map-keys-deep-lodash

1.2.4 • Public • Published

map-keys-deep-lodash

Map/rename keys recursively

Sometimes we need to map keys from an object recursively. map-keys-deep-lodash solves this and uses only lodash as external dependency.

The code for this module uses new features in the Javascript language, but the code is transpiled by Babel to ES2015 so most projects who needs it should be able to use it.

Install

Install with npm

$ npm i map-keys-deep-lodash --save

Usage

const mapKeysDeep = require("map-keys-deep-lodash");

mapKeysDeep({a: "b", c: "d", e: {c: "f", g: {c: "h"}}}, (value, key) => {
  if (key === "c") {
    return "zzz";
  }

  return key;
});
//=> {a: "b", zzz: "d", e: {zzz: "f", g: {zzz: "h"}}}

Related projects

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

License

Released under the MIT license.

Package Sidebar

Install

npm i map-keys-deep-lodash

Weekly Downloads

6,362

Version

1.2.4

License

MIT

Unpacked Size

4.42 kB

Total Files

4

Last publish

Collaborators

  • odynvolk