2.0.0 • Published 7 months ago

camel-case-converter v2.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

camel-case-converter

convert Array Object String, Json to camelCase format from snake_case/snake-case format

usage exmaple

install

 npm i camel-case-converter 

toCamelCase

const { toCamelCase  } = require('camel-case-converter');


let simpleObject = {
  first_name: 'first name',
  last_name: 'last name',
};
simpleObject = toCamelCase(simpleObject);
console.log(simpleObject);

/* { firstName: 'first name', lastName: 'last name' } */


let nestedObject = {
  name: {
    first_name: 'first name',
    last_name: 'last name',
  },
};
nestedObject = toCamelCase(nestedObject);
console.log(nestedObject);

/* { name: { firstName: 'first name', lastName: 'last name' } } */


let array = [
  { country_code: 'IN', other_details: '...' },
  { country_code: 'US', other_details: '...' },
];
array = toCamelCase(array);
console.log(array);

/*
[
    { countryCode: 'IN', otherDetails: '...' },
    { countryCode: 'US', otherDetails: '...' }
  ]
*/

let string = 'hello_world';
string = toCamelCase(string);
console.log(string);

/* helloWorld */

toCamelCaseString

const { toCamelCaseString  } = require('camel-case-converter');


let string = 'hello_world';
string = toCamelCaseString(string);
console.log(string);

/* helloWorld */

let string = 'hello-world';
string = toCamelCaseString(string);
console.log(string);

/* helloWorld */
2.0.0

7 months ago

1.1.1

1 year ago

1.1.0

2 years ago

1.0.0

2 years ago