universalify
Advanced tools
Comparing version 0.0.1 to 0.1.0
'use strict' | ||
exports.fromCallback = function (fn) { | ||
return function () { | ||
return Object.defineProperty(function () { | ||
if (typeof arguments[arguments.length - 1] === 'function') fn.apply(this, arguments) | ||
@@ -16,11 +16,11 @@ else { | ||
} | ||
} | ||
}, 'name', { value: fn.name }) | ||
} | ||
exports.fromPromise = function (fn) { | ||
return function () { | ||
return Object.defineProperty(function () { | ||
const cb = arguments[arguments.length - 1] | ||
if (typeof cb !== 'function') return fn.apply(this, arguments) | ||
else fn.apply(this, arguments).then(r => cb(null, r)).catch(cb) | ||
} | ||
}, 'name', { value: fn.name }) | ||
} |
{ | ||
"name": "universalify", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Make a callback- or promise-based function support both promises and callbacks.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
4450