$ npm install promise2thunk
Convert (transform) promise to thunk, just like was in co@3
npm i promise2thunk --save
npm test
For more use-cases see the tests
var promise2thunk = require('promise2thunk')
var parseJson = require('then-parse-json')
var promise = parseJson('{"foo":"bar"}')
var thunk = promise2thunk(promise)
thunk(function (err, res) {
console.log(err) //=> null
console.log(res) //=> { foo: 'bar' }
})
hybridify. Handle callback in promise - give promise and callback return promise.callback or cb exists in function arguments.Generator or GeneratorFunction. The co way, more strict checking. Always return boolean true or false, never null or undefined.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.
© 2010 - cnpmjs.org x YWFE | Home | YWFE