Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
array.prototype.map
Advanced tools
An ES5 spec-compliant `Array.prototype.map` shim/polyfill/replacement that works as far down as ES3.
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.
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));
Simply clone the repo, npm install
, and run npm test
v1.0.5 - 2022-11-03
c793092
npmignore
to autogenerate an npmignore file 6ec9705
eslint
, @ljharb/eslint-config
, @es-shims/api
, safe-publish-latest
, tape
7d2b675
define-properties
, es-abstract
884c2f1
2b6df28
01ccb07
1eec671
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, tape
b8ae81b
aud
, functions-have-names
, tape
6f2ccae
es-abstract
be80326
es-abstract
1450f7d
es-abstract
8195a0e
FAQs
An ES5 spec-compliant `Array.prototype.map` shim/polyfill/replacement that works as far down as ES3.
We found that array.prototype.map demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.