source: trip-planner-front/node_modules/yaml/README.md@ b738035

Last change on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.4 KB
Line 
1# YAML <a href="https://www.npmjs.com/package/yaml"><img align="right" src="https://badge.fury.io/js/yaml.svg" title="npm package" /></a>
2
3`yaml` is a JavaScript parser and stringifier for [YAML](http://yaml.org/), a human friendly data serialization standard. It supports both parsing and stringifying data using all versions of YAML, along with all common data schemas. As a particularly distinguishing feature, `yaml` fully supports reading and writing comments and blank lines in YAML documents.
4
5The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards.
6
7For 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).
8
9For more information, see the project's documentation site: [**eemeli.org/yaml/v1**](https://eemeli.org/yaml/v1/)
10
11To install:
12
13```sh
14npm install yaml
15```
16
17**Note:** This is `yaml@1`. You may also be interested in the next version, currently available as [`yaml@next`](https://www.npmjs.com/package/yaml/v/next).
18
19## API Overview
20
21The API provided by `yaml` has three layers, depending on how deep you need to go: [Parse & Stringify](https://eemeli.org/yaml/v1/#parse-amp-stringify), [Documents](https://eemeli.org/yaml/#documents), and the [CST Parser](https://eemeli.org/yaml/#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](https://eemeli.org/yaml/#content-nodes), and the third is the closest to YAML source, making it fast, raw, and crude.
22
23```js
24import YAML from 'yaml'
25// or
26const YAML = require('yaml')
27```
28
29### Parse & Stringify
30
31- [`YAML.parse(str, options): value`](https://eemeli.org/yaml/v1/#yaml-parse)
32- [`YAML.stringify(value, options): string`](https://eemeli.org/yaml/v1/#yaml-stringify)
33
34### YAML Documents
35
36- [`YAML.createNode(value, wrapScalars, tag): Node`](https://eemeli.org/yaml/v1/#creating-nodes)
37- [`YAML.defaultOptions`](https://eemeli.org/yaml/v1/#options)
38- [`YAML.Document`](https://eemeli.org/yaml/v1/#yaml-documents)
39 - [`constructor(options)`](https://eemeli.org/yaml/v1/#creating-documents)
40 - [`defaults`](https://eemeli.org/yaml/v1/#options)
41 - [`#anchors`](https://eemeli.org/yaml/v1/#working-with-anchors)
42 - [`#contents`](https://eemeli.org/yaml/v1/#content-nodes)
43 - [`#errors`](https://eemeli.org/yaml/v1/#errors)
44- [`YAML.parseAllDocuments(str, options): YAML.Document[]`](https://eemeli.org/yaml/v1/#parsing-documents)
45- [`YAML.parseDocument(str, options): YAML.Document`](https://eemeli.org/yaml/v1/#parsing-documents)
46
47```js
48import { Pair, YAMLMap, YAMLSeq } from 'yaml/types'
49```
50
51- [`new Pair(key, value)`](https://eemeli.org/yaml/v1/#creating-nodes)
52- [`new YAMLMap()`](https://eemeli.org/yaml/v1/#creating-nodes)
53- [`new YAMLSeq()`](https://eemeli.org/yaml/v1/#creating-nodes)
54
55### CST Parser
56
57```js
58import parseCST from 'yaml/parse-cst'
59```
60
61- [`parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst)
62- [`YAML.parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst)
63
64## YAML.parse
65
66```yaml
67# file.yml
68YAML:
69 - A human-readable data serialization language
70 - https://en.wikipedia.org/wiki/YAML
71yaml:
72 - A complete JavaScript implementation
73 - https://www.npmjs.com/package/yaml
74```
75
76```js
77import fs from 'fs'
78import YAML from 'yaml'
79
80YAML.parse('3.14159')
81// 3.14159
82
83YAML.parse('[ true, false, maybe, null ]\n')
84// [ true, false, 'maybe', null ]
85
86const file = fs.readFileSync('./file.yml', 'utf8')
87YAML.parse(file)
88// { YAML:
89// [ 'A human-readable data serialization language',
90// 'https://en.wikipedia.org/wiki/YAML' ],
91// yaml:
92// [ 'A complete JavaScript implementation',
93// 'https://www.npmjs.com/package/yaml' ] }
94```
95
96## YAML.stringify
97
98```js
99import YAML from 'yaml'
100
101YAML.stringify(3.14159)
102// '3.14159\n'
103
104YAML.stringify([true, false, 'maybe', null])
105// `- true
106// - false
107// - maybe
108// - null
109// `
110
111YAML.stringify({ number: 3, plain: 'string', block: 'two\nlines\n' })
112// `number: 3
113// plain: string
114// block: >
115// two
116//
117// lines
118// `
119```
120
121---
122
123Browser testing provided by:
124
125<a href="https://www.browserstack.com/open-source">
126<img width=200 src="https://eemeli.org/yaml/images/browserstack.svg" />
127</a>
Note: See TracBrowser for help on using the repository browser.