yaml fully supports reading and writing comments and blank lines in YAML documents.
The library is released under the ISC open source license, and the code is available on GitHub. It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards.
For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed).
For more information, see the project's documentation site: eemeli.org/yaml
npm install yaml
yaml 0.x and 1.x are rather different implementations. For the earlier
yaml, see tj/js-yaml.
The API provided by
yaml has three layers, depending on how deep you need to go: Parse & Stringify, Documents, and the CST Parser. The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent AST, and the third is the closest to YAML source, making it fast, raw, and crude.
// orconst YAML =
Parse & Stringify
YAML.createNode(value, wrapScalars, tag): Node
YAML.parseAllDocuments(str, options): YAML.Document
YAML.parseDocument(str, options): YAML.Document
YAML// '3.14159\n'YAML// `- true// - false// - maybe// - null// `YAML// `number: 3// plain: string// block: >// two//// lines// `
Browser testing provided by: