functai for TypeScript - v0.1.0
    Preparing search index...

    Variable tConst

    t: {
        boolean: <const E extends Extra & { default?: boolean } = {}>(
            extra?: E,
        ) => Built<E, boolean>;
        enum: <const M extends Members>(...members: M) => TypedShape<M[number]>;
        integer: <const E extends Extra & { default?: number } = {}>(
            extra?: E,
        ) => Built<E, number>;
        json: (extra?: Extra) => Shape<Json>;
        list: <T>(items: Shape<T>, extra?: Extra) => Shape<T[]>;
        media: (type: string) => TypedShape<Record<string, unknown>>;
        nullable: <T>(shape: TypedShape<T>) => TypedShape<T | null>;
        number: <const E extends Extra & { default?: number } = {}>(
            extra?: E,
        ) => Built<E, number>;
        object: <P extends Record<string, Shape<unknown>>>(
            properties: P,
            extra?: Extra,
        ) => TypedShape<{ [K in string | number | symbol]: SpecValue<P[K]> }>;
        opaque: <T = unknown>() => Shape<T>;
        optional: <T>(shape: Shape<T>) => Shape<T | null>;
        record: <V>(values: Shape<V>, extra?: Extra) => Shape<Record<string, V>>;
        string: <const E extends Extra & { default?: string } = {}>(
            extra?: E,
        ) => Built<E, string>;
        withDefault: <T>(
            shape: Shape<T>,
            value: T,
        ) => JsonObject & { __lmcc_value?: T } & { default: T };
    } = ...

    Builders for shapes (lmcc's, plus a map, optional, json and opaque). Each takes extra JSON Schema keys, which add to the shape it makes.

    Type Declaration

    • boolean: <const E extends Extra & { default?: boolean } = {}>(
          extra?: E,
      ) => Built<E, boolean>

      Yes or no; t.boolean({ default: false }) may be left out.

    • enum: <const M extends Members>(...members: M) => TypedShape<M[number]>

      Membership: t.enum("low", "high").

    • integer: <const E extends Extra & { default?: number } = {}>(
          extra?: E,
      ) => Built<E, number>

      An integer; t.integer({ default: 3 }) may be left out.

    • json: (extra?: Extra) => Shape<Json>

      Any JSON value (shape {}), with words about it if you like: t.json({ description: "each input by name" }).

    • list: <T>(items: Shape<T>, extra?: Extra) => Shape<T[]>

      A list: t.list(t.string(), { description: "one per line" }).

    • media: (type: string) => TypedShape<Record<string, unknown>>

      An lm15 part of this type (image, document, …); its value is the part's data.

    • nullable: <T>(shape: TypedShape<T>) => TypedShape<T | null>

      The shape or null (kernel §1 nullable form).

    • number: <const E extends Extra & { default?: number } = {}>(
          extra?: E,
      ) => Built<E, number>

      A number; t.number({ default: 0.5 }) may be left out.

    • object: <P extends Record<string, Shape<unknown>>>(
          properties: P,
          extra?: Extra,
      ) => TypedShape<{ [K in string | number | symbol]: SpecValue<P[K]> }>

      An object with these properties, all required: t.object({ id: t.integer() }, { description }).

    • opaque: <T = unknown>() => Shape<T>

      A module's field whose values may have no JSON form (a class instance, a buffer, a data frame): never checked, written in the log as a description. It cannot cross a boundary that needs data (a server, a conversation store). t.opaque<Buffer>().

    • optional: <T>(shape: Shape<T>) => Shape<T | null>

      The shape or null; a caller may leave it out, and it is then null.

    • record: <V>(values: Shape<V>, extra?: Extra) => Shape<Record<string, V>>

      A map from text keys to values: t.record(t.integer()).

    • string: <const E extends Extra & { default?: string } = {}>(
          extra?: E,
      ) => Built<E, string>

      Text: t.string(); t.string({ default: "kind" }) may be left out (and is typed so).

    • withDefault: <T>(
          shape: Shape<T>,
          value: T,
      ) => JsonObject & { __lmcc_value?: T } & { default: T }

      The shape, with the value an input takes when a caller leaves it out: t.withDefault(t.string(), "kind").