Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

thunkify

visionmedia1.5mMIT2.1.2

Turn callbacks, arrays, generators, generator functions, and promises into a thunk

thunk, co, generator, generators, promise

readme

thunkify

Turn a regular node function into one which returns a thunk, useful for generator-based flow control such as co.

Installation

$ npm install thunkify

Example

var thunkify = require('thunkify');
var fs = require('fs');

var read = thunkify(fs.readFile);

read('package.json', 'utf8')(function(err, str){

});

License

MIT

changelog

2.1.2 / 2014-06-02

  • fix: make this an optimizable function with crankshaft

2.1.1 / 2014-04-17

  • remove memoization

2.1.0 / 2014-04-17

  • add catching of thunk errors

2.0.0 / 2014-04-17

  • change to behave like a future (subsequent calls yield the same value)
  • remove support for eager execution (breaking change)

1.0.0 / 2014-04-11

  • add assert(fn)