Skip to content

Comment on Node.js - A Giant Step Backwards

Comments

I would write something like this:

  function handler(yes, no) {
      return function (err, data) {
          if (data) {
              yes(err, data);
          }
          else {
              no(err, data);
          }
      }
  }

  function get() {
      function done(err, data) {
  
          // do something with data
  
      }
      function db() {
          asynchronousDb.query("SELECT * fomr something where id = 3244", done);
      }
      asynchronousCache.get("id:3244", handler(done, db));
  }
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.