8cd8ec3d2f203d9227f96a0828f01fe575fcdbd7 This project is a lightweight library that extends the functionality of javascripts built in
String
type with some functions that may come in handy.
To get started, simply go into your project folder and run:
npm install @cenz/string-lib --save
This will install the string library into your application. To get access to the extended
functionallity that is provided by this library, add this to your index.js
or whatever you're
using as your applications main point of entry:
require('@cenz/string-lib')
- capitalize
- allCaps
- capitalizeWords
- oddCaps
- evenCaps
- removeExtraWhiteSpace
- kabobCase
- snakeCase
- camelCase
Capitalize the first letter of the current string.
"this".capitalize() -> "This"
Returns String The capitalized version of the current string.
Uppercase every character within the string.
"this".allCaps() -> "THIS"
Returns String The entire string all capitalized of the current string.
Uppercase every word within the string (Not including: the, in, a, an, and, but, for, at, by, from)
"this word".capitalizeWords() -> "This Word"
Returns String with every first character in every word capitalized of the current string.
Uppercase every other odd character not including white space.
"this".oddCaps() -> "tHiS"
Returns String of every odd character capitalized of the current string.
Uppercase every even character not including white space.
"this".evenCaps() -> "ThIs"
Returns String of every even character capitalized of the current string.
Remove any extra whitespace throughout the string.
" this word ".removeExtraWhiteSpace() -> "this word"
Returns String with all the extra white space removed.
Kabob case the current string if it has spaces.
"kabob this!".kabobCase() -> "kabob-this!"
Returns String that is a kabob cased version of the current string
Snake case the current string if it has spaces.
"snake case this!".snakeCase() -> "snake_case_this!"
Returns String that is a snake cased version of the current string
Convert the current string to camel case if it has spaces.
"camel case these words!".camelCase() -> "camelCaseTheseWords"
Returns String that is a camel cased version of the current string