start-then-go

0.9.2 • Public • Published

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

Install

  npm install start-then-go

Or from source:

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

Straightforward.

Flatten your callbacks into an easy to read pipeline that supports parallelism.

var stg = require('start-then-go');

stg.start(
  function (_, next) {
    next({ user_id : 123});
  }
).then(
  function (prev, next) {
    http.get(
      'http://someurl.com',
      function (_, _, res) {
        next({page_contents : res});
      }
    );
  },
  function (prev, next) {
    Users.findById(
      prev.user_id, 
      function (err, user) {
        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.

Readme

Keywords

none

Package Sidebar

Install

npm i start-then-go

Weekly Downloads

1

Version

0.9.2

License

none

Last publish

Collaborators

  • sbquinlan