json-joy
    Preparing search index...

    Variable schemaConst

    schema: {
        arr: <T extends NodeBuilder>(arr: T[]) => nodes.arr<T>;
        bin: (bin: Uint8Array) => nodes.bin;
        con: <T extends unknown>(raw: T) => nodes.con<T>;
        ext: <ID extends number, T extends NodeBuilder>(
            id: ID,
            data: T,
        ) => ext<ID, T>;
        json: <T>(value: T) => json<T>;
        jsonCon: <T>(value: T) => jsonCon<T>;
        map: <R extends NodeBuilder>(obj: Record<string, R>) => map<R>;
        obj: <
            T extends Record<string, NodeBuilder>,
            O extends Record<string, NodeBuilder>,
        >(
            obj: T,
            opt?: O,
        ) => nodes.obj<T, O>;
        str: <T extends string>(str: T) => nodes.str<T>;
        val: <T extends NodeBuilder>(val: T) => nodes.val<T>;
        vec: <T extends NodeBuilder[]>(...vec: T) => nodes.vec<T>;
    } = ...

    Schema builder. Use this to create a JSON CRDT model schema and the default value.

    Example:

    const schema = s.obj({
    name: s.str(''),
    age: s.con(0),
    tags: s.arr<nodes.con<string>>([]),
    });

    Type declaration

    • arr: <T extends NodeBuilder>(arr: T[]) => nodes.arr<T>

      Creates an "arr" node schema and the default value.

    • bin: (bin: Uint8Array) => nodes.bin

      Creates a "bin" node schema and the default value.

    • con: <T extends unknown>(raw: T) => nodes.con<T>

      Creates a "con" node schema and the default value.

    • ext: <ID extends number, T extends NodeBuilder>(id: ID, data: T) => ext<ID, T>

      Creates an extension node schema.

    • json: <T>(value: T) => json<T>

      Recursively creates a node tree from any POJO.

    • jsonCon: <T>(value: T) => jsonCon<T>

      Recursively creates a schema node tree from any POJO. Same as json, but converts constant values to nodes.con nodes, instead wrapping them into nodes.val nodes.

      Remove this once "arr" RGA supports in-place updates.

    • map: <R extends NodeBuilder>(obj: Record<string, R>) => map<R>

      This is an alias for schema.obj. It creates a "map" node schema, which is an object where a key can be any string and the value is of the same type.

    • obj: <T extends Record<string, NodeBuilder>, O extends Record<string, NodeBuilder>>(
          obj: T,
          opt?: O,
      ) => nodes.obj<T, O>

      Creates a "obj" node schema and the default value.

    • str: <T extends string>(str: T) => nodes.str<T>

      Creates a "str" node schema and the default value.

    • val: <T extends NodeBuilder>(val: T) => nodes.val<T>

      Creates a "val" node schema and the default value.

    • vec: <T extends NodeBuilder[]>(...vec: T) => nodes.vec<T>

      Creates a "vec" node schema and the default value.