Type Parameters

Hierarchy (view full)

Constructors

Properties

[NODE_TYPE]: symbol
comment: null | string

A comment immediately after this Document

commentBefore: null | string

A comment before this Document

contents: null | T

The document contents.

directives?: Directives
errors: YAMLError[]

Errors encountered during parsing.

options: Required<Omit<ParseOptions & DocumentOptions, "version" | "_directives" | "lineCounter">>
range?: Range

The [start, value-end, node-end] character offsets for the part of the source parsed into this document (undefined if not parsed). The value-end and node-end positions are themselves not included in their respective ranges.

schema: yaml.Schema

The schema used with the document. Use setSchema() to change.

warnings: YAMLWarning[]

Warnings encountered during parsing.

Methods

  • Adds a value to the document.

    Parameters

    • value: any

    Returns void

  • Adds a value to the document.

    Parameters

    • path: Iterable<unknown>
    • value: unknown

    Returns void

  • Create a deep copy of this Document and its contents.

    Custom Node values that inherit from Object still refer to their original instances.

    Returns yaml.Document<T>

  • Create a new Alias node, ensuring that the target node has the required anchor.

    If node already has an anchor, name is ignored. Otherwise, the node.anchor value will be set to name, or if an anchor with that name is already present in the document, name will be used as a prefix for a new unique anchor. If name is undefined, the generated anchor will use 'a' as a prefix.

    Parameters

    Returns Alias

  • Convert any value into a Node using the current schema, recursively turning objects into collections.

    Type Parameters

    • T = unknown

    Parameters

    Returns NodeType<T>

  • Type Parameters

    • T = unknown

    Parameters

    Returns NodeType<T>

  • Convert a key and a value into a Pair using the current schema, recursively wrapping all values as Scalar or Collection nodes.

    Type Parameters

    Parameters

    Returns Pair<K, V>

  • Removes a value from the document.

    Parameters

    • key: unknown

    Returns boolean

    true if the item was found and removed.

  • Removes a value from the document.

    Parameters

    • path: null | Iterable<unknown>

    Returns boolean

    true if the item was found and removed.

  • Returns item at key, or undefined if not found. By default unwraps scalar values from their surrounding node; to disable set keepScalar to true (collections are always returned intact).

    Parameters

    • key: unknown
    • OptionalkeepScalar: boolean

    Returns unknown

  • Returns item at path, or undefined if not found. By default unwraps scalar values from their surrounding node; to disable set keepScalar to true (collections are always returned intact).

    Parameters

    • path: null | Iterable<unknown>
    • OptionalkeepScalar: boolean

    Returns unknown

  • Checks if the document includes a value with the key key.

    Parameters

    • key: unknown

    Returns boolean

  • Checks if the document includes a value at path.

    Parameters

    • path: null | Iterable<unknown>

    Returns boolean

  • Sets a value in this document. For !!set, value needs to be a boolean to add/remove the item from the set.

    Parameters

    • key: any
    • value: unknown

    Returns void

  • Sets a value in this document. For !!set, value needs to be a boolean to add/remove the item from the set.

    Parameters

    • path: null | Iterable<unknown>
    • value: unknown

    Returns void

  • Change the YAML version and schema used by the document. A null version disables support for directives, explicit tags, anchors, and aliases. It also requires the schema option to be given as a Schema instance value.

    Overrides all previously set schema options.

    Parameters

    • version:
          | null
          | "next"
          | "1.2"
          | "1.1"
    • Optionaloptions: SchemaOptions

    Returns void

  • A plain JavaScript representation of the document contents.

    Parameters

    • Optionalopt: ToJSOptions & {
          [ignored: string]: unknown;
      }

    Returns any

  • A JSON representation of the document contents.

    Parameters

    • OptionaljsonArg: null | string

      Used by JSON.stringify to indicate the array index or property name.

    • OptionalonAnchor: ((value: unknown, count: number) => void)
        • (value, count): void
        • Parameters

          • value: unknown
          • count: number

          Returns void

    Returns any

  • A YAML representation of the document.

    Parameters

    Returns string