Big update!Announcing Socket for GitHub 1.0. Learn more
Socket
BlogLoveFAQ
Install
Log in

array.prototype.flat

Package Overview
Dependencies
4
Maintainers
1
Versions
6
Issues
File Explorer

Advanced tools

array.prototype.flat

An ES2019 spec-compliant `Array.prototype.flat` shim/polyfill/replacement that works as far down as ES3.

    1.3.0latest

Version published
Maintainers
1
Weekly downloads
16,021,334
decreased by-0.32%

Weekly downloads

Readme

Source

array.prototype.flat Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES2019 spec-compliant Array.prototype.flat shim/polyfill/replacement that works as far down as ES3.

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

Because Array.prototype.flat depends on a receiver (the this value), the main export takes the array to operate on as the first argument.

Getting started

npm install --save array.prototype.flat

Usage/Examples

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]]); 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()); assert.deepEqual(arr.flat(), flat(arr)); 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));

Tests

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

Keywords

FAQs

What is array.prototype.flat?

An ES2019 spec-compliant `Array.prototype.flat` shim/polyfill/replacement that works as far down as ES3.

Is array.prototype.flat popular?

The npm package array.prototype.flat receives a total of 15,368,863 weekly downloads. As such, array.prototype.flat popularity was classified as popular.

Is array.prototype.flat well maintained?

We found that array.prototype.flat demonstrated a healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.

Last updated on 11 Apr 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc