Skip to content

Instantly share code, notes, and snippets.

@jkrems
Last active June 27, 2018 18:30
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jkrems/e3a592edd340f9760ed99d3f95e412fe to your computer and use it in GitHub Desktop.
require('async') → async/await

Moving to async/await

waterfall

function before(cb) {
  waterfall(
    f1,
    f2,
    cb
  );
}

async function after() {
  const r1 = await f1();
  const r2 = await f2(r1);
  return r2;
}

series

function before(cb) {
  series(f1, f2, cb);
}

async function after() {
  return [
    await f1();
    await f2();
  ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment