-
Notifications
You must be signed in to change notification settings - Fork 37
Support for Array Prototype Iteration Methods? #134
Comments
What you're asking for is already at stage 2: https://github.com/tc39/proposal-iterator-helpers |
Awesome news, thanks! It's a little unclear from that proposal that you'll be able to do:
but if it does that will be a truly great language improvement :-) |
Not if const asyncSum = await AsyncIterator.from(urls).reduce(async (sum, url) => {
const response = await fetch(url);
const { number } = await response.json();
return sum + number;
}, 0); |
If it's an array you can do |
That won't work for the given example, as then the |
Seems like it would be a lot simpler to instead have:
... but beggars can't be choosers :-D |
Added an PR with an example similar to the one from @Jamesernator to the readme of the proposal: tc39/proposal-iterator-helpers#124 |
* Add example w. conversion from array, async map Credit to @Jamesernator : tc39/proposal-async-iteration#134 (comment) * Remove extra await * Disable npm test (no test script specified) * Add .toArray() call Ref https://github.com/tc39/proposal-iterator-helpers/pull/124/files#r569479964
The example inspired by @Jamesernator has been accepted for the readme of https://github.com/tc39/proposal-iterator-helpers 🎉 |
Any chance this proposal could get a 2.0 version that adds support for asynchronous mapping, filtering, reducing, etc.?
The text was updated successfully, but these errors were encountered: