function

YAML.parse

function parse(
input: string
): unknown;

Parse a YAML string into a JavaScript value. Every alias (*name) of an anchored collection yields the same object, and an alias may refer to a collection that contains it, so the result can be cyclic.

@param input

The YAML string to parse

@returns

A JavaScript value, or an array of them for a multi-document stream

import { YAML } from "bun";

console.log(YAML.parse("123")) // 123
console.log(YAML.parse("null")) // null
console.log(YAML.parse("false")) // false
console.log(YAML.parse("abc")) // "abc"
console.log(YAML.parse("- abc")) // [ "abc" ]
console.log(YAML.parse("abc: def")) // { "abc": "def" }