map-keys-deep-lodash
Version:
Map/rename keys recursively with lodash as only dependency.
57 lines (35 loc) • 1.28 kB
Markdown
> 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 with [npm](https://www.npmjs.com/)
```sh
$ npm i map-keys-deep-lodash --save
```
```js
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"}}}
```
* [lodash](https://github.com/lodash/lodash): The only external dependency. [more](https://github.com/lodash/lodash)
Install dev dependencies:
```sh
$ npm i -d && npm test
```
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/odynvolk/map-keys-deep-lodash/issues/new)
+ [github/odynvolk](https://github.com/odynvolk)
+ [github/goliney](https://github.com/goliney)
Released under the MIT license.