Skip to content

Commit

Permalink
style: 💄 run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed May 7, 2024
1 parent 8716cfa commit bd738ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/json-crdt-extensions/peritext/overlay/Overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,22 @@ export class Overlay<T = string> implements Printable, Stateful {
return this.entries();
}

public splitIterator(): () => MarkerOverlayPoint | undefined {
public markerIterator(): () => MarkerOverlayPoint | undefined {
let curr = this.first();
return () => {
while (curr) {
const ret = curr;
if (curr) curr = next(curr);
if (ret instanceof MarkerOverlayPoint) return ret;
}
return undefined;
return;
};
}

public markers(): IterableIterator<OverlayPoint<T>> {
return new UndefEndIter(this.iterator());
}

/**
* Retrieve overlay point or the previous one, measured in spacial dimension.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const setup = () => {

const markerCount = (peritext: Peritext): number => {
const overlay = peritext.overlay;
const iterator = overlay.splitIterator();
const iterator = overlay.markerIterator();
let count = 0;
for (let split = iterator(); split; split = iterator()) {
count++;
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('markers', () => {
expect(markerCount(peritext)).toBe(2);
const points = [];
let point;
for (const iterator = peritext.overlay.splitIterator(); (point = iterator()); ) points.push(point);
for (const iterator = peritext.overlay.markerIterator(); (point = iterator()); ) points.push(point);
expect(points.length).toBe(2);
expect(points[0].pos()).toBe(2);
expect(points[1].pos()).toBe(11);
Expand Down
5 changes: 4 additions & 1 deletion src/util/iterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ export class UndefEndIter<T> implements IterableIterator<T> {
}

export class IterRes<T> {
constructor(public readonly value: T, public readonly done: boolean) {}
constructor(
public readonly value: T,
public readonly done: boolean,
) {}
}

0 comments on commit bd738ad

Please sign in to comment.