Skip to content

Instantly share code, notes, and snippets.

@tygas
Created September 8, 2017 07:43
Show Gist options
  • Save tygas/93db2a22d77e10843cb53cf235e5b02f to your computer and use it in GitHub Desktop.
Save tygas/93db2a22d77e10843cb53cf235e5b02f to your computer and use it in GitHub Desktop.
let r;
const runTasks = (...tasks) => Promise.all(tasks.map(t => t())).then(r => (r));
const tA = () => new Promise(r => setTimeout(() => r('A'), 1000));
const tB = () => new Promise(r => setTimeout(() => r('B'), 100));
const tC = () => new Promise(r => setTimeout(() => r('C'), 100));
runTasks(tA, tB, tC).then(re => {
console.log(re);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment