Skip to content

Commit

Permalink
style(json-crdt): 💄 run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 29, 2024
1 parent 6f35c01 commit 0723a09
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/json-crdt/model/api/ModelApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export class ModelApi<N extends JsonNode = JsonNode> implements SyncStore<JsonNo
/**
* Locates a `con` node and returns a local changes API for it. If the node
* doesn't exist or the node at the path is not a `con` node, throws an error.
*
*
* @todo Rename to `con`.
*
* @param path Path at which to locate a node.
Expand Down
10 changes: 6 additions & 4 deletions src/json-crdt/schema/__tests__/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ describe('can infer schema of JSON CRDT nodes', () => {
});

test('from typed model', () => {
const model = Model.withLogicalClock().setSchema(s.obj({
id: s.con('asdf'),
age: s.val(s.con(42)),
}));
const model = Model.withLogicalClock().setSchema(
s.obj({
id: s.con('asdf'),
age: s.val(s.con(42)),
}),
);
type Node = ReturnType<typeof model.root.node>;
type Schema = JsonNodeToSchema<Node>;
const schema: Schema = s.obj({
Expand Down
12 changes: 5 additions & 7 deletions src/json-crdt/schema/toSchema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {JsonNode, ConNode, ValNode, ObjNode, VecNode, StrNode, BinNode, ArrNode} from "../nodes";
import {NodeBuilder, s} from "../../json-crdt-patch";
import type {JsonNodeToSchema} from "./types";
import {JsonNode, ConNode, ValNode, ObjNode, VecNode, StrNode, BinNode, ArrNode} from '../nodes';
import {NodeBuilder, s} from '../../json-crdt-patch';
import type {JsonNodeToSchema} from './types';

/**
* Converts any JSON CRDT node to a schema representation. The schema can be
* used to copy the structure of the JSON CRDT node to another document or
* another location in the same document.
*
* @todo Add type generic.
*
*
* @param node JSON CRDT node to recursively convert to schema.
* @returns Schema representation of the JSON CRDT node.
*/
Expand All @@ -17,7 +15,7 @@ export const toSchema = <N extends JsonNode<any>>(node: N): JsonNodeToSchema<N>
if (node instanceof ValNode) return s.val(toSchema(node.node())) as any;
if (node instanceof ObjNode) {
const obj: Record<string, NodeBuilder> = {};
node.nodes((child, key) => obj[key] = toSchema(child));
node.nodes((child, key) => (obj[key] = toSchema(child)));
return s.obj(obj) as any;
}
if (node instanceof VecNode) {
Expand Down

0 comments on commit 0723a09

Please sign in to comment.