Skip to content

Instantly share code, notes, and snippets.

@blackChef
Created March 24, 2020 10:33
Show Gist options
  • Save blackChef/d57b2a44cb7fdf2b0f67b100e3a4f11b to your computer and use it in GitHub Desktop.
Save blackChef/d57b2a44cb7fdf2b0f67b100e3a4f11b to your computer and use it in GitHub Desktop.
Execute async functions one by one, and collect result after all functions are finished
// [() => Promise] => Promise
const runPromiseFnInOrder = async function(fns) {
const ret = [];
for (const fn of fns) {
const r = await fn();
ret.push(r);
}
return Promise.resolve(ret);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment