interface CollectionTag {
    collection: "map" | "seq";
    createNode?: ((schema: yaml.Schema, value: unknown, ctx: CreateNodeContext) => yaml.Node);
    default?: boolean | "key";
    format?: string;
    identify?: ((value: unknown) => boolean);
    nodeClass?: {
        from?: ((schema: yaml.Schema, obj: unknown, ctx: CreateNodeContext) => yaml.Node);
        new (schema?: yaml.Schema): yaml.Node;
    };
    resolve?: ((value: yaml.YAMLMap.Parsed<ParsedNode, null | ParsedNode> | yaml.YAMLSeq.Parsed<ParsedNode>, onError: ((message: string) => void), options: ParseOptions) => unknown);
    stringify?: undefined;
    tag: string;
    test?: undefined;
}

Hierarchy

  • TagBase
    • CollectionTag

Properties

collection: "map" | "seq"

The source collection type supported by this tag.

createNode?: ((schema: yaml.Schema, value: unknown, ctx: CreateNodeContext) => yaml.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?: {
    from?: ((schema: yaml.Schema, obj: unknown, ctx: CreateNodeContext) => yaml.Node);
    new (schema?: yaml.Schema): yaml.Node;
}

The Node child class that implements this tag. If set, used to select this tag when stringifying.

If the class provides a static from method, then that will be used if the tag object doesn't have a createNode method.

resolve?: ((value: yaml.YAMLMap.Parsed<ParsedNode, null | ParsedNode> | yaml.YAMLSeq.Parsed<ParsedNode>, onError: ((message: string) => void), options: ParseOptions) => unknown)

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

Note: this is required if nodeClass is not provided.

stringify?: undefined
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?: undefined