Skip to content

Latest commit

 

History

History
94 lines (62 loc) · 3.48 KB

README.md

File metadata and controls

94 lines (62 loc) · 3.48 KB

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