keys-transform
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Keys Transform

Features

  1. Recursive Object Keys Transformation to Lower, Upper, Camel and Snake Case
  2. 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

License

Keys-Transform is MIT licensed.

Package Sidebar

Install

npm i keys-transform

Weekly Downloads

44

Version

1.3.0

License

MIT

Unpacked Size

11.6 kB

Total Files

7

Last publish

Collaborators

  • nahidchowdhury