Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

CreateNodeOptions

CreateNodeOptions: { aliasDuplicateObjects?: boolean; anchorPrefix?: string; flow?: boolean; keepUndefined?: boolean | null; tag?: string; onTagObj?: any }

Type declaration

  • Optional aliasDuplicateObjects?: boolean

    During node construction, use anchors and aliases to keep strictly equal non-null objects as equivalent in YAML.

    Default: true

  • Optional anchorPrefix?: string

    Default prefix for anchors.

    Default: 'a', resulting in anchors a1, a2, etc.

  • Optional flow?: boolean

    Force the top-level collection node to use flow style.

  • Optional keepUndefined?: boolean | null

    Keep undefined object values when creating mappings, rather than discarding them.

    Default: false

  • Optional tag?: string

    Specify the top-level collection type, e.g. "!!omap". Note that this requires the corresponding tag to be available in this document's schema.

  • onTagObj?:function

DocumentOptions

DocumentOptions: { _directives?: Directives; logLevel?: LogLevelId; version?: "1.1" | "1.2" | "next" }

Type declaration

  • Optional _directives?: Directives
    internal

    Used internally by Composer. If set and includes an explicit version, that overrides the version option.

  • Optional logLevel?: LogLevelId

    Control the logging level during parsing

    Default: 'warn'

  • Optional version?: "1.1" | "1.2" | "next"

    The YAML version used by documents without a %YAML directive.

    Default: "1.2"

ErrorCode

ErrorCode: "ALIAS_PROPS" | "BAD_ALIAS" | "BAD_DIRECTIVE" | "BAD_DQ_ESCAPE" | "BAD_INDENT" | "BAD_PROP_ORDER" | "BAD_SCALAR_START" | "BLOCK_AS_IMPLICIT_KEY" | "BLOCK_IN_FLOW" | "DUPLICATE_KEY" | "IMPOSSIBLE" | "KEY_OVER_1024_CHARS" | "MISSING_CHAR" | "MULTILINE_IMPLICIT_KEY" | "MULTIPLE_ANCHORS" | "MULTIPLE_DOCS" | "MULTIPLE_TAGS" | "TAB_AS_INDENT" | "TAG_RESOLVE_FAILED" | "UNEXPECTED_TOKEN"

Node

Node<T>: Alias | Scalar<T> | YAMLMap<unknown, T> | YAMLSeq<T>

Type parameters

  • T = unknown

ParseOptions

ParseOptions: { intAsBigInt?: boolean; keepSourceTokens?: boolean; lineCounter?: LineCounter; prettyErrors?: boolean; strict?: boolean; uniqueKeys?: boolean | ((a: ParsedNode, b: ParsedNode) => boolean) }

Type declaration

  • Optional intAsBigInt?: boolean

    Whether integers should be parsed into BigInt rather than number values.

  • Optional keepSourceTokens?: boolean

    Include a srcToken value on each parsed Node, containing the CST token that was composed into this node.

    Default: false

  • Optional lineCounter?: LineCounter

    If set, newlines will be tracked, to allow for lineCounter.linePos(offset) to provide the { line, col } positions within the input.

  • Optional prettyErrors?: boolean

    Include line/col position & node type directly in parse errors.

    Default: true

  • Optional strict?: boolean

    Detect and report errors that are required by the YAML 1.2 spec, but are caused by unambiguous content.

    Default: true

  • Optional uniqueKeys?: boolean | ((a: ParsedNode, b: ParsedNode) => boolean)

    YAML requires map keys to be unique. By default, this is checked by comparing scalar values with ===; deep equality is not checked for aliases or collections. If merge keys are enabled by the schema, multiple << keys are allowed.

    Set false to disable, or provide your own comparator function to customise. The comparator will be passed two ParsedNode values, and is expected to return a boolean indicating their equality.

    Default: true

ParsedNode

Range

Range: [number, number, number]

SchemaOptions

