npm install es-iterator-helpers

An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3.

About es-iterator-helpers

The npm package "es-iterator-helpers" is a robust solution designed to enhance the functionality of iterators in JavaScript. This package serves as a shim, polyfill, or replacement that is fully compliant with the ESnext specification, ensuring that it aligns perfectly with the latest JavaScript standards. Impressive for its backward compatibility, it supports environments as old as ES3, making it an ideal choice for projects that need to maintain legacy system compatibility while also leveraging modern JavaScript features. The "es-iterator-helpers" package simplifies the process of working with iterators, providing developers with a suite of powerful tools to handle iterable objects more efficiently and effectively.

To start using "es-iterator-helpers" in your project, simply run the command `npm install es-iterator-helpers`. This command integrates the package into your node environment, allowing you to immediately benefit from its extensive range of iterator utilities. Once installed, developers can utilize methods that streamline complex operations such as mapping, reducing, filtering, and more directly on iterators. This not only enhances code readability but also significantly improves performance by reducing the need for intermediate arrays. The "es-iterator-helpers" package is also well-supported with regular updates and a strong backing on GitHub, ensuring it remains reliable and up-to-date with the latest developments in JavaScript.

The "es-iterator-helpers" npm package is not only a practical addition to any JavaScript project but also a testament to the evolving capabilities of JavaScript development. Its compliance with the ESnext spec and support down to ES3 showcases its versatility and broad applicability across different project requirements and environments. For developers looking to optimize their code and streamline their development process with efficient iterator handling, "es-iterator-helpers" offers a proven, high-quality solution.

More from es-shims

es-shims npm packages

Find the best node modules for your project.

Search npm

regexp.prototype.flags

ES6 spec-compliant RegExp.prototype.flags shim...

Read more
,

string.prototype.trimend

ES2019 spec-compliant String.prototype.trimEnd shim...

Read more
,

string.prototype.trimstart

ES2019 spec-compliant String.prototype.trimStart shim...

Read more
,

arraybuffer.prototype.slice

ES spec-compliant shim for ArrayBuffer.prototype...

Read more
,

string.prototype.matchall

Spec-compliant polyfill for String.prototype...

Read more
,

object.groupby

An ESnext spec-compliant `Object.groupBy` shim/polyfill/replacement that works as far down as ES3...

Read more
,

array.prototype.tosorted

An ESnext spec-compliant `Array.prototype...

Read more
,

es-iterator-helpers

An ESnext spec-compliant iterator helpers shim/polyfill/replacement that works as far down as ES3...

Read more
,

array.prototype.toreversed

An ESnext spec-compliant `Array.prototype...

Read more
,

typedarray.prototype.slice

ES spec-compliant shim for TypedArray.prototype...

Read more
,

string.prototype.replaceall

Spec-compliant polyfill for String.prototype...

Read more
,

error-cause

An ES-spec-compliant shim/polyfill/replacement for the `...

Read more

Dependencies

Core dependencies of this npm package and its dev dependencies.

call-bind, define-properties, es-abstract, es-errors, es-set-tostringtag, function-bind, get-intrinsic, globalthis, has-property-descriptors, has-proto, has-symbols, internal-slot, iterator.prototype, safe-array-concat, @es-shims/api, @ljharb/eslint-config, aud, auto-changelog, es-value-fixtures, eslint, eslint-plugin-import, evalmd, for-each, functions-have-names, has-strict-mode, has-tostringtag, in-publish, iterate-iterator, make-generator-function, mock-property, npmignore, nyc, object-inspect, safe-publish-latest, tape

Documentation

A README file for the es-iterator-helpers code repository. View Code

es-iterator-helpers Version Badge

github actions coverage License Downloads

npm badge

An ESnext spec-compliant sync iterator helpers shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API “multi” interface. It works in an ES3-supported environment and complies with the spec.

Because the Iterator.prototype methods depend on a receiver (the this value), the main export in each subdirectory takes the iterator to operate on as the first argument.

The main export of the package itself is simply an array of the available directory names. It’s sole intended use is for build tooling and testing.

Supported things

Environments where this is needed

Getting started

npm install --save es-iterator-helpers

Usage/Examples

const map = require('es-iterator-helpers/Iterator.prototype.map');
const toArray = require('es-iterator-helpers/Iterator.prototype.toArray');
const assert = require('assert');

const iterator = [1, 2, 3].values();

const mapped = map(iterator, (x) => x + 10);
assert.deepEqual(
    mapped.next(),
    {
        done: false,
        value: 11,
    }
);
assert.deepEqual(
    toArray(mapped),
    [12, 13]
);
require('./auto'); // shim all of the methods

require('./Iterator.prototype.map/auto'); // shim the “map” method

Tests

Simply clone the repo, npm install, and run npm test