This JavaScript library provides a set of utility functions for converting between different variable naming conventions, promoting readability and consistency in your code.
Hungarian Notation (e.g., strUserName) to:
- Camel Case (e.g., userName)
- Pascal Case (e.g., UserName)
- Snake Case (e.g., user_name)
Camel Case to:
- Pascal Case
- Snake Case
Pascal Case to:
- Camel Case
- Snake Case
Snake Case to:
- Camel Case
- Pascal Case
npm install @multi-kit/convention
The library exports several functions, each taking a string representing the variable name as input and returning the converted string:
import {
HungarianToCamel,
HungarianToPascal,
HungarianToSnake,
CamelToPascal,
CamelToSnake,
PascalToCamel,
PascalToSnake,
SnakeToCamel,
SnakeToPascal,
} from '@multi-kit/convention';
const hungarianName = 'strUserName';
console.log(HungarianToCamel(hungarianName)); // Output: userName
console.log(HungarianToPascal(hungarianName)); // Output: UserName
console.log(HungarianToSnake(hungarianName)); // Output: user_name
const camelCaseName = 'userPassword';
console.log(CamelToPascal(camelCaseName)); // Output: UserPassword
console.log(CamelToSnake(camelCaseName)); // Output: user_password
// ... and so on for other conversions
Improved Code Readability: Consistency in variable naming enhances code clarity and maintainability. Reduced Errors: Automatic conversion minimizes typos and inconsistencies that can lead to bugs. Flexibility: Supports various naming conventions for different coding styles or project requirements.
We welcome contributions to improve this library. Feel free to submit pull requests for bug fixes, feature enhancements, or additional conversion functions.
This project is licensed under the MIT License.