Huge news!Announcing our $20M Series A led by Andreessen Horowitz.Learn more
Socket
Socket
Log inDemoInstall

array.prototype.map

Package Overview
Dependencies
58
Maintainers
1
Versions
7
Issues
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

array.prototype.map

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

    1.0.6latest
    GitHub
    npm

Version published
Maintainers
1
Weekly downloads
2,998,740
increased by9.85%

Weekly downloads

Changelog

Source

v1.0.6 - 2023-09-06

Commits

  • [Deps] update define-properties, es-abstract accd64a
  • [Dev Deps] update @es-shims/api, @ljharb/eslint-config, aud, tape d1d5cb1

Readme

Source

array.prototype.map Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES5 spec-compliant Array.prototype.map 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.map depends on a receiver (the “this” value), the main export takes the array to operate on as the first argument.

Example

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

assert.deepEqual(map([1, 1, 1], function (x) { return x + 1; }), [2, 2, 2]);
assert.deepEqual(map([1, 0, 1], function (x) { return x + 1; }), [2, 1, 2]);
var map = require('array.prototype.map');
var assert = require('assert');
/* when Array#map is not present */
delete Array.prototype.map;
var shimmedMap = map.shim();
assert.equal(shimmedMap, map.getPolyfill());
var arr = [1, 2, 3];
var add4 = function (x) { return x + 4; };
assert.deepEqual(arr.map(add4), map(arr, add4));
var map = require('array.prototype.map');
var assert = require('assert');
/* when Array#map is present */
var shimmedMap = map.shim();
assert.equal(shimmedMap, Array.prototype.map);
assert.deepEqual(arr.map(add4), map(arr, add4));

Tests

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

Keywords

FAQs

Last updated on 07 Sep 2023

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install
SocketSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc