UNPKG

1.42 kBMarkdownView Raw
1# read-yaml [![NPM version](https://badge.fury.io/js/read-yaml.svg)](http://badge.fury.io/js/read-yaml)
2
3> Very thin wrapper around js-yaml for directly reading in YAML files.
4
5## Install with [npm](npmjs.org)
6
7```bash
8npm i read-yaml --save
9```
10
11## API
12### [readYaml](index.js#L39)
13
14Read YAML file asynchronously and parse content as JSON
15
16* `fp` **{String}**: Path of the file to read.
17* `options` **{Object|String}**: to pass to [js-yaml]
18* `cb` **{Function}**: Callback function
19* `returns` **{Object}**: JSON
20
21**Example:**
22
23```js
24var readYaml = require('read-yaml');
25readYaml('config.yml', function(err, data) {
26 if (err) throw err;
27 console.log(data);
28});
29```
30
31### [.sync](index.js#L81)
32
33Read YAML file synchronously and parse content as JSON
34
35* `fp` **{String}**: Path of the file to read.
36* `options` **{Object|String}**: to pass to [js-yaml]
37* `returns` **{Object}**: JSON
38
39**Example:**
40
41```js
42var read = require('read-yaml');
43var config = read.sync('config.yml');
44```
45
46
47## Author
48
49**Jon Schlinkert**
50
51+ [github/jonschlinkert](https://github.com/jonschlinkert)
52+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
53
54## License
55Copyright (c) 2014 Jon Schlinkert
56Released under the MIT license
57
58***
59
60_This file was generated by [verb](https://github.com/assemble/verb) on December 05, 2014. To update, run `npm i -g verb && verb`._
61
62[js-yaml]: https://github.com/nodeca/js-yaml
\No newline at end of file