diff options
Merge pull request #896 from MetaMask/i893-DenodeifyKeyringController
Denodeify most of KeyringController
Diffstat (limited to 'app/scripts/lib/nodeify.js')
-rw-r--r-- | app/scripts/lib/nodeify.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js new file mode 100644 index 000000000..56b793852 --- /dev/null +++ b/app/scripts/lib/nodeify.js @@ -0,0 +1,17 @@ +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) + }) + } +} |