graphflow

0.0.3 • Public • Published

GraphFlow

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

Example (in LiveScript)

flow!
  .add \one, (cb) ->
    cb null, 1

  .add \two, (cb) ->
    cb null, 1

  .add \added, <[one two]>, (cb) ->
    cb null, @one + @two

  .error (e) ->
    throw e

  .done (v) ->
    console.log 'The answer is: ', v.added

  .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

  • Unit test ALL THE THINGS!
  • 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.

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i graphflow

    Weekly Downloads

    3

    Version

    0.0.3

    License

    BSD

    Last publish

    Collaborators

    • industrial