@el3um4s/rename-keys
v0.0.2
Published
Replaces the names of multiple object keys with the values provided.
Downloads
6
Readme
renameKeys & renameKeysAll
Creates a new object from the specified object, where all the keys are in lowercase.
NPM link: @el3um4s/rename-keys
Install and use the package
To use the package in a project:
npm i @el3um4s/rename-keys
and then in a file:
import { renameKeys, renameKeysAll } from "@el3um4s/rename-keys";
const obj = {
foo: "hello",
bar: "john",
it: {
foo: "ciao",
bar: "giovanni",
},
};
const keysMap= { foo: "greeting", bar: "name" },
const lowerCaseObj = renameKeys(obj);
// {
// greeting: "hello",
// name: "john",
// it: {
// foo: "ciao",
// bar: "giovanni",
// },
// }
const lowerCaseAllObj = renameKeysAll(obj);
// {
// greeting: "hello",
// name: "john",
// it: {
// greeting: "ciao",
// name: "giovanni",
// },
// }