start-then-go

simple, declarative flow control

Start.Then.Go -- simple JS flow control.

  npm install start-then-go

Or from source:

  git clone git://github.com/sbquinlan/start-then-go.git 
  cd start-then-go
  npm link

I want to flatten my callbacks in an easy to read pipeline that supports parallelism (note that I'm not calling it concurrency).

var stg = require('start-then-go');
 
stg.start(
  function (_next) {
    next({ user_id : 123});
  }
).then(
  function (prevnext) {
    http.get(
      'http://someurl.com',
      function (__res) {
        next({page_contents : res});
      }
    );
  },
  function (prevnext) {
    Users.findById(
      prev.user_id, 
      function (erruser) {
        next({user : user});
      }
    );
  }
).then(
  function (prev) {
    console.log(prev);
//    { 
//      'page_contents' : '<html>...yadda...</html>', 
//      'user' : [Object object] 
//    } 
  }
).go();

There are a handful of these modules on NPM. I just wanted to add mine to the lot.