async-compatibilty
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,13 +1,14 @@ | ||
var isError = require('is-error'); | ||
var isPromise = require('is-promise'); | ||
module.exports = function asyncValue(value, callback) { | ||
isPromise(value) | ||
? value | ||
.then(function (result) { | ||
callback(null, result); | ||
}) | ||
.catch(function (err) { | ||
callback(err); | ||
}) | ||
: callback(null, value); | ||
if (isError(value)) return callback(value); | ||
if (!isPromise(value)) return callback(null, value); | ||
value | ||
.then(function (result) { | ||
callback(null, result); | ||
}) | ||
.catch(function (err) { | ||
callback(err); | ||
}); | ||
}; |
{ | ||
"name": "async-compatibilty", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Compatibility functions for writing libraries that support both callbacks and promises", | ||
@@ -29,2 +29,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"is-error": "^2.2.2", | ||
"is-promise": "^2.1.0" | ||
@@ -31,0 +32,0 @@ }, |
3888
36
2
+ Addedis-error@^2.2.2
+ Addedis-error@2.2.2(transitive)