Skip to content

Commit

Permalink
Merge pull request #526 from streamich/bump-prettier
Browse files Browse the repository at this point in the history
Bump `prettier`
  • Loading branch information
streamich authored Mar 4, 2024
2 parents 3f1a634 + 1d19607 commit 107f63b
Show file tree
Hide file tree
Showing 95 changed files with 580 additions and 288 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"ot-text-unicode": "^4.0.0",
"p4-css": "^1.5.1",
"pako": "^2.0.4",
"prettier": "^2.6.2",
"prettier": "^3.2.5",
"pretty-quick": "^3.1.3",
"quill-delta": "^5.0.0",
"react": "^18.2.0",
Expand Down
5 changes: 4 additions & 1 deletion src/json-block/Block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export interface BlockModel<Data, Patch> {
export class BasicBlock<Data, Patch> {
public v$: BehaviorSubject<number>;

constructor(version: number, public readonly model: BlockModel<Data, Patch>) {
constructor(
version: number,
public readonly model: BlockModel<Data, Patch>,
) {
this.v$ = new BehaviorSubject<number>(version);
}

Expand Down
4 changes: 2 additions & 2 deletions src/json-cli/routes/crdt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export const defineCrdtRoutes = <Routes extends ObjectType<any>>(r: ObjectValue<
const model = serverClock
? Model.withServerClock()
: sid !== undefined
? Model.withLogicalClock(sid)
: Model.withLogicalClock();
? Model.withLogicalClock(sid)
: Model.withLogicalClock();
if (value !== undefined) model.api.root(value);
const patch = model.api.flush();
const patchEncoded = patch && patch.ops.length ? encodePatch(patch) : null;
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt-patch/builder/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ export namespace nodes {
> extends NodeBuilder {
public readonly type = 'obj';

constructor(public readonly obj: T, public readonly opt?: O) {
constructor(
public readonly obj: T,
public readonly opt?: O,
) {
super((builder) => {
const objId = builder.obj();
const keyValuePairs: [key: string, value: ITimestampStruct][] = [];
Expand Down
11 changes: 9 additions & 2 deletions src/json-crdt-patch/clock/clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import {SESSION} from '../constants';
import type {IClock, IClockVector, ITimestampStruct, ITimespanStruct} from './types';

export class Timestamp implements ITimestampStruct {
constructor(public readonly sid: number, public time: number) {}
constructor(
public readonly sid: number,
public time: number,
) {}
}

export class Timespan implements ITimespanStruct {
constructor(public readonly sid: number, public time: number, public span: number) {}
constructor(
public readonly sid: number,
public time: number,
public span: number,
) {}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt-patch/codec/clock/ClockEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import {ITimestampStruct, IClockVector, tick, Timestamp} from '../../clock';
import {RelativeTimestamp} from './RelativeTimestamp';

class ClockTableEntry {
constructor(public index: number, public clock: ITimestampStruct) {}
constructor(
public index: number,
public clock: ITimestampStruct,
) {}
}

export class ClockEncoder {
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt-patch/codec/clock/ClockTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import {CrdtReader} from '../../util/binary/CrdtReader';
import {CrdtWriter} from '../../util/binary/CrdtWriter';

export class ClockTableEntry {
constructor(public index: number, public id: ITimestampStruct) {}
constructor(
public index: number,
public id: ITimestampStruct,
) {}
}

export class ClockTable {
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt-patch/codec/clock/RelativeTimestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ export class RelativeTimestamp {
* @param sessionIndex Index of the clock in clock table.
* @param timeDiff Time difference relative to the clock time from the table.
*/
public constructor(public readonly sessionIndex: number, public readonly timeDiff: number) {}
public constructor(
public readonly sessionIndex: number,
public readonly timeDiff: number,
) {}
}
18 changes: 12 additions & 6 deletions src/json-crdt-patch/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import {type ITimestampStruct, type ITimespanStruct, Timestamp, toDisplayString}
* @category Operations
*/
export class NewConOp implements IJsonCrdtPatchOperation {
constructor(public readonly id: ITimestampStruct, public readonly val: unknown | undefined | ITimestampStruct) {}
constructor(
public readonly id: ITimestampStruct,
public readonly val: unknown | undefined | ITimestampStruct,
) {}

public span(): number {
return 1;
Expand All @@ -23,10 +26,10 @@ export class NewConOp implements IJsonCrdtPatchOperation {
val instanceof Timestamp
? `{ ${toDisplayString(val)} }`
: val instanceof Uint8Array
? val.length < 13
? `Uint8Array { ${('' + val).replaceAll(',', ', ')} }`
: `Uint8Array(${val.length})`
: `{ ${JSON.stringify(val)} }`;
? val.length < 13
? `Uint8Array { ${('' + val).replaceAll(',', ', ')} }`
: `Uint8Array(${val.length})`
: `{ ${JSON.stringify(val)} }`;
return `${this.name()} ${toDisplayString(this.id)} ${valFormatted}`;
}
}
Expand Down Expand Up @@ -385,7 +388,10 @@ export class DelOp implements IJsonCrdtPatchEditOperation {
* @category Operations
*/
export class NopOp implements IJsonCrdtPatchOperation {
constructor(public readonly id: ITimestampStruct, public readonly len: number) {}
constructor(
public readonly id: ITimestampStruct,
public readonly len: number,
) {}

public span(): number {
return this.len;
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/__tests__/fuzzer/SessionLogical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export class SessionLogical {

public readonly debug = false;

public constructor(public fuzzer: JsonCrdtFuzzer, public concurrency: number) {
public constructor(
public fuzzer: JsonCrdtFuzzer,
public concurrency: number,
) {
if (this.debug) this.modelStart = jsonEncoder.encode(fuzzer.model);
for (let i = 0; i < concurrency; i++) {
const model = fuzzer.model.fork();
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/file/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export class File implements Printable {
return new File(model, PatchLog.fromModel(model));
}

constructor(public readonly model: Model, public readonly log: PatchLog) {}
constructor(
public readonly model: Model,
public readonly log: PatchLog,
) {}

public apply(patch: Patch): void {
const id = patch.getId();
Expand Down
10 changes: 8 additions & 2 deletions src/json-crdt/model/api/fanout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export class MicrotaskBufferFanOut<I> extends FanOut<I[]> {
* Maps the data from a fanout using a mapper function.
*/
export class MapFanOut<I, O> extends FanOut<O> {
constructor(private readonly source: FanOut<I>, private readonly mapper: (data: I) => O) {
constructor(
private readonly source: FanOut<I>,
private readonly mapper: (data: I) => O,
) {
super();
}

Expand Down Expand Up @@ -96,7 +99,10 @@ export class MapFanOut<I, O> extends FanOut<O> {
export class OnNewFanOut<D> extends FanOut<D> {
private unsub?: FanOutUnsubscribe = undefined;

constructor(private readonly source: FanOut<D>, private last: D | undefined = undefined) {
constructor(
private readonly source: FanOut<D>,
private last: D | undefined = undefined,
) {
super();
}

Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/model/api/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export type ApiPath = string | number | Path | void;
* @category Local API
*/
export class NodeApi<N extends JsonNode = JsonNode> implements Printable {
constructor(public node: N, public readonly api: ModelApi<any>) {}
constructor(
public node: N,
public readonly api: ModelApi<any>,
) {}

/** @ignore */
private ev: undefined | NodeEvents<N> = undefined;
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/nodes/arr/ArrNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export class ArrNode<Element extends JsonNode = JsonNode>
extends AbstractRga<E[]>
implements JsonNode<JsonNodeView<Element>[]>, Printable
{
constructor(public readonly doc: Model<any>, id: ITimestampStruct) {
constructor(
public readonly doc: Model<any>,
id: ITimestampStruct,
) {
super(id);
}

Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/nodes/const/ConNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ export class ConNode<View = unknown | ITimestampStruct> implements JsonNode<View
* @param val Raw value of the constant. It can be any JSON/CBOR value, or
* a logical timestamp {@link Timestamp}.
*/
constructor(public readonly id: ITimestampStruct, public readonly val: View) {}
constructor(
public readonly id: ITimestampStruct,
public readonly val: View,
) {}

// ----------------------------------------------------------------- JsonNode

Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/partial-edit/PartialEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export class PartialEdit {
}

export class PartialEditFactory {
constructor(protected readonly decoder: Decoder, protected readonly encoder: Encoder) {}
constructor(
protected readonly decoder: Decoder,
protected readonly encoder: Encoder,
) {}

public startPartialEdit(clockBlob: IndexedFields['c']): PartialEdit {
const reader = this.decoder.dec.reader;
Expand Down
5 changes: 4 additions & 1 deletion src/json-crdt/partial-edit/PartialEditFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {IndexedFields} from '../codec/indexed/binary/types';
import {PartialEdit} from './PartialEdit';

export class PartialEditFactory {
constructor(protected readonly decoder: Decoder, protected readonly encoder: Encoder) {}
constructor(
protected readonly decoder: Decoder,
protected readonly encoder: Encoder,
) {}

public startPartialEdit(clockBlob: IndexedFields['c']): PartialEdit {
const reader = this.decoder.dec.reader;
Expand Down
4 changes: 2 additions & 2 deletions src/json-ot/types/ot-json/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const toStringNode = (self: PickNode | DropNode, tab: string = ''): string => {
(self as PickNode).regId === undefined
? ''
: (self as PickNode).regId === -1
? ''
: ` [${(self as PickNode).regId}]`;
? ''
: ` [${(self as PickNode).regId}]`;
return `${indexFormatted} ${self.constructor.name}${registerFormatted}${children}`;
};

Expand Down
5 changes: 4 additions & 1 deletion src/json-pack/JsonPackExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
* @category Value
*/
export class JsonPackExtension<T = Uint8Array> {
constructor(public readonly tag: number, public readonly val: T) {}
constructor(
public readonly tag: number,
public readonly val: T,
) {}
}
6 changes: 5 additions & 1 deletion src/json-pack/__bench__/profiler/slices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ const arr3 = Buffer.allocUnsafe(1024 * 4);
const FastBuffer = (Buffer as any)[Symbol.species] as any;

class Slice {
constructor(public uint8: ArrayBuffer, public start: number, public end: number) {}
constructor(
public uint8: ArrayBuffer,
public start: number,
public end: number,
) {}
}

const res = {
Expand Down
6 changes: 5 additions & 1 deletion src/json-pack/__bench__/profiler/truncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

const i = 10000;
class MySlice {
constructor(public uint8: ArrayBuffer, public start: number, public end: number) {}
constructor(
public uint8: ArrayBuffer,
public start: number,
public end: number,
) {}
}

console.time('new Slice()');
Expand Down
26 changes: 21 additions & 5 deletions src/json-pack/bson/values.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
export class BsonObjectId {
public constructor(public timestamp: number, public process: number, public counter: number) {}
public constructor(
public timestamp: number,
public process: number,
public counter: number,
) {}
}

export class BsonDbPointer {
public constructor(public name: string, public id: BsonObjectId) {}
public constructor(
public name: string,
public id: BsonObjectId,
) {}
}

export class BsonJavascriptCode {
Expand All @@ -15,7 +22,10 @@ export class BsonSymbol {
}

export class BsonJavascriptCodeWithScope {
public constructor(public code: string, public scope: Record<string, unknown>) {}
public constructor(
public code: string,
public scope: Record<string, unknown>,
) {}
}

export class BsonInt32 {
Expand All @@ -31,7 +41,10 @@ export class BsonFloat {
}

export class BsonTimestamp {
public constructor(public increment: number, public timestamp: number) {}
public constructor(
public increment: number,
public timestamp: number,
) {}
}

export class BsonDecimal128 {
Expand All @@ -43,5 +56,8 @@ export class BsonMinKey {}
export class BsonMaxKey {}

export class BsonBinary {
public constructor(public subtype: number, public data: Uint8Array) {}
public constructor(
public subtype: number,
public data: Uint8Array,
) {}
}
4 changes: 2 additions & 2 deletions src/json-pack/cbor/__tests__/cbor-js.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const run = (encoder: CborEncoder, decoder: CborDecoder) => {
decoded2 instanceof JsonPackExtension
? decoded2.val
: decoded2 instanceof JsonPackValue
? decoded2.val
: decoded2;
? decoded2.val
: decoded2;
expect(resultValue).toStrictEqual(value);
} else {
expect(() => decoder.decode(hex2arrayBuffer(expected))).toThrow();
Expand Down
5 changes: 4 additions & 1 deletion src/json-pack/ion/Import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ export class Import {
public length: number;
protected readonly byText = new Map<string, number>();

constructor(public readonly parent: Import | null, public readonly symbols: SymbolTable) {
constructor(
public readonly parent: Import | null,
public readonly symbols: SymbolTable,
) {
this.offset = parent ? parent.offset + parent.length : 1;
this.length = symbols.length;
for (let i = 0; i < symbols.length; i++) {
Expand Down
5 changes: 4 additions & 1 deletion src/json-pack/ion/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ export class ObjAstNode implements AstNode<Map<number, AstNode<unknown>> | null>
export class AnnotationAstNode implements AstNode<AstNode<unknown>> {
public readonly len: number;
public readonly annotationLen: number;
constructor(public readonly val: AstNode<unknown>, public readonly annotations: number[]) {
constructor(
public readonly val: AstNode<unknown>,
public readonly annotations: number[],
) {
let len = 0;
for (let i = 0; i < annotations.length; i++) len += vUintLen(annotations[i]);
this.annotationLen = len;
Expand Down
3 changes: 2 additions & 1 deletion src/json-pack/json/JsonEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class JsonEncoder implements BinaryJsonEncoder, StreamingBinaryJsonEncode
}

public writeBoolean(bool: boolean): void {
if (bool) this.writer.u32(0x74727565); // true
if (bool)
this.writer.u32(0x74727565); // true
else this.writer.u8u32(0x66, 0x616c7365); // false
}

Expand Down
Loading

0 comments on commit 107f63b

Please sign in to comment.