SchemaOptions: { compat?: string | Tags | null; customTags?: Tags | ((tags: Tags) => Tags) | null; merge?: boolean; resolveKnownTags?: boolean; schema?: string | yaml.Schema; sortMapEntries?: boolean | ((a: Pair, b: Pair) => number); toStringDefaults?: ToStringOptions }

Type declaration

  • Optional compat?: string | Tags | null

    When parsing, warn about compatibility issues with the given schema. When stringifying, use scalar styles that are parsed correctly by the compat schema as well as the actual schema.

    Default: null

  • Optional customTags?: Tags | ((tags: Tags) => Tags) | null

    Array of additional tags to include in the schema, or a function that may modify the schema's base tag array.

  • Optional merge?: boolean

    Enable support for << merge keys.

    Default: false for YAML 1.2, true for earlier versions

  • Optional resolveKnownTags?: boolean

    When using the 'core' schema, support parsing values with these explicit YAML 1.1 tags:

    !!binary, !!omap, !!pairs, !!set, !!timestamp.

    Default true

  • Optional schema?: string | yaml.Schema

    The base schema to use.

    The core library has built-in support for the following:

    • 'failsafe': A minimal schema that parses all scalars as strings
    • 'core': The YAML 1.2 core schema
    • 'json': The YAML 1.2 JSON schema, with minimal rules for JSON compatibility
    • 'yaml-1.1': The YAML 1.1 schema

    If using another (custom) schema, the customTags array needs to fully define the schema's tags.

    Default: 'core' for YAML 1.2, 'yaml-1.1' for earlier versions

  • Optional sortMapEntries?: boolean | ((a: Pair, b: Pair) => number)

    When adding to or stringifying a map, sort the entries. If true, sort by comparing key values with <. Does not affect item order when parsing.

    Default: false

  • Optional toStringDefaults?: ToStringOptions

    Override default values for toString() options.

TagId

TagId: keyof typeof tagsByName

Tags

ToJSOptions

ToJSOptions: { mapAsMap?: boolean; maxAliasCount?: number; reviver?: Reviver; onAnchor?: any }

