Compose a stream of CST nodes into a stream of YAML Documents.

import { Composer, Parser } from 'yaml'

const src: string = ...
const tokens = new Parser().parse(src)
const docs = new Composer().compose(tokens)

Constructors

Methods

Constructors

Methods

  • Compose tokens into documents.

    Parameters

    • tokens: Iterable<yaml.CST.Token>
    • OptionalforceDoc: boolean

      If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.

    • OptionalendOffset: number

      Should be set if forceDoc is also set, to set the document range end and to indicate errors correctly.

    Returns Generator<yaml.Document.Parsed<ParsedNode>, void, unknown>

  • Call at end of input to yield any remaining document.

    Parameters

    • OptionalforceDoc: boolean

      If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.

    • OptionalendOffset: number

      Should be set if forceDoc is also set, to set the document range end and to indicate errors correctly.

    Returns Generator<yaml.Document.Parsed<ParsedNode>, void, unknown>

  • Current stream status information.

    Mostly useful at the end of input for an empty stream.

    Returns {
        comment: string;
        directives: Directives;
        errors: YAMLParseError[];
        warnings: YAMLWarning[];
    }