Skip to content

Commit abbac3a

Browse files
committed
style(json-crdt-extensions): 💄 run Prettier
1 parent 232457b commit abbac3a

File tree

8 files changed

+31
-21
lines changed

8 files changed

+31
-21
lines changed

src/json-crdt-extensions/peritext/Peritext.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Peritext implements Printable {
4242
* the current user.
4343
*/
4444
public readonly localSlices: Slices;
45-
45+
4646
public readonly editor: Editor;
4747
public readonly overlay = new Overlay(this);
4848

@@ -53,19 +53,18 @@ export class Peritext implements Printable {
5353
) {
5454
this.savedSlices = new Slices(this.model, slices, this.str);
5555

56-
const extraModel = Model
57-
.withLogicalClock(SESSION.GLOBAL)
56+
const extraModel = Model.withLogicalClock(SESSION.GLOBAL)
5857
.setSchema(s.vec(s.arr([])))
5958
.fork(this.model.clock.sid + 1);
6059
this.extraSlices = new Slices(extraModel, extraModel.root.node().get(0)!, this.str);
6160

6261
// TODO: flush patches
6362
// TODO: remove `arr` tombstones
64-
const localModel = Model
65-
.withLogicalClock(SESSION.LOCAL)
66-
.setSchema(s.vec(s.arr([])));
63+
const localModel = Model.withLogicalClock(SESSION.LOCAL).setSchema(s.vec(s.arr([])));
6764
const localApi = localModel.api;
68-
localApi.onLocalChange.listen(() => { localApi.flush(); });
65+
localApi.onLocalChange.listen(() => {
66+
localApi.flush();
67+
});
6968
this.localSlices = new LocalSlices(localModel, localModel.root.node().get(0)!, this.str);
7069

7170
this.editor = new Editor(this, this.localSlices);

src/json-crdt-extensions/peritext/editor/Cursor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ export class Cursor<T = string> extends PersistedSlice<T> {
5555
if (this.start === this.end) this.end = this.end.clone();
5656
let anchor = this.anchor();
5757
let focus = this.focus();
58-
if (edge === 0) focus = point; else anchor = point;
58+
if (edge === 0) focus = point;
59+
else anchor = point;
5960
if (focus.cmpSpatial(anchor) < 0) this.set(focus, anchor, CursorAnchor.End);
6061
else this.set(anchor, focus, CursorAnchor.Start);
6162
}

src/json-crdt-extensions/peritext/editor/Editor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export class Editor implements Printable {
1919
*/
2020
public readonly cursor: Cursor;
2121

22-
constructor(public readonly txt: Peritext, slices: Slices) {
22+
constructor(
23+
public readonly txt: Peritext,
24+
slices: Slices,
25+
) {
2326
const point = txt.pointAbsStart();
2427
const range = txt.range(point, point.clone());
2528
this.cursor = slices.ins<Cursor, typeof Cursor>(range, SliceBehavior.Cursor, CursorAnchor.Start, undefined, Cursor);

src/json-crdt-extensions/peritext/overlay/Overlay.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ export class Overlay implements Printable, Stateful {
266266
])
267267
);
268268
};
269-
return `${this.constructor.name} #${this.hash.toString(36)}` + printTree(tab, [!this.root ? null : (tab) => printPoint(tab, this.root!)]);
269+
return (
270+
`${this.constructor.name} #${this.hash.toString(36)}` +
271+
printTree(tab, [!this.root ? null : (tab) => printPoint(tab, this.root!)])
272+
);
270273
}
271274
}

src/json-crdt-extensions/peritext/slice/LocalSlices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ export class LocalSlices extends Slices {
55
public del(id: ITimestampStruct): void {
66
super.del(id);
77
if (Math.random() < 0.1) this.set.removeTombstones();
8-
}
8+
}
99
}

src/json-crdt-extensions/peritext/slice/PersistedSlice.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice
8282
if (params.range) {
8383
const range = params.range;
8484
updateHeader = true;
85-
changes.push(
86-
[SliceTupleIndex.X1, s.con(range.start.id)],
87-
[SliceTupleIndex.X2, s.con(range.end.id)]);
85+
changes.push([SliceTupleIndex.X1, s.con(range.start.id)], [SliceTupleIndex.X2, s.con(range.end.id)]);
8886
this.start = range.start;
8987
this.end = range.start === range.end ? range.end.clone() : range.end;
9088
}
@@ -95,9 +93,9 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice
9593
if (hasOwnProperty(params, 'data')) changes.push([SliceTupleIndex.Data, s.con(params.data)]);
9694
if (updateHeader) {
9795
const header =
98-
(this.behavior << SliceHeaderShift.Behavior) +
99-
(this.start.anchor << SliceHeaderShift.X1Anchor) +
100-
(this.end.anchor << SliceHeaderShift.X2Anchor);
96+
(this.behavior << SliceHeaderShift.Behavior) +
97+
(this.start.anchor << SliceHeaderShift.X1Anchor) +
98+
(this.end.anchor << SliceHeaderShift.X2Anchor);
10199
changes.push([SliceTupleIndex.Header, s.con(header)]);
102100
}
103101
this.tupleApi().set(changes);
@@ -150,6 +148,9 @@ export class PersistedSlice<T = string> extends Range<T> implements MutableSlice
150148
const data = this.data();
151149
const dataFormatted = data ? prettyOneLine(data) : '';
152150
const dataLengthBreakpoint = 32;
153-
return this.toStringName() + printTree(tab, [dataFormatted.length < dataLengthBreakpoint ? null : (tab) => dataFormatted]);
151+
return (
152+
this.toStringName() +
153+
printTree(tab, [dataFormatted.length < dataLengthBreakpoint ? null : (tab) => dataFormatted])
154+
);
154155
}
155156
}

src/json-crdt-extensions/peritext/slice/Slices.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ export class Slices implements Stateful, Printable {
2828
protected readonly rga: AbstractRga<string>,
2929
) {}
3030

31-
public ins<S extends PersistedSlice<string>, K extends new (...args: ConstructorParameters<typeof PersistedSlice<string>>) => S>(
31+
public ins<
32+
S extends PersistedSlice<string>,
33+
K extends new (...args: ConstructorParameters<typeof PersistedSlice<string>>) => S,
34+
>(
3235
range: Range,
3336
behavior: SliceBehavior,
3437
type: SliceType,
3538
data?: unknown,
36-
Klass: K = behavior === SliceBehavior.Marker ? <any>MarkerSlice : PersistedSlice
39+
Klass: K = behavior === SliceBehavior.Marker ? <any>MarkerSlice : PersistedSlice,
3740
): S {
3841
const model = this.model;
3942
const set = this.set;

src/json-crdt/nodes/rga/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {AbstractRga, Chunk} from "./AbstractRga";
1+
import type {AbstractRga, Chunk} from './AbstractRga';
22

33
/** Find the first visible chunk, if any. */
44
export const firstVis = <T>(rga: AbstractRga<T>): Chunk<T> | undefined => {

0 commit comments

Comments
 (0)