just-map-keys
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

just-map-keys

Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.

🍦 Try it

npm install just-map-keys
yarn add just-map-keys

Map an object, predicate updates keys, receives (value, key, object)

import map from 'just-map-keys';

// predicate updates keys, receives (value, key, object)
map({a: 'cow', b: 'sheep', c: 'pig'}, (value) => value);
  // {cow: 'cow', sheep: 'sheep', pig: 'pig'}
map([4, 5, 6], (value, key) => key + 1); // {1: 4, 2: 5, 3: 6}
map({a: 3, b: 5, c: 9}, (value, key) => key + value); // {a3: 3, b5: 5, c9: 9}
map({a: 3, b: 5, c: 9}, (value, key, obj) => obj.b + value + key);
  // {'8a': 3, '10b': 5, '14c': 9}

Package Sidebar

Install

npm i just-map-keys

Weekly Downloads

1,892

Version

2.3.0

License

MIT

Unpacked Size

5.66 kB

Total Files

9

Last publish

Collaborators

  • angus-c