README
Snamel
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: obj2, to:'snakeCase')
snamel(data: obj1, to:'camelCase')
snamel(data: str1, to:'upperCase')
snamel(data: str2, to:'lowerCase')
snamel(data: str1, is:'lowerCase')
snamel(data: str2, is:'upperCase')
For more information about the transformation options check change-case documentation.
License
MIT © Kiko Beats