promise2thunk

1.0.1 • Public • Published

promise2thunk npmjs.com The MIT License

Convert (transform) promise to thunk, just like was in co@3

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

Install

npm i promise2thunk --save
npm test

Usage

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

Related

  • always-promise: Create Bluebird Promise from given async or synchronous function. It automatically convert sync functions to async, then to promise.
  • always-callback: Create callback api for given sync function. Guarantee that given function (sync or async, no matter) will always have callback api and will handle errors correctly.
  • make-callback: Make synchronous function to support callback api
  • handle-callback: Initial step for creating hybrid APIs, used by hybridify. Handle callback in promise - give promise and callback return promise.
  • handle-arguments: Handles given Arguments object - return separatly last argument (commonly callback) and other arguments as Array. Useful in node-style callback flow.
  • manage-arguments: Prevents arguments leakage - managing arguments. From Optimization killers by Petka Antonov.
  • is-async-function: Check that given function is async (callback) function or not. Trying to guess that based on check if callback or cb exists in function arguments.
  • is-es6-generators: Check whether a value is a Generator or GeneratorFunction. The co way, more strict checking. Always return boolean true or false, never null or undefined.

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.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Package Sidebar

Install

npm i promise2thunk

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • vanchoy
  • tunnckocore