A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/app/scripts/lib/nodeify.js

24 lines
592 B

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]
const nodeified = promiseFn.apply(this, args)
if (!nodeified) {
const methodName = String(promiseFn).split('(')[0]
throw new Error(`The ${methodName} did not return a Promise, but was nodeified.`)
}
nodeified.then(function (result) {
cb(null, result)
})
.catch(function (reason) {
cb(reason)
})
return nodeified
}
}