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

2019-10-11 Thread Jacob Bloom
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( responses.get('reqA'), responses.get('reqB'), ); ``` ...which would

Re: Conditional await, anyone?

2019-10-11 Thread Tab Atkins Jr.
On Fri, Oct 11, 2019 at 1:15 AM Andrea Giammarchi wrote: > Again, the `await?` is sugar for the following: > > ```js > const value = await? callback(); > > // as sugar for > let value = callback(); > if ('then' in value) > value = await value; > ``` Okay, so that has the "you can't predict

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

2019-10-11 Thread Bradford Smith
Promise.all(Object.values(myObjWithPromiseValues)).then(...) On Fri, Oct 11, 2019 at 10:22 AM Jordan Harband wrote: > The current API accepts an *iterable*, which means any object that has > `Symbol.iterator`, such as an array or a Set. > > Throwing when it receives a non-iterable object is an

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

2019-10-11 Thread Jordan Harband
The current API accepts an *iterable*, which means any object that has `Symbol.iterator`, such as an array or a Set. Throwing when it receives a non-iterable object is an important tool to catch bugs. If Promise.all was made to accept a non-iterable object as well, I suspect many bugs would go

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

2019-10-11 Thread Adam Eisenreich
Back when async/await was introduced I struggeled quite a bit with promises arrays that have conditional promises. RxJS is moving from array only support in theirs operators to objects too, there seems to be an actual trend going on. Is there any reason

Re: Conditional await, anyone?

2019-10-11 Thread Andrea Giammarchi
Again, the `await?` is sugar for the following: ```js const value = await? callback(); // as sugar for let value = callback(); if ('then' in value) value = await value; ``` but since I've stated already I have no interest anymore in this proposal, we can also stop explaining to each others