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.
Install with npm
$ npm i map-keys-deep-lodash --save
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"}}}
Install dev dependencies:
$ npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Released under the MIT license.