An easy chainable API for dependency based asynchronous flow.

This library allows you to set up asynchronous flow in a javascript program without thinking much about what is running in parralel.

var flow = require('graphflow').flow;

  .add('forty', function(values, callback) {
    callback(null, 40);

  .add('two', function(values, callback) {
    callback(null, 40);

  .add('added', ['forty', 'two'], function(values, callback) {
    callback(null, values.forty[0] + values.two[0]);

  .fail(function(error) {
    throw error;

  .done(function(values) {
    console.log('answer:', values.added[0]);


By putting it in a Depencency Graph (link needed), when run is called, all functions are executed as soon as possible. When all dependencies for a node have been fulfilled, the graph executes that node (in parrallel). When a node has nothing to point to it is considered an end of the graph and the value is collected for the done callback.

By just declaring dependencies for the callbacks you request scope where needed and the graph figures it out.

  • If a callback only returns one value, pull it out of the array, so we don't need [0].
  • If a callback does not expect values (e.g. it is a starting point), do not require a values parameter in the callback function.
  • Generate a GraphViz (link needed) DOT graph with a method on Graph.
  • Maybe expose the graph to flow(), to be able to create a DOT graph out of defined flows.