Does not add an indentation level to array elements when enabled.
Allows a nested collection to start on the same line after -.
Preferred line width for folding. Unbreakable and more-indented lines may
exceed it. Set to -1 for unlimited width.
Adds spaces inside flow collection brackets: {a: 1} becomes { a: 1 }.
Omits the space after commas in flow collections: [1, 2] becomes
[1,2].
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.
Quotes flow mapping keys: {a: 1} becomes {"a": 1}.
Quoting style to use when a string needs quotes.
Quotes all non-key strings using quoteStyle.
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.
Prints an explicit tag before an anchor: &ref_0 !!set becomes
!!set &ref_0.
Schema to use.
Skips invalid types instead of throwing. Invalid mapping pairs and sequence
items are skipped; undefined sequence items are serialized as null.
Inlines duplicate objects instead of converting them into references.
Nesting level at which collections switch from block to flow style. Set to
-1 to never switch automatically.
Sorts mapping keys when true. A function can be provided to define the
sort order.
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)
})
})
})
Indentation width in spaces.