Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CamelCase JS

String to CamelCase or CamelCase to string: foo-barfooBar

Install

$ npm install --save camelcasejs

Methods

  • CamelCase
    • Convert string/array to CamelCase format
  • DeCamelize
    • Convert CamelCase format to string

Examples

CamelCase

// Import
const { CamelCase } = require('camelcasejs');

CamelCase('foo-bar');
// Response = 'fooBar'

CamelCase('foo_bar');
// Response = 'fooBar'

CamelCase('Foo-Bar');
// Response = 'fooBar'

CamelCase('--foo.bar');
// Response = 'fooBar'

CamelCase('__foo__bar__');
// Response = 'fooBar'

CamelCase('foo bar');
// Response = 'fooBar'

Array

// Import
const { CamelCase } = require('camelcasejs');

CamelCase(['foo', 'bar']);
// Response = 'fooBar'

DeCamelize

// Import
const { DeCamelize } = require('camelcasejs');

DeCamelize('fooBar');
// Response = 'foo_bar'

DeCamelize('fooBarV9_2');
// Response = 'foo_bar_v9.2'

/* Custom separator */
DeCamelize('fooBar', '=');
// Response = 'foo=bar'

DeCamelize('fooBarV9_2', '-');
// Response = 'foo-bar-v9.2'

License

MIT © Julio Sansossio

About

String to CamelCase or CamelCase to string: `foo-bar` ⇄ `fooBar`

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages