Hacker Newsnew | comments | ask | jobs | submitlogin
yesbabyyes 813 days ago | link | parent

Great takeaway, jrockway. For his other example, I encourage people to take a look at caolan's excellent async library:

  async.waterfall([
    function(callback) {
      async.map(ids, db.getById, callback)
    },
    function(posts, callback) {
      callback(null, posts.map(templating.render))
    }
  ], function(err, results) {
    console.log(results);
  });
EDIT: Fixed example.


Jach 813 days ago | link

Personally I've gotten more use out of the Futures library, though both are great. https://github.com/coolaj86/futures It contains a form of 'waterfall' known as merely a sequence. I use a lot of sequences and promises, it makes me not go insane from NodeJS programming. In the end I still think it was a mistake for Node to not support any sync features because there are times it's nice to have. TameJS doesn't solve the problem completely either (and I hate the compile step).

-----




Lists | RSS | Bookmarklet | Guidelines | FAQ | DMCA | News News | Feature Requests | Bugs | Y Combinator | Apply | Library

Search: