Skip to content

hybridables/thunk2promise

Repository files navigation

thunk2promise npmjs.com The MIT License

Transform or convert thunk to Bluebird Promise.

code climate standard code style travis build status coverage status dependency status

Install

npm i thunk2promise --save
npm test

Usage

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]
})

Contributing

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.

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

About

Transform or convert thunk to Bluebird Promise, just like in co@4

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published