Skip to content

Commit d1db067

Browse files
committed
feat(json-crdt): 🎸 display node index in Model.toString()
1 parent dbeb8d5 commit d1db067

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/json-crdt/model/Model.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
VectorClock,
99
ServerVectorClock,
1010
compare,
11+
toDisplayString,
1112
} from '../../json-crdt-patch/clock';
1213
import {JsonCrdtPatchOperation, Patch} from '../../json-crdt-patch/Patch';
1314
import {ModelApi} from './api/ModelApi';
@@ -340,8 +341,12 @@ export class Model<RootJsonNode extends JsonNode = JsonNode> implements Printabl
340341
this.constructor.name +
341342
printTree(tab, [
342343
(tab) => this.root.toString(tab),
343-
// nl,
344-
// (tab) => this.index.toString(tab),
344+
nl,
345+
(tab) => {
346+
const nodes: JsonNode[] = [];
347+
this.index.forEach(item => nodes.push(item.v));
348+
return `Index (${nodes.length} nodes)` + printTree(tab, nodes.map(node => (tab) => `${node.constructor.name} ${toDisplayString(node.id)}`));
349+
},
345350
nl,
346351
(tab) => this.clock.toString(tab),
347352
hasExtensions ? nl : null,

0 commit comments

Comments
 (0)