Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created June 30, 2023 17:14
Show Gist options
  • Save onosendi/866c511ada9575aeef6f0cccc6da8a58 to your computer and use it in GitHub Desktop.
Save onosendi/866c511ada9575aeef6f0cccc6da8a58 to your computer and use it in GitHub Desktop.
const errors = [];
const ress = [];
const fn = (x) => new Promise((resolve) => {
if (x === 0) {
errors.push('Equals 0');
// reject(new Error('Error: equals 0'));
} else {
// resolve(`Resolved: ${x}`);
ress.push(`Equals ${x}`);
}
resolve();
});
const arr = [
fn(1),
fn(2),
fn(0),
fn(3),
fn(0),
];
Promise
.all(arr)
.then(() => {
console.log(ress);
console.log(errors);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment