source: imaps-frontend/node_modules/array.prototype.flat/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.9 KB
Line 
1# array.prototype.flat <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![github actions][actions-image]][actions-url]
4[![coverage][codecov-image]][codecov-url]
5[![dependency status][deps-svg]][deps-url]
6[![dev dependency status][dev-deps-svg]][dev-deps-url]
7[![License][license-image]][license-url]
8[![Downloads][downloads-image]][downloads-url]
9
10[![npm badge][npm-badge-png]][package-url]
11
12An ES2019 spec-compliant `Array.prototype.flat` shim/polyfill/replacement that works as far down as ES3.
13
14This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the proposed [spec](https://tc39.github.io/proposal-flatMap/).
15
16Because `Array.prototype.flat` depends on a receiver (the `this` value), the main export takes the array to operate on as the first argument.
17
18## Getting started
19
20```sh
21npm install --save array.prototype.flat
22```
23
24## Usage/Examples
25
26```js
27var flat = require('array.prototype.flat');
28var assert = require('assert');
29
30var arr = [1, [2], [], 3, [[4]]];
31
32assert.deepEqual(flat(arr, 1), [1, 2, 3, [4]]);
33```
34
35```js
36var flat = require('array.prototype.flat');
37var assert = require('assert');
38/* when Array#flat is not present */
39delete Array.prototype.flat;
40var shimmedFlat = flat.shim();
41
42assert.equal(shimmedFlat, flat.getPolyfill());
43assert.deepEqual(arr.flat(), flat(arr));
44```
45
46```js
47var flat = require('array.prototype.flat');
48var assert = require('assert');
49/* when Array#flat is present */
50var shimmedIncludes = flat.shim();
51
52var mapper = function (x) { return [x, 1]; };
53
54assert.equal(shimmedIncludes, Array.prototype.flat);
55assert.deepEqual(arr.flat(mapper), flat(arr, mapper));
56```
57
58## Tests
59Simply clone the repo, `npm install`, and run `npm test`
60
61[package-url]: https://npmjs.org/package/array.prototype.flat
62[npm-version-svg]: https://versionbadg.es/es-shims/Array.prototype.flat.svg
63[deps-svg]: https://david-dm.org/es-shims/Array.prototype.flat.svg
64[deps-url]: https://david-dm.org/es-shims/Array.prototype.flat
65[dev-deps-svg]: https://david-dm.org/es-shims/Array.prototype.flat/dev-status.svg
66[dev-deps-url]: https://david-dm.org/es-shims/Array.prototype.flat#info=devDependencies
67[npm-badge-png]: https://nodei.co/npm/array.prototype.flat.png?downloads=true&stars=true
68[license-image]: https://img.shields.io/npm/l/array.prototype.flat.svg
69[license-url]: LICENSE
70[downloads-image]: https://img.shields.io/npm/dm/array.prototype.flat.svg
71[downloads-url]: https://npm-stat.com/charts.html?package=array.prototype.flat
72[codecov-image]: https://codecov.io/gh/es-shims/Array.prototype.flat/branch/main/graphs/badge.svg
73[codecov-url]: https://app.codecov.io/gh/es-shims/Array.prototype.flat/
74[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Array.prototype.flat
75[actions-url]: https://github.com/es-shims/Array.prototype.flat/actions
Note: See TracBrowser for help on using the repository browser.