
Company News
Meet the Socket Team at RSAC and BSidesSF 2026
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.
@proc7ts/push-iterator
Advanced tools
Push iteration protocol is a faster alternative to traditional JavaScript iteration protocol.
It extends Iterator interface with forNext(accept: (this: void, element: T) => void | boolean): boolean method.
The latter pushes iterated elements to accept function until there is no more elements, or accept function returns
false yo stop iteration. The forNext() method returns true if there are more elements to iterate, or false
otherwise. The former is possible only when iteration stopped, i.e. accept returned false.
Performance!
Traditional iteration protocol implies a call to next() method and creation of IteratorResult object on each
iteration step. The push iteration protocol avoids that.
See benchmarking results for performance comparison.
JavaScript engines optimize native iteration heavily in some situations, especially for arrays. Still, in non-trivial cases the push iteration protocol demonstrates better performance, especially when it deals with push iterators rather with raw ones.
Performance.
Push iterators are faster. Still, a lot of the code base relies on raw iterators and arrays. The library contains performance optimizations to deal with it.
Compatibility.
Tree shaking support.
The library API represented by functions. When tree-shaken the unused ones removed from bundles.
See the full [API Documentation].
Each of the following functions return a push iterable instance:
overArray(array) - Creates a push iterable over elements of array-like structure.overElementsOf(...iterables) - Creates a push iterable over elements of other iterables.overEntries(object) - Creates a push iterable over the property key/value entries of the given object.overKeys(object) - Creates a push iterable over keys of the given object.overMany(...values) - Creates a push iterable over many values.overNone() - Returns a push iterable iterator without elements.reverseArray(array) - Creates a push iterable over elements of array-like structure in reverse order.Each of the following functions accept either Iterable or push iterable:
itsEach(iterable, action) - Performs the given action for each element of the given iterable.itsEmpty(iterable): boolean - Checks whether the given iterable is empty.itsEvery(iterable, test): boolean - Tests whether all elements of the given iterable pass the test implemented
by the provided function.itsFirst(iterable): T | undefined - Extracts the first element of the given iterable, if any.itsReduction(iterable, reducer, initialValue): T - Applies a function against an accumulator and each element
of the given iterable to reduce elements to a single value.itsSome(iterable, test): boolean - Tests whether at least one element of the given iterable passes the test
implemented by the provided function.Each of the following functions accept either Iterable or push iterable, and return a push iterable:
filterIt(source, test) - Creates a push iterable with all source iterable elements that pass the test
implemented by the provided function.flatMapIt(source, convert?) - First maps each element of the source iterable using a mapping function,
then flattens the result into new push iterable.mapIt(source, convert) - Creates a push iterable with the results of calling a provided function on every element
of the source iterable.FAQs
Push iteration protocol
The npm package @proc7ts/push-iterator receives a total of 48 weekly downloads. As such, @proc7ts/push-iterator popularity was classified as not popular.
We found that @proc7ts/push-iterator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.

Research
/Security News
Malicious Packagist packages disguised as Laravel utilities install an encrypted PHP RAT via Composer dependencies, enabling remote access and C2 callbacks.

Research
/Security News
OpenVSX releases of Aqua Trivy 1.8.12 and 1.8.13 contained injected natural-language prompts that abuse local AI coding agents for system inspection and potential data exfiltration.