Skip to content

Convert strings to camelCase, snake_case, CONSTANT_CASE, and other useful code-cases

Notifications You must be signed in to change notification settings

tower-archive/strcase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tower String Case

Convert strings to camelCase, snake_case, CONSTANT_CASE, and other useful code-cases. < 0.4kb minified and gzipped.

Install

node:

npm install tower-strcase

browser:

component install tower/strcase

or use Browserify.

Usage

var strcase = require('tower-strcase')
  , cases = [
      'fooBar'
    , 'foo_bar'
    , 'FOO_BAR'
    , 'FooBar'
    , 'Foo.Bar'
    , 'Foo Bar'
    , 'foo-bar'
    , 'foo/bar'
    , 'foo.bar'
  ]

cases.forEach(function(string) {
  strcase.camelCase(string)      // "fooBar"
  strcase.snakeCase(string)      // "foo_bar"
  strcase.constantCase(string)   // "FOO_BAR"
  strcase.classCase(string)      // "FooBar"
  strcase.namespaceCase(string)  // "Foo.Bar"
  strcase.titleCase(string)      // "Foo Bar"
  strcase.paramCase(string)      // "foo-bar"
  strcase.pathCase(string)       // "foo/bar"
  strcase.dotCase(string)        // "foo.bar"
});

Test

mocha

License

MIT

About

Convert strings to camelCase, snake_case, CONSTANT_CASE, and other useful code-cases

Resources

Stars

Watchers

Forks

Packages

No packages published