fs-readfile-promise
Advanced tools
Comparing version 3.0.1 to 4.0.0-0
21
index.js
'use strict'; | ||
const readFile = require('graceful-fs').readFile; | ||
const {readFile} = require('graceful-fs'); | ||
module.exports = function fsReadFilePromise(filePath, options) { | ||
const ARG_ERROR = 'Expected 1 or 2 arguments (<string|Buffer|URL|integer>[, <Object|string>])'; | ||
module.exports = function fsReadFilePromise(...args) { | ||
const argLen = args.length; | ||
if (argLen === 0) { | ||
const error = new RangeError(`${ARG_ERROR}, but got no arguments.`); | ||
error.code = 'ERR_MISSING_ARGS'; | ||
return Promise.reject(error); | ||
} | ||
if (argLen > 2) { | ||
return Promise.reject(new RangeError(`${ARG_ERROR}, but got ${argLen} arguments.`)); | ||
} | ||
return new Promise((resolve, reject) => { | ||
readFile(filePath, options, (err, data) => { | ||
readFile(...args, (err, data) => { | ||
if (err) { | ||
@@ -9,0 +24,0 @@ reject(err); |
{ | ||
"name": "fs-readfile-promise", | ||
"version": "3.0.1", | ||
"version": "4.0.0-0", | ||
"description": "Promise version of fs.readFile", | ||
@@ -5,0 +5,0 @@ "repository": "shinnn/fs-readfile-promise", |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
4215
23
2