Skip to content

Commit

Permalink
feat(json-crdt-extensions): 馃幐 improve how slices are presented
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Apr 30, 2024
1 parent 7789ced commit a83518d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/json-crdt-extensions/peritext/slice/PersistedSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice

public toString(tab: string = ''): string {
const data = this.data();
const header = `${this.constructor.name} ${super.toString(tab)}, ${this.behavior}, ${JSON.stringify(this.type)}`;
return header + printTree(tab, [!data ? null : (tab) => prettyOneLine(data)]);
const dataFormatted = data ? prettyOneLine(data) : '';
const dataLengthBreakpoint = 32;
const header = `${this.constructor.name} ${super.toString(tab)}, ${this.behavior}, ${JSON.stringify(this.type)}${dataFormatted.length < dataLengthBreakpoint ? `, ${dataFormatted}` : ''}`;
return header + printTree(tab, [dataFormatted.length < dataLengthBreakpoint ? null : (tab) => dataFormatted]);
}
}

0 comments on commit a83518d

Please sign in to comment.