News for hackers. Stuff that matters.
Re:Let’s make a JavaScript Wait function by xg15 on Sunday November 12, 2017 @06:28PM (#15683140)
Moreover, async/await allows you to preserve multiple intermediary results between async steps - which is awkward in both promises and un-nested pyramids like the OP's:

(not even starting with conditions, loops and recursive calls that contain async steps...)

Async/Await:

  async function f(a) {
   var b = await foo(a);
   var c = await bar(a, b);
   return baz(a, b, c);
  }
Promises:

  function f(a) {
   var _b;
   return foo(a)
    .then(b => {
      _b = b;
      return bar(a, b);
    })
    .then(c => baz(a, _b, c))
  }
Callbacks:

  function f(a, done) {
   foo(a, b => bar(a, b, c => baz(a, b, c, done)));
  }
Callbacks untangled:

  function f(a, done) {
   var _b;
   foo(a, step2);

   function step2(b) {
    _b = b;
    bar(a, b, step3);
   }  

   function step3(c) {
    baz(a, _b, c, done);
   }
  }

There are no comments on this comment yet.