Converts a string into camel case.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
After splitting into words, this function joins them and creates a camel case string.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word. (At a result, this function returns a string converted into lower case, e.g. abc123
).
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be converted. |
A string converted into camel case.
Type: string
Splits a string into alphanumeric words.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be splitted. |
An array of splitted words.
Type: Array
Joins alphanumeric words and creates a camel case string.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
words | Array | An array of an alphanumeric words to be joined. |
A camel case string.
Type: string
Converts a string into constant case.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
After splitting into words, this function joins them and creates a constant case string.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word. (At a result, this function returns a string converted into upper case, e.g. ABC123
).
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be converted. |
A string converted into constant case.
Type: string
Splits a string into alphanumeric words.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be splitted. |
An array of splitted words.
Type: Array
Joins alphanumeric words and creates a constant case string.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
words | Array | An array of an alphanumeric words to be joined. |
A constant case string.
Type: string
Checks if string ends with target.
If length is specified, this function ends comparison at index length - 1
.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
string | string | The string to be checked. |
target | string | The string to search for. |
startIndex | number | The index to search from. |
True, if string ends with target, otherwise false.
Type: boolean
Is a set of functins to escape characters in a string.
This function set provides escapings for following syntaxes and formats:
In addition, the factory functions for two types of escaping are provided:
NOTE: These functions doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Escapes special characters of Regular Expression.
The special characters which are escaped are as follows: ^$\.*+?()[]{}|
.
The specification of the special characters of Regular Expression comes from ECMA-262 — 21.2 RegExp (Regular Expression) Objects.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
An escaped string.
Type: string
Escapes special characters of Regular Expression Character Class.
The special characters which are escaped are as follows: -^]\
.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
An escaped string.
Type: string
Escapes special characters of HTML entity to character references, etc.
The escape mapping for HTML entity is as follows:
source character | replaced text |
---|---|
'<' (\u003c) |
'<' |
'>' (\u003e) |
'>' |
'&' (\u0026) |
'&' |
' ' (\u0020) |
' ' |
'\n' (\u000a) |
'<br/>' |
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
An escaped string.
Type: string
Escapes special characters of HTML attributes to character references.
The escape mapping for HTML attribute is as follows:
source character | replaced text |
---|---|
'<' (\u003c) |
'<' |
'>' (\u003e) |
'>' |
'&' (\u0026) |
'&' |
'"' (\u0022) |
'"' |
"'" (\u0027) |
''' |
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
An escaped string.
Type: string
Creates an escape function which escapes special characters by preposition of an espacing character, for example:
var escape = fav.text.escape.byPreposition('\\', '"\'');
escape('escaping ", \' and \\.');
// => 'escaping \\", \\\' and \\\\.'
Parameter | Type | Description |
---|---|---|
escapingChar | string | The escaping character placed before special characters. This character is escaped, too. |
escapedChars | string | The special characters to be escaped. |
An escaping function.
Type: function
Creates an escape function which escapes special characters by replacement to corresponding strings, for examples:
var escape = fav.text.escape.byReplacement({ '"': '"', "'": ''' });
escape('escaping " and \'.');
// => 'escaping " and '.'
Parameter | Type | Description |
---|---|---|
escapingMap | object | The plain object of which keys and values are mappings of escaped characters and replaced strings. |
An escaping function.
Type: function
Converts a string into kebab case.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
After splitting into words, this function joins them and creates a kebab case string.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word. (At a result, this function returns a string converted into lower case, e.g. abc123
).
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be converted. |
A string converted into kebab case.
Type: string
Splits a string into alphanumeric words.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be splitted. |
An array of splitted words.
Type: Array
Joins alphanumeric words and creates a kebab case string.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
words | Array | An array of an alphanumeric words to be joined. |
A kebab case string.
Type: string
Pads padding on left and right sides of source to center it.
If length is less than the length of source, return source with no padding.
If padding is not specified, this function use a white space ('\u0020'
) as a padding.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
length | number | The length of the result text. (Optional, and source.length in default.) |
padding | string | The padding characters. (Optional, and ' ' in default.) |
The padded string.
Type: string
Pads padding on left side of source.
If length is less than the length of source, return source with no padding.
If padding is not specified, this function use a white space ('\u0020'
) as a padding.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data type.
NOTE: This function is different from String#padStart
at the point that this function uses a white space ('\u0020'
) as padding when specified null
or an empty string to padding.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
length | number | The length of the result text. (Optional, and source.length in default.) |
padding | string | The padding characters. (Optional, and ' ' in default.) |
The padded string.
Type: string
Pads padding on right side of source.
If length is less than the length of source, return source with no padding.
If padding is not specified, this function use a white space ('\u0020'
) as a padding.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data type.
NOTE: This function is different from String#padEnd
at the point that this function uses a white space ('\u0020'
) as padding when specified null
or an empty string to padding.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
length | number | The length of the result text. (Optional, and source.length in default.) |
padding | string | The padding characters. (Optional, and ' ' in default.) |
The padded string.
Type: string
Converts a string into pascal case.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
After splitting into words, this function joins them and creates a pascal case string.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be converted. |
A string converted into pascal case.
Type: string
Splits a string into alphanumeric words.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be splitted. |
An array of splitted words.
Type: Array
Joins alphanumeric words and creates a pascal case string.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
words | Array | An array of an alphanumeric words to be joined. |
A pascal case string.
Type: string
Repeat source ntimes times.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
source | string | The string to repeat. |
ntimes | number | The number of times to repeat. |
The repeated string.
Type: string
Converts a string into snake case.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
After splitting into words, this function joins them and creates a snake case string.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word. (At a result, this function returns a string converted into lower case, e.g. abc123
).
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be converted. |
A string converted into snake case.
Type: string
Splits a string into alphanumeric words.
This function trys to split text into words with non-alphanumeric characters first. If text does not contains non-alphanumeric character, this function trys to split text into words before capital letters.
If text is a string which is composed of either lower case characters and numerics only (e.g. abc123
), or upper case characters and numerics only (e.g. ABC123
), this function regards text as one word.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
text | string | A string to be splitted. |
An array of splitted words.
Type: Array
Joins alphanumeric words and creates a snake case string.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
words | Array | An array of an alphanumeric words to be joined. |
A snake case string.
Type: string
Checks if string starts with target. If startIndex is specified this function starts comparison from startIndex.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
string | string | The string to be checked. |
target | string | The string to search for. |
startIndex | number | The index to search from. |
True, if string starts with target, otherwise false.
Type: boolean
Removes leading and trailing white spaces or chars from source.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
chars | string | The characters to be trimmed. (Optional, and white space in default.) |
The trimmed string.
Type: string
Removes leading white spaces or chars from source.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
chars | string | The characters to be trimmed. (Optional, and white space in default.) |
The trimmed string.
Type: string
Removes trailing white spaces or chars from source.
NOTE: This function doesn't check data types of the arguments, and assumes that they are given as per the specific data types.
Parameter | Type | Description |
---|---|---|
source | string | The source string. |
chars | string | The characters to be trimmed. (Optional, and white space in default.) |
The trimmed string.
Type: string
Returns an unique string in the application.
This unique string is not fixed-length and uses characters: a-z0-9
.
This function creates an unique string with following methods:
new Date().getTime().toString(36) + <sequencial-number-in-application>.toString(36)
NOTE: On a browser, the string returned by this function is unique in only the window.
An unique string in the application.
Type: string