1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/lib/nodeify.js
2016-11-28 17:27:20 -08:00

18 lines
376 B
JavaScript

module.exports = function (promiseFn) {
return function () {
var args = []
for (var i = 0; i < arguments.length - 1; i++) {
args.push(arguments[i])
}
var cb = arguments[arguments.length - 1]
return promiseFn.apply(this, args)
.then(function (result) {
cb(null, result)
})
.catch(function (reason) {
cb(reason)
})
}
}