interface ScalarTag {
    collection?: undefined;
    createNode?: ((schema, value, ctx) => yaml.Node<unknown>);
    default?: boolean;
    format?: string;
    identify?: ((value) => boolean);
    nodeClass?: undefined;
    stringify?: ((item, ctx, onComment?, onChompKeep?) => string);
    tag: string;
    test?: RegExp;
    resolve(value, onError, options): unknown;
}

Hierarchy

  • TagBase
    • ScalarTag

Properties

collection?: undefined
createNode?: ((schema, value, ctx) => yaml.Node<unknown>)

Type declaration

    • (schema, value, ctx): yaml.Node<unknown>
    • An optional factory function, used e.g. by collections when wrapping JS objects as AST nodes.

      Parameters

      • schema: yaml.Schema
      • value: unknown
      • ctx: CreateNodeContext

      Returns yaml.Node<unknown>

default?: boolean

If true, together with test allows for values to be stringified without an explicit tag. 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) => boolean)

Type declaration

    • (value): boolean
    • Used by YAML.createNode to detect your data type, e.g. using typeof or instanceof.

      Parameters

      • value: unknown

      Returns boolean

nodeClass?: undefined
stringify?: ((item, ctx, onComment?, onChompKeep?) => string)

Type declaration

    • (item, ctx, onComment?, onChompKeep?): 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.

      Parameters

      • item: Scalar<unknown>

        The node being stringified.

      • ctx: StringifyContext

        Contains the stringifying context variables.

      • Optional onComment: (() => void)

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

          • (): void
          • Returns void

      • Optional onChompKeep: (() => void)

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

          • (): void
          • Returns void

      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) => void)
        • (message): void
        • Parameters

          • message: string

          Returns void

    • options: ParseOptions

    Returns unknown

Generated using TypeDoc