If this is what we gonna have `[].promiseAll`
then I'd rather `Promise.all()` You made some fair point, I guess there's nothing to see here. Regards On Fri, Mar 3, 2017 at 2:12 PM, T.J. Crowder < [email protected]> wrote: > On Fri, Mar 3, 2017 at 12:43 PM, Andrea Giammarchi < > [email protected]> wrote: > > Not the first time I accidentally type the following: > > > > ```js > > const allTheThings = await [pa, pb, pc]; > > ``` > > > > I am assuming that JS will implicitly realize that'd be a > > `Promise.all([pa, pb, pc])` call but nope. > > The problem is that an array of promises is a perfectly valid promise > resolution value. (And that the proposal is now at Stage 4. :-) ) To > do this, `await` would have to treat arrays specially in a way that > promises don't. That seems like something `await` shouldn't do. You > might propose `awaitall`, `awaitany`, `awaitrace` or similar... > > > Then I also realize it'd be cool to have other shortcuts too that > > play nice with arrays such: > > > > ```js > > Array.prototype.all = function all() { return Promise.all(this); }; > > Array.prototype.race = function race() { return Promise.race(this); }; > > Side note: I'm fairly sure `all` isn't websafe as an `Array.prototype` > function (isn't that why ES5 used `every`?). > > I don't think arrays need special promise-related functionality in the > standard lib. But if they got it, I'd want it to be reflected in the > naming, e.g. `[].promiseAll`, `[].promiseAny`, ... Both for clarity and > for web safety (I'm fairly sure `all` on `Array.prototype` wouldn't be > web-safe). > > -- T.J. >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

