ts-lambda-api - v2.5.2
    Preparing search index...

    Interface ScalarTag

    interface ScalarTag {
        collection?: never;
        createNode?: (
            schema: Schema,
            value: unknown,
            ctx: CreateNodeContext,
        ) => Node;
        default?: boolean | "key";
        format?: string;
        identify?: (value: unknown) => boolean;
        nodeClass?: never;
        stringify?: (
            item: Scalar,
            ctx: StringifyContext,
            onComment?: () => void,
            onChompKeep?: () => void,
        ) => string;
        tag: string;
        test?: RegExp;
        resolve(
            value: string,
            onError: (message: string) => void,
            options: ParseOptions,
        ): unknown;
    }

    Hierarchy (View Summary)

    Index

    Properties

    collection?: never
    createNode?: (schema: Schema, value: unknown, ctx: CreateNodeContext) => Node

    An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.

    default?: boolean | "key"

    If true, allows for values to be stringified without an explicit tag together with test. If 'key', this only applies if the value is used as a mapping key. For most cases, it's unlikely that you'll actually want to use this, even if you first think you do.

    format?: string

    If a tag has multiple forms that should be parsed and/or stringified differently, use format to identify them.

    identify?: (value: unknown) => boolean

    Used by YAML.createNode to detect your data type, e.g. using typeof or instanceof.

    nodeClass?: never
    stringify?: (
        item: Scalar,
        ctx: StringifyContext,
        onComment?: () => void,
        onChompKeep?: () => void,
    ) => string

    Optional function stringifying a Scalar node. If your data includes a suitable .toString() method, you can probably leave this undefined and use the default stringifier.

    Type declaration

      • (
            item: Scalar,
            ctx: StringifyContext,
            onComment?: () => void,
            onChompKeep?: () => void,
        ): string
      • Parameters

        • item: Scalar

          The node being stringified.

        • ctx: StringifyContext

          Contains the stringifying context variables.

        • OptionalonComment: () => void

          Callback to signal that the stringifier includes the item's comment in its output.

        • OptionalonChompKeep: () => void

          Callback to signal that the output uses a block scalar type with the + chomping indicator.

        Returns string

    tag: string

    The identifier for your data type, with which its stringified form will be prefixed. Should either be a !-prefixed local !tag, or a fully qualified tag:domain,date:foo.

    test?: RegExp

    Together with default allows for values to be stringified without an explicit tag and detected using a regular expression. For most cases, it's unlikely that you'll actually want to use these, even if you first think you do.

    Methods

    • Turns a value into an AST node. If returning a non-Node value, the output will be wrapped as a Scalar.

      Parameters

      • value: string
      • onError: (message: string) => void
      • options: ParseOptions

      Returns unknown