keys-transform
v1.3.0
Published
Recursive Transformation of object keys to lower, upper and camel case
Downloads
510
Maintainers
Readme
Features
- Recursive Object Keys Transformation to Lower, Upper, Camel and Snake Case
- Typescript Support
Installation
$ npm install keys-transform
$ yarn add keys-transform
Code Example
const {toLowerKeys, toUpperKeys, toCamelKeys, toSnakeKeys, changeKeys} = require('keys-transform');
const obj = {
"NAME_ME": "Nahid Chowdhury",
"AGE": 26,
"hobby": ["Coding", "singing"],
"job": {
"professional": "engineer",
"personal": null
},
"planet_Belongs": undefined,
"nesT": {
"dummy_me": {
"hellO": "world"
}
}
}
/**
* Lower case object keys recursively
* @param {Object} objectToCon
*/
console.log(toLowerKeys(obj));
/**
* Upper case object keys recursively
* @param {Object} objectToCon
*/
console.log(toUpperKeys(obj));
/**
* Camel case object keys recursively
* @param {Object} objectToCon
*/
console.log(toCamelKeys(obj));
/**
* Snake case object keys recursively
* @param {Object} objectToCon
*/
console.log(toSnakeKeys(obj));
/**
* Change object keys name recursively
* @param {Object} objectToCon
* @param {Object} changedKeys
*/
console.log(changeKeys(obj, {
"NAME_ME": "name",
"professional": "occupation"
}));
Stay in touch
- Author - Nahid Chowdhury
License
Keys-Transform is MIT licensed.