aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/nodeify.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/nodeify.js')
-rw-r--r--app/scripts/lib/nodeify.js17
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)
+ })
+ }
+}