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

array.prototype.flatmap

Package Overview
Dependencies
4
Maintainers
1
Versions
11
Issues
File Explorer

Advanced tools

array.prototype.flatmap

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

    1.3.0latest

Version published
Maintainers
1
Weekly downloads
11,384,316
decreased by-3.99%

Weekly downloads

Readme

Source

array.prototype.flatmap Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES2019 spec-compliant Array.prototype.flatMap 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 spec.

Because Array.prototype.flatMap 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.flatmap

Usage/Examples

var flatMap = require('array.prototype.flatmap'); var assert = require('assert'); var arr = [1, [2], [], 3]; var results = flatMap(arr, function (x, i) { assert.equal(x, arr[i]); return x; }); assert.deepEqual(results, [1, 2, 3]); var flatMap = require('array.prototype.flatmap'); var assert = require('assert'); /* when Array#flatMap is not present */ delete Array.prototype.flatMap; var shimmedFlatMap = flatMap.shim(); var mapper = function (x) { return [x, 1]; }; assert.equal(shimmedFlatMap, flatMap.getPolyfill()); assert.deepEqual(arr.flatMap(mapper), flatMap(arr, mapper)); var flatMap = require('array.prototype.flatmap'); var assert = require('assert'); /* when Array#flatMap is present */ var shimmedIncludes = flatMap.shim(); var mapper = function (x) { return [x, 1]; }; assert.equal(shimmedIncludes, Array.prototype.flatMap); assert.deepEqual(arr.flatMap(mapper), flatMap(arr, mapper));

Tests

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

Keywords

FAQs

What is array.prototype.flatmap?

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

Is array.prototype.flatmap popular?

The npm package array.prototype.flatmap receives a total of 9,082,576 weekly downloads. As such, array.prototype.flatmap popularity was classified as popular.

Is array.prototype.flatmap well maintained?

We found that array.prototype.flatmap 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