convert string/object keys to equivalent case
npm install case-convertionconvert string or object keys to equivalent string case
const {convert_to_snake_case, SnakeCaseToCamelCase} = require("case-convertion");
>convert to snake_case
``
`
console.log(convert_to_snake_case({convertMeToSnakeCase: "value"})) // { convert_me_to_snake_case: 'value' }
console.log(convert_to_snake_case([{ConvertMeToSnakeCase: "value"}])) // [ { convert_me_to_snake_case: 'value' } ]
console.log(convert_to_snake_case("ConvertMeToSnakeCase")) // convert_me_to_snake_case
`
---
>convert to camelCase
``
console.log(SnakeCaseToCamelCase({convert_me_to_camel_case: "value"})) // { convertMeToCamelCase: 'value' }
console.log(SnakeCaseToCamelCase([{convert_me_to_camel_case: "value"}])) // [ { convertMeToCamelCase: 'value' } ]
console.log(SnakeCaseToCamelCase("convert_me_to_camel_case")) // convertMeToCamelCase
INSTALLATION
---
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 0.10 or higher is required.
If this is a brand new project, make sure to create a package.json first with the npm init command.
Installation is done using the npm install command:
>$ npm install case-convertion