0.2.2 • Published 8 years ago

async-parts v0.2.2

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

Build Status NPM version Coverage Status

var Async = require('async-parts');

// next()-chained async tasks
(new Async)
  .catch(function(err, next) {
    if (err) {
      console.log(err);
    }
    next();
  })
  .then(function(next) {
    next(/* error, data, ... */);
    // or throw new Error(...)
  })
  .run(function(err, data) {
    // err will be empty on success
    // data will be collected from next()
  });

Usage

new Async(context) will expose three methods:

  • catch(handler) Error handler for the chain
  • then(handler) Adds a subtask to chain
  • run(success) Initialize the chain

The created chain will be consumed until there are no more subtasks to invoke.

The constructor function can accept a context that will be bound on each callback.

Async.queue() is deprecated since 0.2.0.