Comparing version 1.1.0 to 1.1.1
18
index.js
'use strict'; | ||
function isFn(fn) { | ||
return ({}).toString.call(fn) === '[object Function]'; | ||
} | ||
var pify = module.exports = function (fn, P) { | ||
P = P || Promise; | ||
if (!isFn(fn)) { | ||
if (typeof fn !== 'function') { | ||
throw new TypeError('Expected a function'); | ||
@@ -34,13 +30,11 @@ } | ||
pify.all = function (module, P) { | ||
pify.all = function (obj, P) { | ||
var ret = {}; | ||
for (var method in module) { | ||
if (({}).hasOwnProperty.call(module, method)) { | ||
var x = module[method]; | ||
ret[method] = isFn(x) ? pify(x, P) : x; | ||
} | ||
} | ||
Object.keys(obj).forEach(function (key) { | ||
var x = obj[key]; | ||
ret[key] = typeof x === 'function' ? pify(x, P) : x; | ||
}); | ||
return ret; | ||
}; |
{ | ||
"name": "pify", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Promisify a callback-style function", | ||
@@ -13,3 +13,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=0.12.0" | ||
"node": ">=0.10.0" | ||
}, | ||
@@ -16,0 +16,0 @@ "scripts": { |
@@ -16,6 +16,6 @@ # pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) | ||
```js | ||
var fs = require('fs'); | ||
var pify = require('pify'); | ||
const fs = require('fs'); | ||
const pify = require('pify'); | ||
pify(fs.readFile)('package.json', 'utf8').then(function (data) { | ||
pify(fs.readFile)('package.json', 'utf8').then(data => { | ||
console.log(JSON.parse(data).name); | ||
@@ -26,5 +26,5 @@ //=> 'pify' | ||
// promisify all methods in a module | ||
var promiseFs = pify.all(fs); | ||
const promiseFs = pify.all(fs); | ||
promiseFs.readFile('package.json', 'utf8').then(function (data) { | ||
promiseFs.readFile('package.json', 'utf8').then(data => { | ||
console.log(JSON.parse(data).name); | ||
@@ -31,0 +31,0 @@ //=> 'pify' |
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
3888
31