function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function main() {
const start = Date.now();
const p1 = delay(100).then(() => 'a');
const p2 = delay(200).then(() => 'b');
const p3 = delay(50).then(() => { throw new Error('c'); });
try {
const result = await Promise.allSettled([p1, p2, p3]);
console.log(result.map(r => r.status));
} catch(e) {
console.log('caught:', e.message);
}
}
main(); 
