@xdream77/case-converter

1.0.8 • Public • Published

Node.js CI Test Node.js Version

case-converter

  • Converts cases from one to another.
  • Perfect to clean and unify your code.
  • Zero Dependency

Run example.js for live action.

Installation

npm i @xdream77/case-converter

Provided functions

  • toCamel
  • toKebab
  • toPascal
  • toSnake

Usage

const { toSnake, toCamel } = require('@xdream77/case-converter');

const str = 'This_is-myCamel';

console.log(toSnake(str)); // this_is_my_camel
console.log(toCamel(str)); // thisIsMyCamel

Bonus: Object keys

const { objectKeys, toCamel } = require('@xdream77/case-converter');

const obj = {
    MyMulti          : 'hello',
    'This_is-myCamel': 'isWeird',
    with_underscore  : 'isPossible',
    andAlsoCamels    : 'are supported'
};

console.log(objectKeys(obj, toCamel));
/**
{
  myMulti: 'hello',
  thisIsMyCamel: 'isWeird',
  withUnderscore: 'isPossible',
  andAlsoCamels: 'are supported'
}
 */

Package Sidebar

Install

npm i @xdream77/case-converter

Weekly Downloads

2

Version

1.0.8

License

ISC

Unpacked Size

9.22 kB

Total Files

12

Last publish

Collaborators

  • xdream77