Skip to content

Commit a41034b

Browse files
committed
style: 💄 run Prettier
1 parent cd8b62f commit a41034b

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

src/json-crdt/history/LocalHistoryCrud.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {File, FileOptions} from "../file/File";
2-
import {CborEncoder} from "../../json-pack/cbor/CborEncoder";
3-
import type {CrudApi} from "memfs/lib/crud/types";
4-
import type {Locks} from "thingies/es2020/Locks";
5-
import type {Patch} from "../../json-crdt-patch";
6-
import type {PatchLog} from "./PatchLog";
7-
import type {LocalHistory} from "./types";
1+
import {File, FileOptions} from '../file/File';
2+
import {CborEncoder} from '../../json-pack/cbor/CborEncoder';
3+
import type {CrudApi} from 'memfs/lib/crud/types';
4+
import type {Locks} from 'thingies/es2020/Locks';
5+
import type {Patch} from '../../json-crdt-patch';
6+
import type {PatchLog} from './PatchLog';
7+
import type {LocalHistory} from './types';
88

99
export const genId = (octets: number = 8): string => {
1010
const uint8 = crypto.getRandomValues(new Uint8Array(octets));
@@ -29,7 +29,7 @@ export class LocalHistoryCrud implements LocalHistory {
2929
// TODO: Remove `log.end`, just `log` should be enough.
3030
const file = new File(log.end, log, this.fileOpts);
3131
const blob = file.toBinary({
32-
format: "seq.cbor",
32+
format: 'seq.cbor',
3333
model: 'binary',
3434
});
3535
const id = genId();
@@ -39,7 +39,7 @@ export class LocalHistoryCrud implements LocalHistory {
3939
return {id};
4040
}
4141

42-
public async read(collection: string[], id: string): Promise<{log: PatchLog, cursor: string}> {
42+
public async read(collection: string[], id: string): Promise<{log: PatchLog; cursor: string}> {
4343
const blob = await this.crud.get([...collection, id], STATE_FILE_NAME);
4444
const {log} = File.fromSeqCbor(blob);
4545
return {
@@ -48,7 +48,7 @@ export class LocalHistoryCrud implements LocalHistory {
4848
};
4949
}
5050

51-
public readHistory(collection: string[], id: string, cursor: string): Promise<{log: PatchLog, cursor: string}> {
51+
public readHistory(collection: string[], id: string, cursor: string): Promise<{log: PatchLog; cursor: string}> {
5252
throw new Error('Method not implemented.');
5353
}
5454

@@ -59,7 +59,7 @@ export class LocalHistoryCrud implements LocalHistory {
5959
log.end.applyBatch(patches);
6060
const file = new File(log.end, log, this.fileOpts);
6161
const blob2 = file.toBinary({
62-
format: "seq.cbor",
62+
format: 'seq.cbor',
6363
model: 'binary',
6464
});
6565
await this.crud.put([...collection, id], STATE_FILE_NAME, blob2, {throwIf: 'missing'});
@@ -74,7 +74,11 @@ export class LocalHistoryCrud implements LocalHistory {
7474

7575
protected async lock(collection: string[], id: string, fn: () => Promise<void>): Promise<void> {
7676
const key = collection.join('/') + '/' + id;
77-
await this.locks.lock(key, 250, 500)(async () => {
77+
await this.locks.lock(
78+
key,
79+
250,
80+
500,
81+
)(async () => {
7882
await fn();
7983
});
8084
}

src/json-crdt/history/SessionHistory.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import {createRace} from 'thingies/es2020/createRace';
22
import {FanOutUnsubscribe} from 'thingies/es2020/fanout';
3-
import {InsValOp, Patch} from "../../json-crdt-patch";
4-
import {ValNode} from "../nodes";
5-
import {toSchema} from "../schema/toSchema";
6-
import {PatchLog} from "./PatchLog";
7-
import {RedoItem, UndoItem, UndoRedoStack} from "./UndoRedoStack";
3+
import {InsValOp, Patch} from '../../json-crdt-patch';
4+
import {ValNode} from '../nodes';
5+
import {toSchema} from '../schema/toSchema';
6+
import {PatchLog} from './PatchLog';
7+
import {RedoItem, UndoItem, UndoRedoStack} from './UndoRedoStack';
88

99
class Undo implements UndoItem {
10-
constructor (public readonly undo: () => Redo) {}
10+
constructor(public readonly undo: () => Redo) {}
1111
}
1212

1313
class Redo implements RedoItem {
14-
constructor (public readonly redo: () => Undo) {}
14+
constructor(public readonly redo: () => Undo) {}
1515
}
1616

1717
export class SessionHistory {
18-
constructor (
19-
public readonly log: PatchLog,
20-
) {}
21-
18+
constructor(public readonly log: PatchLog) {}
19+
2220
private readonly __onPatchRace = createRace();
2321

2422
public attachUndoRedo(stack: UndoRedoStack): FanOutUnsubscribe {

src/json-crdt/history/__tests__/LocalHistoryCrud.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ test('can delete a document', async () => {
5959
} catch (err) {
6060
expect((err as Error).message).toBe(`Collection /test/${id} does not exist`);
6161
}
62-
});
62+
});

src/json-crdt/history/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export interface RemoteHistory<Cursor> {
3838

3939
export interface LocalHistory {
4040
create(collection: string[], log: PatchLog): Promise<{id: string}>;
41-
read(collection: string[], id: string): Promise<{log: PatchLog, cursor: string}>;
42-
readHistory(collection: string[], id: string, cursor: string): Promise<{log: PatchLog, cursor: string}>;
41+
read(collection: string[], id: string): Promise<{log: PatchLog; cursor: string}>;
42+
readHistory(collection: string[], id: string, cursor: string): Promise<{log: PatchLog; cursor: string}>;
4343
update(collection: string[], id: string, patches: Patch[]): Promise<void>;
4444
delete(collection: string[], id: string): Promise<void>;
4545
}

0 commit comments

Comments
 (0)