Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

Readonly [NODE_TYPE]

[NODE_TYPE]: symbol

comment

comment: null | string

A comment immediately after this Document

commentBefore

commentBefore: null | string

A comment before this Document

contents

contents: null | T

The document contents.

Optional directives

directives?: Directives

errors

errors: YAMLError[]

Errors encountered during parsing.

options

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

Optional range

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

schema: yaml.Schema

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

warnings

warnings: YAMLWarning[]

Warnings encountered during parsing.

Methods

add

  • add(value: any): void
  • Adds a value to the document.

    Parameters

    • value: any

    Returns void

addIn

  • addIn(path: Iterable<unknown>, value: unknown): void
  • Adds a value to the document.

    Parameters

    • path: Iterable<unknown>
    • value: unknown

    Returns void

clone

  • 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>

createAlias

  • 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

createNode

  • 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>

createPair

  • 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>

delete

  • delete(key: unknown): boolean
  • Removes a value from the document.

    Parameters

    • key: unknown

    Returns boolean

    true if the item was found and removed.

deleteIn

  • deleteIn(path: null | Iterable<unknown>): boolean
  • Removes a value from the document.

    Parameters

    • path: null | Iterable<unknown>

    Returns boolean

    true if the item was found and removed.

get

  • get(key: unknown, keepScalar?: boolean): unknown
  • 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
    • Optional keepScalar: boolean

    Returns unknown

getIn

  • getIn(path: null | Iterable<unknown>, keepScalar?: boolean): 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>
    • Optional keepScalar: boolean

    Returns unknown

has

  • has(key: unknown): boolean
  • Checks if the document includes a value with the key key.

    Parameters

    • key: unknown

    Returns boolean

hasIn

  • hasIn(path: null | Iterable<unknown>): boolean
  • Checks if the document includes a value at path.

    Parameters

    • path: null | Iterable<unknown>

    Returns boolean

set

  • set(key: any, value: unknown): void
  • 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

setIn

  • setIn(path: null | Iterable<unknown>, value: unknown): 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

setSchema

  • setSchema(version: null | "next" | "1.1" | "1.2", options?: SchemaOptions): 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.1" | "1.2"
    • Optional options: SchemaOptions

    Returns void

toJS

  • A plain JavaScript representation of the document contents.

    Parameters

    Returns any

toJSON

  • toJSON(jsonArg?: null | string, onAnchor?: (value: unknown, count: number) => void): any
  • A JSON representation of the document contents.

    Parameters

    • Optional jsonArg: null | string

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

    • Optional onAnchor: (value: unknown, count: number) => void
        • (value: unknown, count: number): void
        • If defined, called with the resolved value and reference count for each anchor in the document.

          Parameters

          • value: unknown
          • count: number

          Returns void

    Returns any

toString

  • A YAML representation of the document.

    Parameters

    Returns string

Generated using TypeDoc