thenify-all
Advanced tools
Comparing version 1.4.0 to 1.5.0
36
index.js
var thenify = require('thenify') | ||
module.exports = function (source, destination, methods) { | ||
module.exports = thenifyAll | ||
/** | ||
* Promisifies all the selected functions in an object. | ||
* | ||
* @param {Object} source the source object for the async functions | ||
* @param {Object} [destination] the destination to set all the promisified methods | ||
* @param {Array} [methods] an array of method names of `source` | ||
* @return {Object} | ||
* @api public | ||
*/ | ||
function thenifyAll(source, destination, methods) { | ||
return promisifyAll(source, destination, methods, thenify) | ||
} | ||
/** | ||
* Promisifies all the selected functions in an object and backward compatible with callback. | ||
* | ||
* @param {Object} source the source object for the async functions | ||
* @param {Object} [destination] the destination to set all the promisified methods | ||
* @param {Array} [methods] an array of method names of `source` | ||
* @return {Object} | ||
* @api public | ||
*/ | ||
thenifyAll.withCallback= function(source, destination, methods) { | ||
return promisifyAll(source, destination, methods, thenify.withCallback) | ||
} | ||
function promisifyAll(source, destination, methods, promisify) { | ||
if (!destination) { | ||
@@ -19,7 +49,7 @@ destination = {}; | ||
if (typeof source === 'function') destination = thenify(source) | ||
if (typeof source === 'function') destination = promisify(source) | ||
methods.forEach(function (name) { | ||
// promisify only if it's a function | ||
if (typeof source[name] === 'function') destination[name] = thenify(source[name]) | ||
if (typeof source[name] === 'function') destination[name] = promisify(source[name]) | ||
}) | ||
@@ -26,0 +56,0 @@ |
{ | ||
"name": "thenify-all", | ||
"description": "Promisifies all the selected functions in an object", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"author": "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)", | ||
@@ -9,3 +9,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"thenify": "3" | ||
"thenify": "^3.1.0" | ||
}, | ||
@@ -31,3 +31,6 @@ "devDependencies": { | ||
"index.js" | ||
] | ||
], | ||
"engines": { | ||
"node": ">=0.10" | ||
} | ||
} |
@@ -31,2 +31,4 @@ | ||
Promisifies all the selected functions in an object. | ||
- `source` - the source object for the async functions | ||
@@ -36,2 +38,10 @@ - `obj` - the destination to set all the promisified methods | ||
### var obj = thenify.withCallback(source, [obj], [methods]) | ||
Promisifies all the selected functions in an object and backward compatible with callback. | ||
- `source` - the source object for the async functions | ||
- `obj` - the destination to set all the promisified methods | ||
- `methods` - an array of method names of `source` | ||
[gitter-image]: https://badges.gitter.im/thenables/thenify-all.png | ||
@@ -38,0 +48,0 @@ [gitter-url]: https://gitter.im/thenables/thenify-all |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
6332
5
57
63
1
Updatedthenify@^3.1.0