A function that creates a Bluebird promise that can be resolved or rejected using a Node-style callback.
make-promise
exports a single function, which takes a function as it sole argument. After you have called makePromise
, this function is called immediately afterwards with a Node-style callback as its sole argument.
undefined
.var skyIsFalling = false
var makePromise = require("make-promise")
var promise = makePromise(function(cb) {
setImmediate(function() {
if skyIsfalling
cb(new Error("Sky is falling."))
else
cb()
})
})
promise.then(
function(){
// phew!
},
function(err) {
console.error err.toString() + " Better take cover."
})
make-promise is released under the MIT License.
Copyright (c) 2017 Braveg1rl