Skip to content

Instantly share code, notes, and snippets.

@devyn
Created June 18, 2016 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devyn/1b47b19022f52c0d0eadbb4c81fce492 to your computer and use it in GitHub Desktop.
Save devyn/1b47b19022f52c0d0eadbb4c81fce492 to your computer and use it in GitHub Desktop.
// With async
function foo(callback) {
async.series([
function (done) {
one("x", done);
},
function (done) {
if (FOO) {
two("y", done);
} else {
done();
}
}
], callback);
}
// With .then()
function foo() {
return one("x")
.then(() => {
if (FOO) {
return two("y");
}
});
}
// With async/await
async function foo() {
await one("x");
if (FOO) {
return await two("y");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment