js-yaml - v5.4.1
    Preparing search index...

    Interface DumpOptions

    interface DumpOptions {
        indent?: number;
        seqNoIndent?: boolean;
        seqInlineFirst?: boolean;
        lineWidth?: number;
        flowBracketPadding?: boolean;
        flowSkipCommaSpace?: boolean;
        flowSkipColonSpace?: boolean;
        quoteFlowKeys?: boolean;
        quoteStyle?: "single" | "double";
        forceQuotes?: boolean;
        scalarStyleRules?: readonly ScalarStyleRule[];
        tagBeforeAnchor?: boolean;
        schema?: Schema;
        skipInvalid?: boolean;
        noRefs?: boolean;
        flowLevel?: number;
        sortKeys?: boolean | ((a: any, b: any) => number);
        transform?: (documents: Document[]) => void;
    }

    Hierarchy

    Index

    Indentation width in spaces.

    2

    Does not add an indentation level to array elements when enabled.

    false

    Allows a nested collection to start on the same line after -.

    true

    Preferred line width for folding. Unbreakable and more-indented lines may exceed it. Set to -1 for unlimited width.

    80

    Adds spaces inside flow collection brackets: {a: 1} becomes { a: 1 }.

    false

    Omits the space after commas in flow collections: [1, 2] becomes [1,2].

    false

    Omits the space after : in flow mappings: {"a": 1} becomes {"a":1}.

    This forces quoteFlowKeys; otherwise a:1 would be parsed as a single plain scalar instead of a mapping entry.

    false

    Quotes flow mapping keys: {a: 1} becomes {"a": 1}.

    false

    Quoting style to use when a string needs quotes.

    'single'

    Quotes all non-key strings using quoteStyle.

    false

    Customizes how strings are rendered as plain, quoted, literal, or folded scalars. Rules are applied in array order; providing this option replaces the default rules.

    Object.values(DEFAULT_SCALAR_STYLE_RULES)

    Prints an explicit tag before an anchor: &ref_0 !!set becomes !!set &ref_0.

    false

    Schema to use.

    DUMP_SCHEMA

    Skips invalid types instead of throwing. Invalid mapping pairs and sequence items are skipped; undefined sequence items are serialized as null.

    false

    Inlines duplicate objects instead of converting them into references.

    false

    Nesting level at which collections switch from block to flow style. Set to -1 to never switch automatically.

    -1

    Sorts mapping keys when true. A function can be provided to define the sort order.

    false

    Use transform to reorder mapping items.

    Mutates the generated AST before it is rendered.

    import { dump, visit } from 'js-yaml'

    dump(value, {
    transform: documents => visit(documents, node => {
    if (node.kind === 'mapping') node.items.sort((a, b) => {
    const x = a.key.kind === 'scalar' ? a.key.value : ''
    const y = b.key.kind === 'scalar' ? b.key.value : ''
    return x.localeCompare(y)
    })
    })
    })