achain.js

0.0.8 • Public • Published

achain.js

Build Status

A simple module to chain asynchronous calls. Please look at the code or the test code for more examples.

Usage

var Chain = require("achain.js");

var args_list = [ 1, 2, 3, 4, 5, 6, 7 ];
var chain = new Chain();

function inc(args, options, callback)
{
  options.value++;
  options.args_list = options.args_list || [];
  options.args_list.push(args);
  callback();
};

chain.addMany(args_list, inc);
chain.add(8, inc);

chain.final(function(error, options)
{
  if (error)
  {
    console.log(error);
    return;
  }

  console.log(options.value); // 8
  console.log(options.args_list); // [ 1, 2, 3, 4, 5, 6, 7, 8 ];
});

chain.run();

Readme

Keywords

none

Package Sidebar

Install

npm i achain.js

Weekly Downloads

7

Version

0.0.8

License

GPLv2

Last publish

Collaborators

  • mattiasrunge