Skip to content

Commit 536c848

Browse files
committed
refactor(json-crdt-extensions): 💡 remove Peritext from Point closure
1 parent 0af5609 commit 536c848

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class Peritext implements Printable {
4242
* @returns The point.
4343
*/
4444
public point(id: ITimestampStruct = this.str.id, anchor: Anchor = Anchor.After): Point {
45-
return new Point(this, this.str, id, anchor);
45+
return new Point(this.str, id, anchor);
4646
}
4747

4848
/**

src/json-crdt-extensions/peritext/point/Point.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {ChunkSlice} from '../util/ChunkSlice';
44
import {updateId} from '../../../json-crdt/hash';
55
import type {AbstractRga, Chunk} from '../../../json-crdt/nodes/rga';
66
import type {Stateful} from '../types';
7-
import type {Peritext} from '../Peritext';
87
import type {Printable} from '../../../util/print/types';
98

109
/**
@@ -25,7 +24,6 @@ import type {Printable} from '../../../util/print/types';
2524
*/
2625
export class Point<T = string> implements Pick<Stateful, 'refresh'>, Printable {
2726
constructor(
28-
protected readonly txt: Peritext,
2927
protected readonly rga: AbstractRga<T>,
3028
public id: ITimestampStruct,
3129
public anchor: Anchor,
@@ -48,7 +46,7 @@ export class Point<T = string> implements Pick<Stateful, 'refresh'>, Printable {
4846
* @returns Returns a new point with the same ID and anchor as this point.
4947
*/
5048
public clone(): Point<T> {
51-
return new Point(this.txt, this.rga, this.id, this.anchor);
49+
return new Point(this.rga, this.id, this.anchor);
5250
}
5351

5452
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export class Range implements Printable {
149149
public setCaret(after: ITimestampStruct, shift: number = 0): void {
150150
const id = shift ? tick(after, shift) : after;
151151
const txt = this.txt;
152-
const caretAfter = new Point(txt, txt.str, id, Anchor.After);
152+
const caretAfter = new Point(txt.str, id, Anchor.After);
153153
this.set(caretAfter);
154154
}
155155

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ export class Slices implements Stateful, Printable {
7575
const id2 = (tuple.get(2)!.view() || id1) as ITimestampStruct;
7676
if (!(id1 instanceof Timestamp)) throw new Error('INVALID_ID');
7777
if (!(id2 instanceof Timestamp)) throw new Error('INVALID_ID');
78-
const p1 = new Point(txt, txt.str, id1, anchor1);
79-
const p2 = new Point(txt, txt.str, id2, anchor2);
78+
const p1 = new Point(txt.str, id1, anchor1);
79+
const p2 = new Point(txt.str, id2, anchor2);
8080
const type = tuple.get(3)!.view() as SliceType;
8181
const slice =
8282
behavior === SliceBehavior.Split

0 commit comments

Comments
 (0)