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

Package detail

asyncify

coolaj861772.1.2

The asyncify deferred module of FuturesJS (Ender.JS and Node.JS)

flow-control, async, asynchronous, asyncify, util, browser

readme

asyncify()

  • doStuff = Futures.asyncify(doStuffSync) - returns a fuction with the same signature which catches errors and returns a future rather than the synchronous data.

Example:

function doStuffSync = function (params) {
  throw new Error("Error of some sort");
  return "Hello";
}

var doStuff = Futures.asyncify(doStuffSync);

doStuff.whenever(function (err, data) {
  console.log(err, data);
});

doStuff();
doStuff();
doStuff().when(function (err, data) {
  if (err) {
    throw err;
  }
  console.log(data);
});