asyncify

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

2 个版本
安装
npm install asyncify
yarn add asyncify
pnpm add asyncify
bun add asyncify
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);
});
版本列表
2.1.2 2014-01-13
2.1.1 2011-07-13