proposal-iterator-helpers
proposal-iterator-helpers copied to clipboard
Methods for working with iterators in ECMAScript
It currently flattens iterables. If `X.prototype.flatMap` flattens `X`s, we should instead be flattening iterators. As mentioned by @rbuckton in https://github.com/tc39/proposal-iterator-helpers/issues/117#issuecomment-1238559467.
https://github.com/tc39/ecma262/pull/3268 lets us simplify use of the iteration protocol.
## implementations test results: https://test262.fyi/#built-ins/Iterator/prototype|v8_exp,sm_exp,jsc,qjs,libjs,chakra,graaljs,xs,rhino,babel - [ ] Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1568906 - [X] Chrome (114 dev trial, 117 stable): https://chromestatus.com/feature/5102502917177344 - [ ] Safari: https://bugs.webkit.org/show_bug.cgi?id=248650 - [X] polyfill: [es-iterator-helpers](https://www.npmjs.com/package/es-iterator-helpers) ## other...
**Terribly sorry if this is clearly documented and I missed it** With `Array#flatMap`, it will automatically flatten/merge in values that are not arrays into the array output: ```ts [1, 2,...
Hi, I just came across this proposal. I was thinking of something in the context of testing streams and found generators as a simple way to stream data. the purpose...
```js const nums = [1,2,3,4,5,6,7,8,9] const iter1 = nums.values() iter1.take(2).toArray() // [1, 2] iter1.take(2).toArray() // [3, 4] iter1.take(2).toArray() // [5, 6] iter1.next() // {value: 7, done: false} const iter2 =...
Could you please add Java Streams to the prior art, as IMO this is the prior art closest in shape to this proposal? The high-level structure of Iterator Helpers is...