source: frontend/node_modules/es-iterator-helpers/README.md

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 5.4 KB
Line 
1# es-iterator-helpers <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![github actions][actions-image]][actions-url]
4[![coverage][codecov-image]][codecov-url]
5[![License][license-image]][license-url]
6[![Downloads][downloads-image]][downloads-url]
7
8[![npm badge][npm-badge-png]][package-url]
9
10An ESnext spec-compliant sync iterator helpers shim/polyfill/replacement that works as far down as ES3.
11
12This package implements the [es-shim API](https://github.com/es-shims/api) “multi” interface. It works in an ES3-supported environment and complies with the [iterator helpers spec](https://tc39.es/proposal-iterator-helpers/) and the [iterator sequencing spec](https://tc39.es/proposal-iterator-sequencing/).
13
14Because 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.
15
16The 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.
17
18## Supported things
19
20 - [`Iterator` constructor](https://tc39.es/proposal-iterator-helpers/#sec-iterator-constructor)
21 - [`Iterator.prototype`](https://tc39.es/proposal-iterator-helpers/#sec-iterator.prototype)
22 - [`Iterator.concat`](https://tc39.es/proposal-iterator-sequencing/)
23 - [`Iterator.from`](https://tc39.es/proposal-iterator-helpers/#sec-iterator.from)
24 - [`Iterator.zip`](https://tc39.es/proposal-joint-iteration/#sec-iterator.zip)
25 - [`Iterator.zipKeyed`](https://tc39.es/proposal-joint-iteration/#sec-iterator.zipkeyed)
26 - [`Iterator.prototype.constructor`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.constructor)
27 - [`Iterator.prototype.drop`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.drop)
28 - [`Iterator.prototype.every`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.every)
29 - [`Iterator.prototype.filter`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.filter)
30 - [`Iterator.prototype.find`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.find)
31 - [`Iterator.prototype.flatMap`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.flatmap)
32 - [`Iterator.prototype.forEach`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.foreach)
33 - [`Iterator.prototype.includes`](https://tc39.es/proposal-iterator-includes/)
34 - [`Iterator.prototype.map`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.map)
35 - [`Iterator.prototype.reduce`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.reduce)
36 - [`Iterator.prototype.some`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.some)
37 - [`Iterator.prototype.take`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.take)
38 - [`Iterator.prototype.toArray`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.toarray)
39
40## Environments where this is needed
41
42 - node < v22, Chrome < v122, Safari <= v17.1, Firefox <= v125: not implemented
43 - node v22, Chrome v122 - v130: has a [bug](https://issues.chromium.org/issues/336839115) where `{ next: null }` is not properly rejected
44 - node v22 - v24, Chrome v122 - v134: missing early-error `IteratorClose` when argument validation fails (e.g., non-callable mapper does not call the iterator's `return` method)
45 - all environments lack Iterator.concat, Iterator.zip, Iterator.zipKeyed, Iterator.prototype.includes
46
47## Getting started
48
49```sh
50npm install --save es-iterator-helpers
51```
52
53## Usage/Examples
54
55Using explicit imports:
56
57```js
58const map = require('es-iterator-helpers/Iterator.prototype.map');
59const toArray = require('es-iterator-helpers/Iterator.prototype.toArray');
60const assert = require('assert');
61
62const iterator = [1, 2, 3].values();
63
64const mapped = map(iterator, (x) => x + 10);
65assert.deepEqual(
66 mapped.next(),
67 {
68 done: false,
69 value: 11,
70 }
71);
72assert.deepEqual(
73 toArray(mapped),
74 [12, 13]
75);
76```
77
78Shim using `require`:
79
80```js
81require('es-iterator-helpers/auto'); // shim all of the methods
82
83require('es-iterator-helpers/Iterator.prototype.map/auto'); // shim the “map” method
84```
85
86Shim using `import` syntax:
87
88[](#preventEval)
89```js
90import 'es-iterator-helpers/auto'; // shim all of the methods
91
92import 'es-iterator-helpers/Iterator.prototype.map/auto'; // shim the “map” method
93```
94
95## Tests
96Simply clone the repo, `npm install`, and run `npm test`
97
98[package-url]: https://npmjs.org/package/es-iterator-helpers
99[npm-version-svg]: https://versionbadg.es/es-shims/iterator-helpers.svg
100[deps-svg]: https://david-dm.org/es-shims/iterator-helpers.svg
101[deps-url]: https://david-dm.org/es-shims/iterator-helpers
102[dev-deps-svg]: https://david-dm.org/es-shims/iterator-helpers/dev-status.svg
103[dev-deps-url]: https://david-dm.org/es-shims/iterator-helpers#info=devDependencies
104[npm-badge-png]: https://nodei.co/npm/es-iterator-helpers.png?downloads=true&stars=true
105[license-image]: https://img.shields.io/npm/l/es-iterator-helpers.svg
106[license-url]: LICENSE
107[downloads-image]: https://img.shields.io/npm/dm/es-iterator-helpers.svg
108[downloads-url]: https://npm-stat.com/charts.html?package=es-iterator-helpers
109[codecov-image]: https://codecov.io/gh/es-shims/iterator-helpers/branch/main/graphs/badge.svg
110[codecov-url]: https://app.codecov.io/gh/es-shims/iterator-helpers/
111[actions-image]: https://img.shields.io/github/check-runs/es-shims/iterator-helpers/main
112[actions-url]: https://github.com/es-shims/iterator-helpers/actions
Note: See TracBrowser for help on using the repository browser.