Package Exports
- map-arr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-arr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
map-arr 
A tiny (124b), faster alternative to native
Array.prototype.map
!
JavaScript's native Array.prototype.map
is (unfortunately) *much slower than standard for-loops.
This module has no dependencies and serves as a drop-in replacement for Node.js and the browser!
It is ES3-compatible, which means it will run on any browser and be the fastest version you can use.
Lastly, it is CommonJS & ES-Module friendly 🎉
Install
$ npm install --save map-arr
Usage
// import mapArr from 'map-arr';
const mapArr = require('map-arr');
mapArr(['foo', 'bar', 'baz'], el => {
return el + el;
});
//=> ['foofoo', 'barbar', 'bazbaz']
mapArr(['foo', 'bar', 'baz'], (el, idx) => {
return el + idx;
});
//=> ['foo0', 'bar1', 'baz2']
API
This module is a drop-in replacement for Array.prototype.map
, which means it has the same API and behavior!
Benchmarks
native
--> 141,953 ops/sec ±0.15% (95 runs sampled)
map-arr
--> 4,202,912 ops/sec ±0.72% (94 runs sampled)
arr-map
--> 3,820,479 ops/sec ±0.37% (96 runs sampled)
array-map
--> 135,490 ops/sec ±1.15% (92 runs sampled)
License
MIT © Luke Edwards