Comparing version 2.0.0 to 2.1.0
28
index.js
@@ -36,10 +36,26 @@ 'use strict'; | ||
pify.all = function (obj, P, opts) { | ||
var ret = {}; | ||
if (typeof P !== 'function') { | ||
opts = P; | ||
P = Promise; | ||
} | ||
Object.keys(obj).forEach(function (key) { | ||
opts = opts || {}; | ||
var filter = function (key) { | ||
if (opts.include) { | ||
return opts.include.indexOf(key) !== -1; | ||
} | ||
if (opts.exclude) { | ||
return opts.exclude.indexOf(key) === -1; | ||
} | ||
return true; | ||
}; | ||
return Object.keys(obj).reduce(function (ret, key) { | ||
var x = obj[key]; | ||
ret[key] = typeof x === 'function' ? pify(x, P, opts) : x; | ||
}); | ||
return ret; | ||
ret[key] = (typeof x === 'function') && filter(key) ? pify(x, P, opts) : x; | ||
return ret; | ||
}, {}); | ||
}; |
{ | ||
"name": "pify", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Promisify a callback-style function", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -82,5 +82,21 @@ # pify [![Build Status](https://travis-ci.org/sindresorhus/pify.svg?branch=master)](https://travis-ci.org/sindresorhus/pify) | ||
##### include | ||
Type: `array` | ||
*Works for `pify.all()` only.* | ||
Pick which methods in a module to promisify. Remaining methods will be left untouched. | ||
##### exclude | ||
Type: `array` | ||
*Works for `pify.all()` only.* | ||
Pick which methods in a module **not** to promisify. | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
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
5079
48
102