Comparing version 0.1.0 to 0.2.0
@@ -9,3 +9,3 @@ --- | ||
## Install | ||
{%= include("install") %} | ||
{%= include("install-npm", {save: true}) %} | ||
@@ -12,0 +12,0 @@ ## API |
64
index.js
@@ -12,29 +12,16 @@ /*! | ||
var async = require('async'); | ||
var file = module.exports = {}; | ||
/** | ||
* ## .readYAMLSync( filepath ) | ||
* ## async | ||
* | ||
* Read YAML file synchronously and parse content as JSON | ||
* @param {String} `filepath` | ||
* @return {Object} | ||
*/ | ||
file.readYAMLSync = function (filepath) { | ||
var str = fs.readFileSync(String(filepath), 'utf8'); | ||
try { | ||
return YAML.load(str); | ||
} catch (err) { | ||
err.message = 'Failed to parse "' + filepath + '": ' + err.message; | ||
throw err; | ||
} | ||
}; | ||
/** | ||
* ## .readYAML( filepath ) | ||
* | ||
* Read YAML file asynchronously and parse content as JSON | ||
* | ||
* **Example:** | ||
* | ||
* ```js | ||
* var yaml = require('read-yaml'); | ||
* var config = yaml('config.yml'); | ||
* ``` | ||
* | ||
* @param {String} `filepath` | ||
@@ -44,3 +31,3 @@ * @return {Object} | ||
file.readYAML = function (filepath, callback) { | ||
module.exports = function (filepath, callback) { | ||
async.waterfall([ | ||
@@ -56,4 +43,31 @@ function (next) { fs.readFile(String(filepath), 'utf8', next); }, | ||
} | ||
], | ||
callback); | ||
}; | ||
], callback); | ||
}; | ||
/** | ||
* ## sync | ||
* | ||
* Read YAML file synchronously and parse content as JSON | ||
* | ||
* **Example:** | ||
* | ||
* ```js | ||
* var yaml = require('read-yaml').sync; | ||
* var config = yaml('config.yml'); | ||
* ``` | ||
* | ||
* @param {String} `filepath` | ||
* @return {Object} | ||
*/ | ||
module.exports.sync = function (filepath) { | ||
var str = fs.readFileSync(String(filepath), 'utf8'); | ||
try { | ||
return YAML.load(str); | ||
} catch (err) { | ||
err.message = 'Failed to parse "' + filepath + '": ' + err.message; | ||
throw err; | ||
} | ||
}; | ||
{ | ||
"name": "read-yaml", | ||
"description": "Very thin wrapper around js-yaml for directly reading in YAML files.", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/read-yaml", | ||
@@ -24,9 +24,6 @@ "author": { | ||
"keywords": [ | ||
"docs", | ||
"documentation", | ||
"generate", | ||
"generator", | ||
"markdown", | ||
"templates", | ||
"verb" | ||
"yaml", | ||
"data", | ||
"parse", | ||
"read" | ||
], | ||
@@ -48,5 +45,4 @@ "main": "index.js", | ||
"async": "^0.9.0", | ||
"js-yaml": "^3.0.2", | ||
"read-file": "^0.1.2" | ||
"js-yaml": "^3.0.2" | ||
} | ||
} |
@@ -6,13 +6,20 @@ # read-yaml [![NPM version](https://badge.fury.io/js/read-yaml.png)](http://badge.fury.io/js/read-yaml) | ||
## Install | ||
Install with [npm](npmjs.org): | ||
#### [npm](npmjs.org) | ||
```bash | ||
npm i read-yaml --save-dev | ||
npm i read-yaml --save | ||
``` | ||
## API | ||
### .readYAMLSync ( filepath ) | ||
### async | ||
Read YAML file synchronously and parse content as JSON | ||
Read YAML file asynchronously and parse content as JSON | ||
**Example:** | ||
```js | ||
var yaml = require('read-yaml'); | ||
var config = yaml('config.yml'); | ||
``` | ||
* `filepath` {String}: | ||
@@ -22,6 +29,13 @@ * `return` {Object} | ||
### .readYAML ( filepath ) | ||
### sync | ||
Read YAML file asynchronously and parse content as JSON | ||
Read YAML file synchronously and parse content as JSON | ||
**Example:** | ||
```js | ||
var yaml = require('read-yaml').sync; | ||
var config = yaml('config.yml'); | ||
``` | ||
* `filepath` {String}: | ||
@@ -43,2 +57,2 @@ * `return` {Object} | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 10, 2014._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 18, 2014._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6899
2
15
99
55
- Removedread-file@^0.1.2
- Removedasync@0.7.0(transitive)
- Removedfile-normalize@0.1.1(transitive)
- Removedgraceful-fs@2.0.3(transitive)
- Removedread-file@0.1.2(transitive)