source: imaps-frontend/node_modules/es-iterator-helpers/README.md@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 4.9 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.prototype.constructor`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.constructor)
25 - [`Iterator.prototype.drop`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.drop)
26 - [`Iterator.prototype.every`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.every)
27 - [`Iterator.prototype.filter`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.filter)
28 - [`Iterator.prototype.find`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.find)
29 - [`Iterator.prototype.flatMap`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.flatmap)
30 - [`Iterator.prototype.forEach`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.foreach)
31 - [`Iterator.prototype.map`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.map)
32 - [`Iterator.prototype.reduce`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.reduce)
33 - [`Iterator.prototype.some`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.some)
34 - [`Iterator.prototype.take`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.take)
35 - [`Iterator.prototype.toArray`](https://tc39.es/proposal-iterator-helpers/#sec-iteratorprototype.toarray)
36
37## Environments where this is needed
38
39 - node v22, Chrome >= v122: has a [bug](https://issues.chromium.org/issues/336839115)
40 - node < v22, Chrome < v122, Safari <= v17.1, Firefox <= v125: not implemented
41 - all environments lack Iterator.concat
42
43## Getting started
44
45```sh
46npm install --save es-iterator-helpers
47```
48
49## Usage/Examples
50
51Using explicit imports:
52
53```js
54const map = require('es-iterator-helpers/Iterator.prototype.map');
55const toArray = require('es-iterator-helpers/Iterator.prototype.toArray');
56const assert = require('assert');
57
58const iterator = [1, 2, 3].values();
59
60const mapped = map(iterator, (x) => x + 10);
61assert.deepEqual(
62 mapped.next(),
63 {
64 done: false,
65 value: 11,
66 }
67);
68assert.deepEqual(
69 toArray(mapped),
70 [12, 13]
71);
72```
73
74Shim using `require`:
75
76```js
77require('es-iterator-helpers/auto'); // shim all of the methods
78
79require('es-iterator-helpers/Iterator.prototype.map/auto'); // shim the “map” method
80```
81
82Shim using `import` syntax:
83
84[](#preventEval)
85```js
86import 'es-iterator-helpers/auto'; // shim all of the methods
87
88import 'es-iterator-helpers/Iterator.prototype.map/auto'; // shim the “map” method
89```
90
91## Tests
92Simply clone the repo, `npm install`, and run `npm test`
93
94[package-url]: https://npmjs.org/package/es-iterator-helpers
95[npm-version-svg]: https://versionbadg.es/es-shims/iterator-helpers.svg
96[deps-svg]: https://david-dm.org/es-shims/iterator-helpers.svg
97[deps-url]: https://david-dm.org/es-shims/iterator-helpers
98[dev-deps-svg]: https://david-dm.org/es-shims/iterator-helpers/dev-status.svg
99[dev-deps-url]: https://david-dm.org/es-shims/iterator-helpers#info=devDependencies
100[npm-badge-png]: https://nodei.co/npm/es-iterator-helpers.png?downloads=true&stars=true
101[license-image]: https://img.shields.io/npm/l/es-iterator-helpers.svg
102[license-url]: LICENSE
103[downloads-image]: https://img.shields.io/npm/dm/es-iterator-helpers.svg
104[downloads-url]: https://npm-stat.com/charts.html?package=es-iterator-helpers
105[codecov-image]: https://codecov.io/gh/es-shims/iterator-helpers/branch/main/graphs/badge.svg
106[codecov-url]: https://app.codecov.io/gh/es-shims/iterator-helpers/
107[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/iterator-helpers
108[actions-url]: https://github.com/es-shims/iterator-helpers/actions
Note: See TracBrowser for help on using the repository browser.