Class: StringUtil
String processing tool class
Constructors
Methods
- hasString
- getEllipsis
- getURLName
- getFileFormat
- readLineProperty
- getPath
- normalizePath
- getStringList
- formatTime
- trim
- isEmpty
- strCut
- toQueryPair
- stringFormat
- parseJson2String
- compareVersion
- buildRandomCode
- UUID
- stringToHash
- parseUrl
Constructors
constructor
• new StringUtil(): StringUtil
Returns
Methods
hasString
▸ hasString(fields
, str
): number
Does the string exist
Parameters
Name | Type | Description |
---|---|---|
fields | string [] | List of detected string |
str | string | source string |
Returns
number
Return the index position where it is located. If it does not exist, return -1
Defined in
getEllipsis
▸ getEllipsis(str
, len?
): string
Gets an ellipsis terminated string representation that exceeds the range
Parameters
Name | Type | Default value | Description |
---|---|---|---|
str | any | undefined | source string |
len | number | 4 | range of string |
Returns
string
result string
Defined in
getURLName
▸ getURLName(url
): string
get name based on URL
Parameters
Name | Type | Description |
---|---|---|
url | string | source url |
Returns
string
name
Defined in
getFileFormat
▸ getFileFormat(url
): string
get suffix of file name from url
Parameters
Name | Type | Description |
---|---|---|
url | string | source url |
Returns
string
suffix
Defined in
readLineProperty
▸ readLineProperty(line
, data
): void
get information stored in a string
Parameters
Name | Type | Description |
---|---|---|
line | string | source string |
data | any | result data reference |
Returns
void
Defined in
getPath
▸ getPath(url
): string
Parameters
Name | Type |
---|---|
url | string |
Returns
string
Defined in
normalizePath
▸ normalizePath(url
): string
Parameters
Name | Type |
---|---|
url | string |
Returns
string
Defined in
getStringList
▸ getStringList(str
, char?
): string
[]
Used to cut specified characters
Parameters
Name | Type | Default value | Description |
---|---|---|---|
str | string | undefined | source string |
char | string | ';' | cut string |
Returns
string
[]
result string array
Defined in
formatTime
▸ formatTime(time
): string
[]
Format timestamp data
Parameters
Name | Type | Description |
---|---|---|
time | number | timestamp |
Returns
string
[]
Defined in
trim
▸ trim(str
): any
trim
Parameters
Name | Type | Description |
---|---|---|
str | any | source string |
Returns
any
result string
Defined in
isEmpty
▸ isEmpty(value
): boolean
Determine if the string is empty, null, '' or 'null'
Parameters
Name | Type | Description |
---|---|---|
value | any | source string |
Returns
boolean
boolean
Defined in
strCut
▸ strCut(str
, len
): string
Handle strings that exceed the length range, such as adding strings that exceed the range
Parameters
Name | Type | Description |
---|---|---|
str | any | source string |
len | any | length |
Returns
string
result string
Defined in
toQueryPair
▸ toQueryPair(key
, value
, isEncodeURI?
): string
According to the splicing request parameters
Parameters
Name | Type | Default value | Description |
---|---|---|---|
key | any | undefined | key string |
value | any | undefined | value string |
isEncodeURI | boolean | false | isEncodeURI |
Returns
string
result string
Defined in
stringFormat
▸ stringFormat(str
, ...params
): string
format a string
Parameters
Name | Type | Description |
---|---|---|
str | string | source string |
...params | any [] | Pass in a regular processing parameter array |
Returns
string
result string
Defined in
parseJson2String
▸ parseJson2String(json
, options?
): string
Convert JSON objects to strings
Parameters
Name | Type | Description |
---|---|---|
json | any | object of json |
options? | any |
Returns
string
result string
Defined in
compareVersion
▸ compareVersion(v1
, v2
): 1
| 0
| -1
Compatibility mode - version comparison
Parameters
Name | Type | Description |
---|---|---|
v1 | any | Version 1 |
v2 | any | Version 2 |
Returns
1
| 0
| -1
Returns 1, -1, or 0, indicating that the version number is greater, less, or equal, respectively
Defined in
buildRandomCode
▸ buildRandomCode(): string
Generate non repeating random string codes
Returns
string
result
Defined in
UUID
▸ UUID(): string
UUID
Returns
string
UUID
Defined in
stringToHash
▸ stringToHash(str
): number
make hash code
Parameters
Name | Type | Description |
---|---|---|
str | any | source value |
Returns
number
hash code
Defined in
parseUrl
▸ parseUrl(base
, url
): string
Convert GLTF URL Address
Parameters
Name | Type | Description |
---|---|---|
base | string | baseURL |
url | string | source url |
Returns
string
result url