Skip to content

Commit 397468d

Browse files
committed
style(json-crdt): 💄 run Prettier
1 parent 5c294cc commit 397468d

File tree

4 files changed

+34
-33
lines changed

4 files changed

+34
-33
lines changed

src/json-crdt/model/__tests__/Model.node-deletion.spec.ts

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,17 @@ test('removes from index recursively after LWW register write', () => {
163163
});
164164

165165
test('calling .view() on dangling "obj" when it was deleted, should not throw', () => {
166-
const doc = Model.withLogicalClock()
167-
.setSchema(s.obj({
166+
const doc = Model.withLogicalClock().setSchema(
167+
s.obj({
168168
foo: s.obj({
169169
bar: s.obj({
170170
baz: s.con(123),
171171
qux: s.str('asdf'),
172172
}),
173173
}),
174-
}));
175-
174+
}),
175+
);
176+
176177
const bar = doc.root.child()!.get('foo')!.get('bar')!;
177178
const baz = bar.get('baz')!;
178179
const qux = bar.get('qux')!;
@@ -188,15 +189,13 @@ test('calling .view() on dangling "obj" when it was deleted, should not throw',
188189
});
189190

190191
test('calling .view() on dangling "arr" when it was deleted, should not throw', () => {
191-
const doc = Model.withLogicalClock()
192-
.setSchema(s.obj({
192+
const doc = Model.withLogicalClock().setSchema(
193+
s.obj({
193194
foo: s.obj({
194-
bar: s.arr([
195-
s.con(123),
196-
s.str('asdf'),
197-
]),
195+
bar: s.arr([s.con(123), s.str('asdf')]),
198196
}),
199-
}));
197+
}),
198+
);
200199
const bar = doc.root.child()!.get('foo')!.get('bar')!;
201200
expect(bar.view()).toStrictEqual([123, 'asdf']);
202201
doc.api.obj(['foo']).del(['bar']);
@@ -205,15 +204,13 @@ test('calling .view() on dangling "arr" when it was deleted, should not throw',
205204
});
206205

207206
test('calling .view() on dangling "vec" when it was deleted, should not throw', () => {
208-
const doc = Model.withLogicalClock()
209-
.setSchema(s.obj({
207+
const doc = Model.withLogicalClock().setSchema(
208+
s.obj({
210209
foo: s.obj({
211-
bar: s.vec(
212-
s.con(123),
213-
s.str('asdf'),
214-
),
210+
bar: s.vec(s.con(123), s.str('asdf')),
215211
}),
216-
}));
212+
}),
213+
);
217214
const bar = doc.root.child()!.get('foo')!.get('bar')!;
218215
expect(bar.view()).toStrictEqual([123, 'asdf']);
219216
doc.api.obj(['foo']).del(['bar']);
@@ -222,14 +219,13 @@ test('calling .view() on dangling "vec" when it was deleted, should not throw',
222219
});
223220

224221
test('calling .view() on dangling "val" when it was deleted, should not throw', () => {
225-
const doc = Model.withLogicalClock()
226-
.setSchema(s.obj({
222+
const doc = Model.withLogicalClock().setSchema(
223+
s.obj({
227224
foo: s.obj({
228-
bar: s.val(
229-
s.str('asdf'),
230-
),
225+
bar: s.val(s.str('asdf')),
231226
}),
232-
}));
227+
}),
228+
);
233229
const bar = doc.root.child()!.get('foo')!.get('bar')!;
234230
expect(bar.view()).toStrictEqual('asdf');
235231
doc.api.obj(['foo']).del(['bar']);

src/json-crdt/nodes/arr/ArrNode.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,10 @@ export class ArrNode<Element extends JsonNode = JsonNode>
193193
const index = this.doc.index;
194194
valueTree = printTree(
195195
tab,
196-
chunk.data!.map((id) => index.get(id)).filter((node) => !!node).map(
197-
(node, i) => (tab) => `[${pos + i}]: ${node!.toString(tab + ' ' + ' '.repeat(String(i).length))}`,
198-
),
196+
chunk
197+
.data!.map((id) => index.get(id))
198+
.filter((node) => !!node)
199+
.map((node, i) => (tab) => `[${pos + i}]: ${node!.toString(tab + ' ' + ' '.repeat(String(i).length))}`),
199200
);
200201
}
201202
return (

src/json-crdt/nodes/obj/ObjNode.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ export class ObjNode<Value extends Record<string, JsonNode> = Record<string, Jso
142142
header +
143143
printTree(
144144
tab,
145-
[...this.keys.entries()].filter(([, id]) => !!this.doc.index.get(id)).map(
146-
([key, id]) =>
147-
(tab) =>
148-
JSON.stringify(key) + printTree(tab + ' ', [(tab) => this.doc.index.get(id)!.toString(tab)]),
149-
),
145+
[...this.keys.entries()]
146+
.filter(([, id]) => !!this.doc.index.get(id))
147+
.map(
148+
([key, id]) =>
149+
(tab) =>
150+
JSON.stringify(key) + printTree(tab + ' ', [(tab) => this.doc.index.get(id)!.toString(tab)]),
151+
),
150152
)
151153
);
152154
}

src/json-crdt/nodes/vec/VecNode.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,9 @@ export class VecNode<Value extends JsonNode[] = JsonNode[]>
189189
printTree(tab, [
190190
...this.elements.map(
191191
(id, i) => (tab: string) =>
192-
`${i}: ${!id ? 'nil' : index.get(id) ? index.get(id)!.toString(tab + ' ' + ' '.repeat(('' + i).length)) : 'nil'}`,
192+
`${i}: ${
193+
!id ? 'nil' : index.get(id) ? index.get(id)!.toString(tab + ' ' + ' '.repeat(('' + i).length)) : 'nil'
194+
}`,
193195
),
194196
...(extNode ? [(tab: string) => `${this.child()!.toString(tab)}`] : []),
195197
])

0 commit comments

Comments
 (0)