{"name":"read-data","description":"Utils for reading JSON and YAML data files.","version":"0.2.0","homepage":"https://github.com/jonschlinkert/read-data","author":{"name":"Jon Schlinkert","url":"https://github.com/jonschlinkert"},"repository":{"type":"git","url":"git://github.com/jonschlinkert/read-data.git"},"bugs":{"url":"https://github.com/jonschlinkert/read-data/issues"},"licenses":[{"type":"MIT","url":"https://github.com/jonschlinkert/read-data/blob/master/LICENSE-MIT"}],"main":"index.js","engines":{"node":">=0.8"},"scripts":{"test":"mocha -R test"},"devDependencies":{"should":"^4.1.0","verb":"^0.2.15","verb-tag-jscomments":"^0.2.2"},"dependencies":{"async":"^0.9.0","graceful-fs":"^3.0.4","js-yaml":"^3.2.2"},"keywords":["data","file","filepath","fs","json","parse","read","system","yaml"],"_id":"read-data@0.2.0","_shasum":"90a63688eaf488392f5b2968f6e8e108b8324114","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dist":{"shasum":"90a63688eaf488392f5b2968f6e8e108b8324114","tarball":"http://registry-npm.ywwl.com/read-data/download/read-data-0.2.0.tgz","integrity":"sha512-7zyZYfXw1ZJc2+DFrfi82+97iwNLtqX77OjxvsoFp0oQRwnR4bfAyTElSy2sj+iYG2g0moE51dU0GxanIdhStQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEOo4JnGBhmSG2ada3Z2m4p4K0oVnwXXcYq9tkGU3DaJAiAKM/rYcJ8/aqJWntGLsKBmjIFtfYCvFaDKNU5Nzz2xdQ=="}],"size":3715,"noattachment":false,"key":"/read-data/-/read-data-0.2.0.tgz"},"directories":{},"readme":"# read-data [![NPM version](https://img.shields.io/npm/v/read-data.svg?style=flat)](https://www.npmjs.com/package/read-data) [![NPM monthly downloads](https://img.shields.io/npm/dm/read-data.svg?style=flat)](https://npmjs.org/package/read-data)  [![NPM total downloads](https://img.shields.io/npm/dt/read-data.svg?style=flat)](https://npmjs.org/package/read-data) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/read-data.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/read-data)\n\n> Read JSON or YAML files.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save read-data\n```\n\n**Heads up!**\n\nPlease read the [release history](#history), there were breaking changes in 1.0.0!\n\n## Usage\n\n```js\nvar read = require('read-data');\n\n// sync\nconsole.log(read.sync('foo.yml'));\nconsole.log(read.sync('foo.yaml'));\nconsole.log(read.sync('foo.json'));\n\n// async\nread('foo.yml', function(err, data) {\n  if (err) return console.log(err);\n  console.log(data);\n});\nread('foo.yaml', function(err, data) {\n  if (err) return console.log(err);\n  console.log(data);\n});\nread('foo.json', function(err, data) {\n  if (err) return console.log(err);\n  console.log(data);\n});\n```\n\n## API\n\n### [read](index.js#L41)\n\nAsynchronously read a JSON or YAML file, automatically determining the reader based on extension.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `options` **{Object|String}**: to pass to [js-yaml](https://github.com/nodeca/js-yaml)\n* `cb` **{Function}**: callback function\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar read = require('read-data');\n\nread('foo.json', function(err, data) {\n  if (err) throw err;\n  console.log(data);\n});\n\nread('foo.yml', function(err, data) {\n  if (err) throw err;\n  console.log(data);\n});\n```\n\n### [.sync](index.js#L70)\n\nSynchronously read a `.json` or `.(yaml|yml)` file, automatically determining the reader based on extension.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `options` **{Object|String}**: to pass to [js-yaml](https://github.com/nodeca/js-yaml)\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar data = require('read-data').data;\n\nvar yaml = data.sync('foo.yml');\nvar json = data.sync('foo.json');\n```\n\n### [.yaml](index.js#L96)\n\nAsynchronously read a YAML file.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `options` **{Object|String}**: to pass to [js-yaml](https://github.com/nodeca/js-yaml)\n* `cb` **{Function}**: callback function\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar yaml = require('read-data').yaml;\n\nyaml('foo.yml', function(err, data) {\n  if (err) throw err;\n  console.log(data);\n});\n```\n\n### [.yaml.sync](index.js#L113)\n\nSynchronously read a YAML file.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `options` **{Object|String}**: to pass to [js-yaml](https://github.com/nodeca/js-yaml)\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar yaml = require('read-data').yaml;\nvar data = yaml.sync('foo.yml');\n```\n\n### [.json](index.js#L134)\n\nAsynchronously read a JSON file.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `callback` **{Function}**: callback function\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar json = require('read-data');\n\njson('foo.json', function(err, data) {\n  if (err) throw err;\n  console.log(data);\n});\n```\n\n### [.json.sync](index.js#L166)\n\nSynchronously read a JSON file.\n\n**Params**\n\n* `filepath` **{String}**: path of the file to read.\n* `returns` **{Object}**: JSON\n\n**Example**\n\n```js\nvar json = require('read-data').json;\nvar data = json.sync('foo.json');\n```\n\n## History\n\n### 1.0.0\n\n**Breaking changes**\n\n* The main export is now a function\n* Use `read()` instead of `read.data()`\n* Use `read.sync()` instead of `read.data.sync()`\n\nEverything else is the same.\n\n## About\n\n### Related projects\n\n* [copy](https://www.npmjs.com/package/copy): Copy files or directories using globs. | [homepage](https://github.com/jonschlinkert/copy \"Copy files or directories using globs.\")\n* [read-yaml](https://www.npmjs.com/package/read-yaml): Very thin wrapper around js-yaml for directly reading in YAML files. | [homepage](https://github.com/jonschlinkert/read-yaml \"Very thin wrapper around js-yaml for directly reading in YAML files.\")\n* [write](https://www.npmjs.com/package/write): Write files to disk, creating intermediate directories if they don't exist. | [homepage](https://github.com/jonschlinkert/write \"Write files to disk, creating intermediate directories if they don't exist.\")\n\n### Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n### Contributors\n\n| **Commits** | **Contributor** | \n| --- | --- |\n| 14 | [jonschlinkert](https://github.com/jonschlinkert) |\n| 1 | [tunnckoCore](https://github.com/tunnckoCore) |\n\n### Building docs\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme && verb\n```\n\n### Running tests\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install && npm test\n```\n\n### Author\n\n**Jon Schlinkert**\n\n* [github/jonschlinkert](https://github.com/jonschlinkert)\n* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2017, [Jon Schlinkert](http://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on April 02, 2017._","publish_time":1414137229431,"_cnpm_publish_time":1414137229431,"dist-tags":{"latest":"1.1.0"}}