0.0.3 • Published 11 years ago

graphflow v0.0.3

Weekly downloads
1
License
-
Repository
-
Last release
11 years ago

GraphFlow

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

Example

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

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]);
  })

  .run();

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.

Todo

  • 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.
0.0.3

11 years ago

0.0.2

11 years ago

0.0.1-1

11 years ago

0.0.1

11 years ago