fs-readfile-promise
Advanced tools
Comparing version 2.0.1 to 3.0.0
23
index.js
'use strict'; | ||
var fs = require('graceful-fs'); | ||
const fs = require('graceful-fs'); | ||
module.exports = function fsReadFilePromise(filePath, options) { | ||
var resolve; | ||
var reject; | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(filePath, options, (err, data) => { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
fs.readFile(filePath, options, function(err, buf) { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(buf); | ||
resolve(data); | ||
}); | ||
}); | ||
return new Promise(function(_resolve, _reject) { | ||
resolve = _resolve; | ||
reject = _reject; | ||
}); | ||
}; |
{ | ||
"name": "fs-readfile-promise", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Promise version of fs.readFile", | ||
@@ -8,6 +8,5 @@ "repository": "shinnn/fs-readfile-promise", | ||
"scripts": { | ||
"pretest": "eslint --config node_modules/@shinnn/eslintrc-node/rc.json index.js test.js", | ||
"test": "node --harmony_arrow_functions test.js", | ||
"coverage": "node --harmony_arrow_functions node_modules/.bin/istanbul cover test.js", | ||
"coveralls": "${npm_package_scripts_coverage} && istanbul-coveralls" | ||
"pretest": "eslint --fix --config @shinnn/node index.js test.js", | ||
"test": "node --strong_mode test.js", | ||
"coverage": "node --strong_mode node_modules/.bin/istanbul cover test.js" | ||
}, | ||
@@ -31,8 +30,7 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@shinnn/eslintrc-node": "^1.0.2", | ||
"eslint": "^0.24.0", | ||
"istanbul": "^0.3.17", | ||
"istanbul-coveralls": "^1.0.3", | ||
"tape": "^4.0.0" | ||
"@shinnn/eslint-config-node": "^2.0.0", | ||
"eslint": "^2.10.0", | ||
"istanbul": "^0.4.3", | ||
"tape": "^4.5.1" | ||
} | ||
} |
@@ -7,4 +7,4 @@ # fs-readfile-promise | ||
[![Coverage Status](https://img.shields.io/coveralls/shinnn/fs-readfile-promise.svg)](https://coveralls.io/r/shinnn/fs-readfile-promise) | ||
[![Dependency Status](https://img.shields.io/david/shinnn/fs-readfile-promise.svg?label=deps)](https://david-dm.org/shinnn/fs-readfile-promise) | ||
[![devDependency Status](https://img.shields.io/david/dev/shinnn/fs-readfile-promise.svg?label=devDeps)](https://david-dm.org/shinnn/fs-readfile-promise#info=devDependencies) | ||
[![Dependency Status](https://david-dm.org/shinnn/fs-readfile-promise.svg)](https://david-dm.org/shinnn/fs-readfile-promise) | ||
[![devDependency Status](https://david-dm.org/shinnn/fs-readfile-promise/dev-status.svg)](https://david-dm.org/shinnn/fs-readfile-promise#info=devDependencies) | ||
@@ -14,7 +14,7 @@ [Promises/A+][promise] version of [`fs.readFile`][fs.readfile] | ||
```javascript | ||
var readFile = require('fs-readfile-promise'); | ||
const readFile = require('fs-readfile-promise'); | ||
readFile('path/to/file') | ||
.then(buffer => console.log(buffer.toString())) | ||
.catch(err => console.log(err.message)); | ||
.catch(err => console.error(err.message)); | ||
``` | ||
@@ -59,3 +59,3 @@ | ||
Copyright (c) 2014 - 2015 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn) | ||
@@ -62,0 +62,0 @@ Licensed under [the MIT License](./LICENSE). |
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
4
4948
13