Skip to content

Instantly share code, notes, and snippets.

@lisovskyvlad
Created March 18, 2019 17:49
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 lisovskyvlad/99b93b8571cf29a870e531ff335260f8 to your computer and use it in GitHub Desktop.
Save lisovskyvlad/99b93b8571cf29a870e531ff335260f8 to your computer and use it in GitHub Desktop.
Learning of promises
const f = (wait_count, string) => (
new Promise((res, rej) => (setTimeout(() => res(string), wait_count)))
);
async function sequence() {
const a = await Promise.all([
f(2000, '2000 wait'),
f(500, '500 wait'),
f(1000, '1000 wait')
]);
console.log(a);
}
sequence()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment