A simple package to switch between multiple case standards effortlessly.
A simple package to switch between multiple case standards effortlessly.
While using the object related functions, make sure your object is not polluted with mixed cases for keys.
Errors, other than validations, are no longer thrown but console.error
ed. So, please be sure to check (error) logs before raising a bug on this.
npm install @paradoxinfinite/convert-case
# OR
npm i @paradoxinfinite/convert-case
const convertCase = require('@paradoxinfinite/convert-case');
// OR
import convertCase from '@paradoxinfinite/convert-case';
const camelCaseString = convertCase.snakeToCamel('hello_world');
console.log(camelCaseString);
// Outputs: helloWorld
Test Cases: I would really appreciate any help on writing test cases for this package. The more testing it gets, the better it will be.
Bug fixes and feature development: If you want to contribute to the code, feel free to raise a PR as long as it’s a minor change. For a major change, please open an issue and discuss it out before you raise a PR or even get started with coding!
Feature requests: Feature requests will be great, raise an issue with the feature template to let me know what feature you would like added.
Documentation: Documentation and examples are also an amazing way to contribute, so if you notice any mistakes or want to add more content to the docs, you are more than welcome to!
All examples assume you’ve installed and imported the package by following this.
console.log(snakeToCamel('convert_case'));
// Outputs: convertCase
console.log(snakeToKebab('convert_case'));
// Outputs: convert-case
console.log(snakeToPascal('convert_case'));
// Outputs: ConvertCase
console.log(kebabToCamel('convert-case'));
// Outputs: convertCase
console.log(kebabToSnake('convert-case'));
// Outputs: convert_case
console.log(kebabToPascal('convert-case'));
// Outputs: ConvertCase
console.log(pascalToCamel('ConvertCase'));
// Outputs: convertCase
console.log(pascalToSnake('ConvertCase'));
// Outputs: convert_case
console.log(pascalToKebab('ConvertCase'));
// Outputs: convert-case
console.log(camelToSnake('convertCase'));
// Outputs: convert_case
console.log(camelToKebab('convertCase'));
// Outputs: convert-case
console.log(camelToPascal('convertCase'));
// Outputs: ConvertCase
console.log(objSnakeToCamel({
key_one: 'random value',
key: 3
}));
// Outputs:
// {
// keyOne: 'random value',
// key: 3
// }
console.log(objSnakeToPascal({
key_one: 'random value',
key: 3
}));
// Outputs:
// {
// KeyOne: 'random value',
// Key: 3
// }
console.log(objSnakeToKebab({
key_one: 'random value',
key: 3
}));
// Outputs:
// {
// 'key-one': 'random value',
// key: 3
// }
console.log(objCamelToSnake({
keyOne: 'random value',
key: 3
}));
// Outputs:
// {
// key_one: 'random value',
// key: 3
// }
console.log(objCamelToPascal({
keyOne: 'random value',
key: 3
}));
// Outputs:
// {
// KeyOne: 'random value',
// Key: 3
// }
console.log(objCamelToKebab({
keyOne: 'random value',
key: 3
}));
// Outputs:
// {
// 'key-one': 'random value',
// key: 3
// }
console.log(objPascalToSnake({
KeyOne: 'random value',
Key: 3
}));
// Outputs:
// {
// key_one: 'random value',
// key: 3
// }
console.log(objPascalToCamel({
KeyOne: 'random value',
Key: 3
}));
// Outputs:
// {
// keyOne: 'random value',
// key: 3
// }
console.log(objPascalToKebab({
KeyOne: 'random value',
Key: 3
}));
// Outputs:
// {
// 'key-one': 'random value',
// key: 3
// }
console.log(objKebabToPascal({
'key-one': 'random value',
key: 3
}));
// Outputs:
// {
// KeyOne: 'random value',
// Key: 3
// }
console.log(objKebabToSnake({
'key-one': 'random value',
key: 3
}));
// Outputs:
// {
// key_one: 'random value',
// key: 3
// }
console.log(objKebabToCamel({
'key-one': 'random value',
key: 3
}));
// Outputs:
// {
// keyOne: 'random value',
// key: 3
// }