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
- pascalCase
- snakeCase
- constantCase
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
snameldata: obj2to:'snakeCase'snameldata: obj1to:'camelCase'snameldata: str1to:'upperCase'snameldata: str2to:'lowerCase'snameldata: str1is:'lowerCase'snameldata: str2is:'upperCase'
For more information about the transformation options check change-case documentation.
License
MIT © Kiko Beats