0.10.13-b • Published 10 years ago

snamel v0.10.13-b

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

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: \, to: \])

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: \, to: \])

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: \, is: \])

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