Skip to content

Commit 2145d24

Browse files
committed
style: 💄 run Prettier
1 parent c3ffd13 commit 2145d24

File tree

4 files changed

+48
-49
lines changed

4 files changed

+48
-49
lines changed

src/json-crdt-extensions/peritext/__tests__/setup.ts

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const schema = (text: string) =>
1414
export const setupKit = (
1515
initialText: string = '',
1616
edits: (model: Model<SchemaToJsonNode<Schema>>) => void = () => {},
17-
sid?: number
17+
sid?: number,
1818
) => {
1919
const model = ModelWithExt.create(schema(initialText), sid);
2020
edits(model);
@@ -67,35 +67,39 @@ export const setupNumbersKit = (): Kit => {
6767
* block-wise chunks, as well as with plenty of tombstones.
6868
*/
6969
export const setupNumbersWithTombstonesKit = (sid?: number): Kit => {
70-
return setupKit('1234', (model) => {
71-
const str = model.s.text.toExt().text();
72-
str.ins(0, '234');
73-
str.ins(1, '234');
74-
str.ins(2, '345');
75-
str.ins(3, '456');
76-
str.ins(4, '567');
77-
str.ins(5, '678');
78-
str.ins(6, '789');
79-
str.del(7, 1);
80-
str.del(8, 1);
81-
str.ins(0, '0');
82-
str.del(1, 4);
83-
str.del(2, 1);
84-
str.ins(1, '1');
85-
str.del(0, 1);
86-
str.ins(0, '0');
87-
str.ins(2, '234');
88-
str.del(4, 7);
89-
str.del(4, 2);
90-
str.del(7, 3);
91-
str.ins(6, '6789');
92-
str.del(7, 2);
93-
str.ins(7, '78');
94-
str.del(10, 2);
95-
str.del(2, 3);
96-
str.ins(2, 'x234');
97-
str.del(2, 1);
98-
str.del(10, 3);
99-
if (str.view() !== '0123456789') throw new Error('Invalid text');
100-
}, sid);
70+
return setupKit(
71+
'1234',
72+
(model) => {
73+
const str = model.s.text.toExt().text();
74+
str.ins(0, '234');
75+
str.ins(1, '234');
76+
str.ins(2, '345');
77+
str.ins(3, '456');
78+
str.ins(4, '567');
79+
str.ins(5, '678');
80+
str.ins(6, '789');
81+
str.del(7, 1);
82+
str.del(8, 1);
83+
str.ins(0, '0');
84+
str.del(1, 4);
85+
str.del(2, 1);
86+
str.ins(1, '1');
87+
str.del(0, 1);
88+
str.ins(0, '0');
89+
str.ins(2, '234');
90+
str.del(4, 7);
91+
str.del(4, 2);
92+
str.del(7, 3);
93+
str.ins(6, '6789');
94+
str.del(7, 2);
95+
str.ins(7, '78');
96+
str.del(10, 2);
97+
str.del(2, 3);
98+
str.ins(2, 'x234');
99+
str.del(2, 1);
100+
str.del(10, 3);
101+
if (str.view() !== '0123456789') throw new Error('Invalid text');
102+
},
103+
sid,
104+
);
101105
};

src/json-crdt-extensions/peritext/block/Inline.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ export type InlineAttributes = Record<string | number, unknown>;
2222
* full text content of the inline.
2323
*/
2424
export class Inline extends Range implements Printable {
25-
public static create(
26-
txt: Peritext,
27-
start: OverlayPoint,
28-
end: OverlayPoint,
29-
) {
25+
public static create(txt: Peritext, start: OverlayPoint, end: OverlayPoint) {
3026
const texts: ChunkSlice[] = [];
3127
txt.overlay.chunkSlices0(undefined, start, end, (chunk, off, len) => {
3228
if (txt.overlay.isMarker(chunk.id)) return;
@@ -39,7 +35,7 @@ export class Inline extends Range implements Printable {
3935
rga: AbstractRga<string>,
4036
public start: OverlayPoint,
4137
public end: OverlayPoint,
42-
38+
4339
/**
4440
* @todo PERF: for performance reasons, we should consider not passing in
4541
* this array. Maybe pass in just the initial chunk and the offset. However,

src/json-crdt-extensions/peritext/block/__tests__/Inline.key.spec.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Timestamp} from '../../../../json-crdt-patch';
22
import {updateId} from '../../../../json-crdt/hash';
33
import {updateNum} from '../../../../json-hash';
4-
import {Kit, setupKit, setupNumbersKit, setupNumbersWithTombstonesKit} from '../../__tests__/setup';
4+
import {Kit, setupKit, setupNumbersKit, setupNumbersWithTombstonesKit} from '../../__tests__/setup';
55
import {Point} from '../../rga/Point';
66
import {Inline} from '../Inline';
77

@@ -40,14 +40,8 @@ describe('range hash', () => {
4040
});
4141

4242
test('computes unique hash - 4', () => {
43-
const hash1 = updateNum(
44-
updateId(0, new Timestamp(2, 7)),
45-
updateId(1, new Timestamp(2, 7)),
46-
);
47-
const hash2 = updateNum(
48-
updateId(0, new Timestamp(2, 6)),
49-
updateId(1, new Timestamp(2, 40)),
50-
);
43+
const hash1 = updateNum(updateId(0, new Timestamp(2, 7)), updateId(1, new Timestamp(2, 7)));
44+
const hash2 = updateNum(updateId(0, new Timestamp(2, 6)), updateId(1, new Timestamp(2, 40)));
5145
expect(hash1).not.toBe(hash2);
5246
});
5347
});

src/json-crdt-extensions/peritext/block/__tests__/Inline.str.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Kit, setupKit, setupNumbersKit, setupNumbersWithTombstonesKit} from '../../__tests__/setup';
1+
import {Kit, setupKit, setupNumbersKit, setupNumbersWithTombstonesKit} from '../../__tests__/setup';
22
import {Inline} from '../Inline';
33

44
const runStrTests = (setup: () => Kit) => {
@@ -14,7 +14,12 @@ const runStrTests = (setup: () => Kit) => {
1414
const [start, end] = [...overlay.points()];
1515
const inline = Inline.create(peritext, start, end);
1616
const str = inline.str();
17-
expect(str).toBe(peritext.strApi().view().slice(i, i + j));
17+
expect(str).toBe(
18+
peritext
19+
.strApi()
20+
.view()
21+
.slice(i, i + j),
22+
);
1823
}
1924
}
2025
});

0 commit comments

Comments
 (0)