b3c5d44b22eefea43859f81b3b73b79bce63730e
[dotfiles/.git] / index.js
1 "use strict"
2
3 var next = (global.process && process.nextTick) || global.setImmediate || function (f) {
4   setTimeout(f, 0)
5 }
6
7 module.exports = function maybe (cb, promise) {
8   if (cb) {
9     promise
10       .then(function (result) {
11         next(function () { cb(null, result) })
12       }, function (err) {
13         next(function () { cb(err) })
14       })
15     return undefined
16   }
17   else {
18     return promise
19   }
20 }