Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 18, 2024 via pnpm

array.prototype.flat 1.3.2

An ES2019 spec-compliant `Array.prototype.flat` shim/polyfill/replacement that works as far down as ES3.
Package summary
Share
0
issues
1
license
67
MIT
Package created
22 May 2018
Version published
6 Sep 2023
Maintainers
1
Total deps
67
Direct deps
4
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
67 Packages, Including:
array-buffer-byte-length@1.0.1
array.prototype.flat@1.3.2
arraybuffer.prototype.slice@1.0.3
available-typed-arrays@1.0.7
call-bind@1.0.7
data-view-buffer@1.0.1
data-view-byte-length@1.0.1
data-view-byte-offset@1.0.0
define-data-property@1.1.4
define-properties@1.2.1
es-abstract@1.23.3
es-define-property@1.0.0
es-errors@1.3.0
es-object-atoms@1.0.0
es-set-tostringtag@2.0.3
es-shim-unscopables@1.0.2
es-to-primitive@1.2.1
for-each@0.3.3
function-bind@1.1.2
function.prototype.name@1.1.6
functions-have-names@1.2.3
get-intrinsic@1.2.4
get-symbol-description@1.0.2
globalthis@1.0.4
gopd@1.0.1
has-bigints@1.0.2
has-property-descriptors@1.0.2
has-proto@1.0.3
has-symbols@1.0.3
has-tostringtag@1.0.2
hasown@2.0.2
internal-slot@1.0.7
is-array-buffer@3.0.4
is-bigint@1.0.4
is-boolean-object@1.1.2
is-callable@1.2.7
is-data-view@1.0.1
is-date-object@1.0.5
is-negative-zero@2.0.3
is-number-object@1.0.7
is-regex@1.1.4
is-shared-array-buffer@1.0.3
is-string@1.0.7
is-symbol@1.0.4
is-typed-array@1.1.13
is-weakref@1.0.2
isarray@2.0.5
object-inspect@1.13.1
object-keys@1.1.1
object.assign@4.1.5
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

4
All Dependencies CSV
β“˜ This is a list of array.prototype.flat 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
call-bind1.0.721.6 kBMIT
prod
define-properties1.2.15.08 kBMIT
prod
es-abstract1.23.31 BMIT
prod
es-shim-unscopables1.0.24.31 kBMIT
prod

Visualizations

Frequently Asked Questions

What does array.prototype.flat do?

Array.prototype.flat is a polyfill, replacement, or shim for the Array.prototype.flat functionality that is compliant with the ES2019 specification. This JavaScript utility provides a means to flatten multi-dimensional arrays in an environment that supports ES3. This is critically useful in mitigating instances where the native Array.prototype.flat method may not be available or supported.

How do you use array.prototype.flat?

To utilize the array.prototype.flat, you first need to install it in your project using npm, the node package manager. Once installed, you can import the function and use it to flatten arrays. The code that demonstrates this is:

var flat = require('array.prototype.flat');
var assert = require('assert');

var arr = [1, [2], [], 3, [[4]]];

assert.deepEqual(flat(arr, 1), [1, 2, 3, [4]]); //array flattened up to 1 level

Moreover, in an instance where Array#flat is not present, you can use the following code:

var flat = require('array.prototype.flat');
var assert = require('assert');
/* when Array#flat is not present */
delete Array.prototype.flat;
var shimmedFlat = flat.shim();

assert.equal(shimmedFlat, flat.getPolyfill());

Finally, when Array#flat is present, the following code can be used:

var flat = require('array.prototype.flat');
var assert = require('assert');
/* when Array#flat is present */
var shimmedIncludes = flat.shim();

var mapper = function (x) { return [x, 1]; };

assert.equal(shimmedIncludes, Array.prototype.flat);
assert.deepEqual(arr.flat(mapper), flat(arr, mapper));

Where are the array.prototype.flat docs?

The comprehensive documentation and information about array.prototype.flat can be found in the README file of the package on GitHub. The URL is git://github.com/es-shims/Array.prototype.flat.git. One can also refer to the es-shim API interface for additional understanding on how to use the package. There, you will find all the necessary instructions on using and understanding this library, sample usage patterns, installation instructions, and information regarding the test suite.