Variable sConst

s: {
    arr: (<T>(arr) => nodes.arr<T>);
    bin: ((bin) => nodes.bin);
    con: (<T>(raw) => nodes.con<T>);
    ext: (<ID, T>(id, data) => ext<ID, T>);
    json: (<T>(value) => json<T>);
    jsonCon: (<T>(value) => jsonCon<T>);
    map: (<R>(obj) => map<R>);
    obj: (<T, O>(obj, opt?) => nodes.obj<T, O>);
    str: (<T>(str) => nodes.str<T>);
    val: (<T>(val) => nodes.val<T>);
    vec: (<T>(...vec) => nodes.vec<T>);
} = schema

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

Type declaration

  • arr: (<T>(arr) => nodes.arr<T>)

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

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

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

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

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

      • <T>(raw): nodes.con<T>
      • Type Parameters

        • T extends unknown

        Parameters

        • raw: T

          Raw default value.

        Returns nodes.con<T>

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

    Creates an extension node schema.

      • <ID, T>(id, data): ext<ID, T>
      • Type Parameters

        Parameters

        • id: ID

          A unique extension ID.

        • data: T

          Schema of the data node of the extension.

        Returns ext<ID, T>

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

    Recursively creates a node tree from any POJO. It uses the Builder.json method to create a JSON node. It can be used similar to TypeScript's any type, where the value can be anything.

      • <T>(value): json<T>
      • Type Parameters

        • T

        Parameters

        • value: T

          Default value.

        Returns json<T>

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

    Recursively creates a node tree from any POJO. It uses the Builder.constOrJson method to create a JSON node. It can be used similar to TypeScript's any type, where the value can be anything.

  • map: (<R>(obj) => 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.

      • <R>(obj): map<R>
      • Type Parameters

        Parameters

        • obj: Record<string, R>

          Default value.

        Returns map<R>

  • obj: (<T, O>(obj, opt?) => nodes.obj<T, O>)

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

      • <T, O>(obj, opt?): nodes.obj<T, O>
      • Type Parameters

        Parameters

        • obj: T

          Default value, required object keys.

        • Optional opt: O

          Default value of optional object keys.

        Returns nodes.obj<T, O>

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

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

      • <T>(str): nodes.str<T>
      • Type Parameters

        • T extends string

        Parameters

        • str: T

          Default value.

        Returns nodes.str<T>

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

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

  • vec: (<T>(...vec) => nodes.vec<T>)

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