Re: Modify Promise.all() to accept an Object as a parameter

2019-10-14 Thread Cyril Auburtin
maybe a naming like: `Promise.allObject` ```js Promise.allObject = obj => { if (obj && !obj[Symbol.iterator]) { return Promise.all( Object.entries(obj).map(async ([k, v]) => [k, await v]) ) .then(Object.fromEntries); } return Promise.all(obj); } var delay = t => new Prom

Re: Modify Promise.all() to accept an Object as a parameter

2019-10-14 Thread Michał Wadas
Established name is Promise.properties On Mon, 14 Oct 2019, 09:29 Cyril Auburtin, wrote: > maybe a naming like: `Promise.allObject` > > ```js > Promise.allObject = obj => { > if (obj && !obj[Symbol.iterator]) { > return Promise.all( > Object.entries(obj).map(async ([k, v]) => [k, awa

Re: Modify Promise.all() to accept an Object as a parameter

2019-10-14 Thread Michael Luder-Rosefield
The RSVP library uses Promise.hash, which seems sensible enough that I'm surprised no-one has mentioned or suggested it here. -- Dammit babies, you've got to be kind. On Mon, 14 Oct 2019 at 09:17, Michał Wadas wrote: > Established name is Promise.properties > > On Mon, 1

Re: Re: Modify Promise.all() to accept an Object as a parameter

2019-10-14 Thread Tab Atkins Jr.
On Fri, Oct 11, 2019 at 9:53 PM Jacob Bloom wrote: > What about special handling for Maps? Maybe something like > > ``` > const requests = new Map(); > requests.set('reqA', fetch('...')); > requests.set('reqB', fetch('...')); > const responses = await Promise.all(requests); > console.log( > resp

Re: Conditional await, anyone?

2019-10-14 Thread Tab Atkins Jr.
On Sat, Oct 12, 2019 at 7:19 AM Andrea Giammarchi wrote: > in order to work, `await` must be executed in an async scope/context (either > top level or within a closure). > > In such case, either somebody is awaiting the result of that `async` > execution, or the order doesn't matter. That's def