Transform or convert thunk to Bluebird Promise.
npm i thunk2promise --save
npm test
For more use-cases see the tests
var thunk2promise = require('thunk2promise')
function thunk (a, b) {
return function (cb) {
if (a === b) {
return cb(new Error('a === b'))
}
cb(null, a, b, 3)
}
}
thunk2promise(thunk(333, 333)).catch(function (err) {
console.error(err.message)
//=> 'a === b'
})
thunk2promise(thunk(1, 2)).then(function (res) {
console.log(res)
//=> [1, 2, 3]
})
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.