snamel

0.10.13-b • Public • Published

Snamel

Build Status Dependency status Dev Dependencies Status NPM Status Gittip

Convert Object and String Javascript types between different styles.

Install

npm install snamel --save

Usage

snamel = require 'snamel'

API

Objects

smael(data: <object>, to: <type>])

Convert the keys of a object in a standard format.

to can be:

  • camelCase
{
    helloWorld: 'hello world'
}
  • pascalCase
{
    HelloWorld: 'hello world'
}
  • snakeCase
{
    hello_world: 'hello world'
}
  • constantCase
{
    HELLO_WORLD: 'hello world'
}

Strings

smael(data: <object>, to: <type>])

to can be:

  • upperCase
//=> "TEST STRING"
  • lowerCase
//=> "test string"
  • upperCaseFirst
//=> "Test"
  • sentenceCase
//=> "test string"
  • titleCase
//=> "A Simple Test"
  • camelCase
//=> "testString"
  • pascalCase
//=> "TestString"
  • snakeCase
//=> "test_string"
  • paramCase
//=> "test-string"
  • dotCase
//=> "test.string"
  • pathCase
//=> "test/string"
  • constantCase
//=> "TEST_STRING"
  • swapCase
//=> "tEST sTRING"

smael(data: <object>, is: <type>])

is can be:

  • upperCase
  • lowerCase

and return true or false.

Examples

snamel(data: obj2to:'snakeCase')
snamel(data: obj1to:'camelCase')
snamel(data: str1to:'upperCase')
snamel(data: str2to:'lowerCase')
snamel(data: str1is:'lowerCase')
snamel(data: str2is:'upperCase')

For more information about the transformation options check change-case documentation.

License

MIT © Kiko Beats

Package Sidebar

Install

npm i snamel

Weekly Downloads

1

Version

0.10.13-b

License

MIT

Last publish

Collaborators

  • kikobeats