@multi-kit/convention
TypeScript icon, indicating that this package has built-in type declarations

0.0.20 • Public • Published

JavaScript Variable Naming Convention Converter

This JavaScript library provides a set of utility functions for converting between different variable naming conventions, promoting readability and consistency in your code.

Supported Conversions:

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

Installation:

npm install @multi-kit/convention

Usage:

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

Benefits:

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.

Contribution:

We welcome contributions to improve this library. Feel free to submit pull requests for bug fixes, feature enhancements, or additional conversion functions.

License:

This project is licensed under the MIT License.

/@multi-kit/convention/

    Package Sidebar

    Install

    npm i @multi-kit/convention

    Weekly Downloads

    116

    Version

    0.0.20

    License

    ISC

    Unpacked Size

    8.11 kB

    Total Files

    7

    Last publish

    Collaborators

    • wanglizhi