Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including async-chain with all npm packages installed. Try it out:

var asyncChain = require("async-chain")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

async-chain v0.3.0

construct async chains.

var ch = new Chains({
  //object of async functions
  method1: function (arg1,arg2, callback) {},
  method2: function (arg1,arg2, callback) {}
})

then call methods like this:

ch.method1(1,2).method2(3,4).done(function (){
  called when all the commands are done.
})

an instance of Chain is an event emitter. It will emit the callback args of every async called. The events are the names of the methods. Also, you can pass callbacks in the usual way.

if a method calls back with an argument in the first slot Chain will emit 'error'

also, an Chains emits a 'change' event, that emits the same arguments as the normal event, but with the event name as the first argument.

##conventions

async-chains depends on some strict conventions.

  • no varible arguments. the number of arguments will be asserted.
  • callback must be last.
  • functions may refur to this. this will be the Chain instance
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free