2016-11-28 17:27:20 -08:00
|
|
|
module.exports = function (promiseFn) {
|
|
|
|
return function () {
|
|
|
|
var args = []
|
|
|
|
for (var i = 0; i < arguments.length - 1; i++) {
|
|
|
|
args.push(arguments[i])
|
2016-11-28 12:43:44 -08:00
|
|
|
}
|
2016-11-28 17:27:20 -08:00
|
|
|
var cb = arguments[arguments.length - 1]
|
2016-11-28 12:43:44 -08:00
|
|
|
|
2016-11-28 17:27:20 -08:00
|
|
|
return promiseFn.apply(this, args)
|
|
|
|
.then(function (result) {
|
|
|
|
cb(null, result)
|
|
|
|
})
|
|
|
|
.catch(function (reason) {
|
|
|
|
cb(reason)
|
|
|
|
})
|
2016-11-28 12:43:44 -08:00
|
|
|
}
|
|
|
|
}
|