parse
parse(
text):unknown
Defined in: src/index.ts:515
Parse a single YAML document into a JavaScript value.
Reads exactly one document — like JSON.parse and js-yaml’s load. If
text contains more than one ----separated document (or any trailing
content after the first), parse throws rather than silently returning the
first; use parseAll for multi-document streams. Plain scalars are
typed per the YAML 1.2 core schema (1 is a number, true a boolean,
null/~/empty a null); an empty document is null.
Parameters
Section titled “Parameters”string
The YAML source text.
Returns
Section titled “Returns”unknown
The document’s value: an object, array, string, number, boolean,
or null.
Throws
Section titled “Throws”YAMLParseError if text is not well-formed YAML, or contains
more than one document.
Example
Section titled “Example”parse("dish: pancakes\nserves: 4")// { dish: "pancakes", serves: 4 }