UNPKG

1.12 kBMarkdownView Raw
1# Node YAML
2
3A wrapper for js-yaml parser
4
5## Installation
6
7You can install this module using NPM:
8
9```bash
10 npm install --save node-yaml
11```
12
13## API
14
15### yaml.read(file[, options], callback)
16
17Read and parse YAML file.
18
19* string file Path to file
20* null|string|object Options:
21 * encoding String | Null default = null
22 * schema More information about this options [here](https://github.com/nodeca/js-yaml#safeload-string---options-).
23
24```coffee
25 yaml = require 'node-yaml'
26
27 yaml.read 'path/to/file.yaml', (err, data) ->
28 if err
29 throw err
30 console.log data
31```
32
33**Note:** You also can use path without file extension (only for yaml.read and yaml.readSync).
34
35### yaml.readSync(file[, options])
36
37Synchronous version of **yaml.read**. Returns the contents of the **file**
38
39### yaml.write(file, data[, options], callback)
40
41Parse and write YAML to file.
42
43```coffee
44 yaml = require 'node-yaml'
45
46 data =
47 foo: foo
48 bar: bar
49
50 yaml.write 'path/to/file.yaml', data, (err) -> throw err if err
51```
52
53### yaml.writeSync(file, data[, options])
54
55Synchronous version of **yaml.write**. Returns null if file has successfully written.
\No newline at end of file