Another entry on the 'Keeping up with ECMAScript standards', today I present the underrated 'Iterator' helpers. Before, if you wanted to transform data in steps, you would usually materialize arrays with Array.from(...), .map(), .filter(), etc, where each step returns a new materialized array. With Iterator Helpers, you can keep the pipeline lazy and only consume values when needed. ECMAScript 2025 added the 'Iterator' global with helper methods, and the current spec defines Iterator Helper objects specifically for that lazy transformation model. So now you can do things like: Iterator .from(data) .filter(fn) .map(fn) .take(10) .toArray() The important part is not syntax sugar. The important part is laziness. Methods like map(), filter(), drop(), take(), and flatMap() return iterator helpers, so the pipeline stays chainable without producing intermediate arrays. That avoids unnecessary work and also fits much better with large or even infinite sequences. Additionally it is extremely useful when the pipeline is composed conditionally (i.e. if/else adds steps), making it much more performant. Although small on paper and some libs already supplied such functionality, having it built-in on the language pushes JavaScript a bit more toward composable, efficient, streaming-friendly code and helps solve the third-party dependency hell commonly found in JS projects. What are your thoughts about it? I don't know you, but from now on I will be using 'Iterator' helpers every time chains or conditional steps are involved. #JavaScript #TypeScript #ES2025 #Streaming #Pipeline
Nice post! 👍 Thanks for sharing!
Great insight. Thank you for sharing.
Underrated indeed, Giancarlo! I've been using libraries like RxJS or Highland for years to get this 'lazy' behavior, so seeing it land natively in ECMAScript is a massive win for simplicity. Do you think this will significantly reduce the need for utility libraries like Lodash in the long run, or do you think they'll still have a place for more complex transformations?