map-x

0.0.4 • Public • Published

map-x

Auto detecting, non-destructive map for Object and Array

  • Auto detects Object or Array and applies the appropriate operation
  • Switches to native map, if available, in case of Array
  • Checks for hasOwnProperty in case of Object
  • Won't crash on missing arguments
  • Returns original input on missing handler

--

Usage:

Install with npm: npm install --save map-x


import mapx from 'map-x';
 
const square= value => value * value;
 
const arr= mapx( [1, 2, 3], square );
console.log( arr );
// [ 1, 4, 9 ]
 
const obj= mapx( {a: 1, b: 2, c: 3}, square );
console.log( obj );
// { a: 1, b: 4, c: 9 }

license

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.4
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.4
    2
  • 0.0.3
    0
  • 0.0.2
    0
  • 0.0.1
    0

Package Sidebar

Install

npm i map-x

Weekly Downloads

2

Version

0.0.4

License

GPL-3

Unpacked Size

4.72 kB

Total Files

6

Last publish

Collaborators

  • sygn