Type declaration

  • Optional mapAsMap?: boolean

    Use Map rather than Object to represent mappings.

    Default: false

  • Optional maxAliasCount?: number

    Prevent exponential entity expansion attacks by limiting data aliasing count; set to -1 to disable checks; 0 disallows all alias nodes.

    Default: 100

  • Optional reviver?: Reviver
  • onAnchor?:function
    • onAnchor(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

ToStringOptions

ToStringOptions: { blockQuote?: boolean | "folded" | "literal"; collectionStyle?: "any" | "block" | "flow"; defaultKeyType?: Type | null; defaultStringType?: Type; directives?: boolean | null; doubleQuotedAsJSON?: boolean; doubleQuotedMinMultiLineLength?: number; falseStr?: string; flowCollectionPadding?: boolean; indent?: number; indentSeq?: boolean; lineWidth?: number; minContentWidth?: number; nullStr?: string; simpleKeys?: boolean; singleQuote?: boolean | null; trueStr?: string; verifyAliasOrder?: boolean; commentString?: any }

Type declaration

  • Optional blockQuote?: boolean | "folded" | "literal"

    Use block quote styles for scalar values where applicable. Set to false to disable block quotes completely.

    Default: true

  • Optional collectionStyle?: "any" | "block" | "flow"

    Enforce 'block' or 'flow' style on maps and sequences. Empty collections will always be stringified as {} or [].

    Default: 'any', allowing each node to set its style separately with its flow: boolean (default false) property.

  • Optional defaultKeyType?: Type | null

    The default type of string literal used to stringify implicit key values. Output may use other types if required to fully represent the value.

    If null, the value of defaultStringType is used.

    Default: null

  • Optional defaultStringType?: Type

    The default type of string literal used to stringify values in general. Output may use other types if required to fully represent the value.

    Default: 'PLAIN'

  • Optional directives?: boolean | null

    Include directives in the output.

    • If true, at least the document-start marker --- is always included. This does not force the %YAML directive to be included. To do that, set doc.directives.yaml.explicit = true.
    • If false, no directives or marker is ever included. If using the %TAG directive, you are expected to include it manually in the stream before its use.
    • If null, directives and marker may be included if required.

    Default: null

  • Optional doubleQuotedAsJSON?: boolean

    Restrict double-quoted strings to use JSON-compatible syntax.

    Default: false

  • Optional doubleQuotedMinMultiLineLength?: number

    Minimum length for double-quoted strings to use multiple lines to represent the value. Ignored if doubleQuotedAsJSON is set.

    Default: 40

  • Optional falseStr?: string

    String representation for false. With the core schema, use 'false', 'False', or 'FALSE'.

    Default: 'false'

  • Optional flowCollectionPadding?: boolean

    When true, a single space of padding will be added inside the delimiters of non-empty single-line flow collections.

    Default: true

  • Optional indent?: number

    The number of spaces to use when indenting code.

    Default: 2

  • Optional indentSeq?: boolean

    Whether block sequences should be indented.

    Default: true

  • Optional lineWidth?: number

    Maximum line width (set to 0 to disable folding).

    This is a soft limit, as only double-quoted semantics allow for inserting a line break in the middle of a word, as well as being influenced by the minContentWidth option.

    Default: 80

  • Optional minContentWidth?: number

    Minimum line width for highly-indented content (set to 0 to disable).

    Default: 20

  • Optional nullStr?: string

    String representation for null. With the core schema, use 'null', 'Null', 'NULL', '~', or an empty string ''.

    Default: 'null'

  • Optional simpleKeys?: boolean

    Require keys to be scalars and to use implicit rather than explicit notation.

    Default: false

  • Optional singleQuote?: boolean | null

    Use 'single quote' rather than "double quote" where applicable. Set to false to disable single quotes completely.

    Default: null

  • Optional trueStr?: string

    String representation for true. With the core schema, use 'true', 'True', or 'TRUE'.

    Default: 'true'

  • Optional verifyAliasOrder?: boolean

    The anchor used by an alias must be defined before the alias node. As it's possible for the document to be modified manually, the order may be verified during stringification.

    Default: 'true'

  • commentString?:function
    • commentString(comment: string): string
    • Comment stringifier. Output should be valid for the current schema.

      By default, empty comment lines are left empty, lines consisting of a single space are replaced by #, and all other lines are prefixed with a #.

      Parameters

      • comment: string

      Returns string

asyncVisitor

asyncVisitorFn

asyncVisitorFn<T>: (key: number | "key" | "value" | null, node: T, path: readonly (yaml.Document | yaml.Node | Pair)[]) => void | symbol | number | yaml.Node | Pair | Promise<void | symbol | number | yaml.Node | Pair>

Type parameters

  • T

Type declaration

visitor

visitor: visitorFn<unknown> | { Alias?: visitorFn<Alias>; Collection?: visitorFn<YAMLMap | YAMLSeq>; Map?: visitorFn<YAMLMap>; Node?: visitorFn<Alias | Scalar | YAMLMap | YAMLSeq>; Pair?: visitorFn<Pair>; Scalar?: visitorFn<Scalar>; Seq?: visitorFn<YAMLSeq>; Value?: visitorFn<Scalar | YAMLMap | YAMLSeq> }

visitorFn

visitorFn<T>: (key: number | "key" | "value" | null, node: T, path: readonly (yaml.Document | yaml.Node | Pair)[]) => void | symbol | number | yaml.Node | Pair

Type parameters

  • T

Type declaration

Functions

Const isAlias

  • isAlias(node: any): node is Alias
  • Parameters

    • node: any

    Returns node is Alias

isCollection

  • Type parameters

    • K = unknown

    • V = unknown

    Parameters

    • node: any

    Returns node is YAMLMap<K, V> | YAMLSeq<V>

Const isDocument

  • Type parameters

    Parameters

    • node: any

    Returns node is yaml.Document<T>

Const isMap

  • isMap<K, V>(node: any): node is YAMLMap<K, V>
  • Type parameters

    • K = unknown

    • V = unknown

    Parameters

    • node: any

    Returns node is YAMLMap<K, V>

isNode

  • isNode<T>(node: any): node is yaml.Node<T>
  • Type parameters

    • T = unknown

    Parameters

    • node: any

    Returns node is yaml.Node<T>

Const isPair

  • isPair<K, V>(node: any): node is Pair<K, V>
  • Type parameters

    • K = unknown

    • V = unknown

    Parameters

    • node: any

    Returns node is Pair<K, V>

Const isScalar

  • isScalar<T>(node: any): node is Scalar<T>
  • Type parameters

    • T = unknown

    Parameters

    • node: any

    Returns node is Scalar<T>

Const isSeq

  • isSeq<T>(node: any): node is YAMLSeq<T>
  • Type parameters

    • T = unknown

    Parameters

    • node: any

    Returns node is YAMLSeq<T>

parse

  • Parse an input string into JavaScript.

    Only supports input consisting of a single YAML document; for multi-document support you should use YAML.parseAllDocuments. May throw on error, and may log warnings using console.warn.

    Parameters

    Returns any

    The value will match the type of the root value of the parsed YAML document, so Maps become objects, Sequences arrays, and scalars result in nulls, booleans, numbers and strings.

  • Parameters

    Returns any

parseAllDocuments

  • Parse the input as a stream of YAML documents.

    Documents should be separated from each other by ... or --- marker lines.

    Type parameters

    Parameters

    Returns yaml.Document.Parsed<T>[] | EmptyStream

    If an empty docs array is returned, it will be of type EmptyStream and contain additional stream information. In TypeScript, you should use 'empty' in docs as a type guard for it.

parseDocument

stringify

visit

  • Apply a visitor to an AST node or document.

    Walks through the tree (depth-first) starting from node, calling a visitor function with three arguments:

    • key: For sequence values and map Pair, the node's index in the collection. Within a Pair, 'key' or 'value', correspondingly. null for the root node.
    • node: The current node.
    • path: The ancestry of the current node.

    The return value of the visitor may be used to control the traversal:

    • undefined (default): Do nothing and continue
    • visit.SKIP: Do not visit the children of this node, continue with next sibling
    • visit.BREAK: Terminate traversal completely
    • visit.REMOVE: Remove the current node, then continue with the next one
    • Node: Replace the current node, then continue by visiting it
    • number: While iterating the items of a sequence or map, set the index of the next step. This is useful especially if the index of the current node has changed.

    If visitor is a single function, it will be called with all values encountered in the tree, including e.g. null values. Alternatively, separate visitor functions may be defined for each Map, Pair, Seq, Alias and Scalar node. To define the same visitor function for more than one node type, use the Collection (map and seq), Value (map, seq & scalar) and Node (alias, map, seq & scalar) targets. Of all these, only the most specific defined one will be used for each node.

    Parameters

    Returns void

visitAsync

  • Apply an async visitor to an AST node or document.

    Walks through the tree (depth-first) starting from node, calling a visitor function with three arguments:

    • key: For sequence values and map Pair, the node's index in the collection. Within a Pair, 'key' or 'value', correspondingly. null for the root node.
    • node: The current node.
    • path: The ancestry of the current node.

    The return value of the visitor may be used to control the traversal:

    • Promise: Must resolve to one of the following values
    • undefined (default): Do nothing and continue
    • visit.SKIP: Do not visit the children of this node, continue with next sibling
    • visit.BREAK: Terminate traversal completely
    • visit.REMOVE: Remove the current node, then continue with the next one
    • Node: Replace the current node, then continue by visiting it
    • number: While iterating the items of a sequence or map, set the index of the next step. This is useful especially if the index of the current node has changed.

    If visitor is a single function, it will be called with all values encountered in the tree, including e.g. null values. Alternatively, separate visitor functions may be defined for each Map, Pair, Seq, Alias and Scalar node. To define the same visitor function for more than one node type, use the Collection (map and seq), Value (map, seq & scalar) and Node (alias, map, seq & scalar) targets. Of all these, only the most specific defined one will be used for each node.

    Parameters

    Returns Promise<void>

Generated using TypeDoc