Methods
# camelcase(string) → {String}
Returns a string in camelcase after trimming it
Parameters:
Name | Type | Description |
---|---|---|
string |
String |
The camelcase string
String
Examples
camelcase(' This is a tesT ')
// thisIsATest
str(' This is a tesT ').camelcase().value
// thisIsATest
# capitalize(str) → {String}
Capitalizes a string after applying a trim to it
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
String
Examples
capitalize('test')
// Test
str('TEST').capitalize()
// Test
# count(str) → {Number}
Counts characters in a string
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Number of characters
Number
Examples
count('test')
// 4
str('test').length
// 4
str('test').count()
// 4
# endsWith(str, substring, posopt) → {Boolean}
Checks if a string ends with the provided substring
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | |||
substring |
String | |||
pos |
Number |
<optional> |
0 | Position to start checking. Defaults to 0 |
True / False
Boolean
Examples
endsWith('test', 'st')
// true
str('test').endsWith('st')
// true
# lower(str) → {String}
Transform str to lower case
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Lower cased string
String
Examples
lower('TEST')
// test
str('TEST').lower().value
// test
# slugify(str, delopt) → {String}
Slugifies a string
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | |||
del |
String |
<optional> |
- | Delimiter, defaults to '-' |
Slugified string
String
Examples
slugify(' This is a tesT ')
// this-is-a-test
slugify(' This is a tesT ', ':')
// this:is:a:test
str(' This is a tesT ').slugify().value
// this-is-a-test
# startsWith(str, substring, posopt) → {Boolean}
Checks if a string starts with the provided substring
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
str |
String | |||
substring |
String | |||
pos |
Number |
<optional> |
0 | Position to start checking. Defaults to 0 |
True / False
Boolean
Examples
startsWith('test', 'te')
// true
str('test').startsWith('te')
// true
# trim(str) → {String}
Trims a string by the right and by the left
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Trimmed string
String
Examples
trim(' This is a tesT ')
// This is a tesT
str(' This is a tesT ').trim().value
// This is a tesT
# upper(str) → {String}
Transform a string to uppercase
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Uppercased string
String
Examples
upper('test')
// TEST
str('test').upper().value
// TEST