Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created July 20, 2020 00:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twolfson/154c0671c148884e6a6fa6a19ad782da to your computer and use it in GitHub Desktop.
Save twolfson/154c0671c148884e6a6fa6a19ad782da to your computer and use it in GitHub Desktop.
Exploration for familiarization with Promise API
(async function () {
// Define a Promise generator
function getPromise() {
// return Promise.resolve('done2');
// return Promise.reject('throw text ');
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('done');
}, 300 /* ms */);
});
}
let retVal = await Promise.allSettled([
getPromise(),
getPromise(),
Promise.reject('foo'),
]);
console.log(retVal);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment