aboutsummaryrefslogtreecommitdiff
path: root/node_modules/call-me-maybe/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/call-me-maybe/index.js')
-rw-r--r--node_modules/call-me-maybe/index.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/node_modules/call-me-maybe/index.js b/node_modules/call-me-maybe/index.js
new file mode 100644
index 0000000..b3c5d44
--- /dev/null
+++ b/node_modules/call-me-maybe/index.js
@@ -0,0 +1,20 @@
+"use strict"
+
+var next = (global.process && process.nextTick) || global.setImmediate || function (f) {
+ setTimeout(f, 0)
+}
+
+module.exports = function maybe (cb, promise) {
+ if (cb) {
+ promise
+ .then(function (result) {
+ next(function () { cb(null, result) })
+ }, function (err) {
+ next(function () { cb(err) })
+ })
+ return undefined
+ }
+ else {
+ return promise
+ }
+}