Skip to content

Class: StringUtil

String processing tool class

Constructors

Methods

Constructors

constructor

new StringUtil(): StringUtil

Returns

StringUtil

Methods

hasString

hasString(fields, str): number

Does the string exist

Parameters

NameTypeDescription
fieldsstring[]List of detected string
strstringsource string

Returns

number

Return the index position where it is located. If it does not exist, return -1

Defined in

src/util/StringUtil.ts:15


getEllipsis

getEllipsis(str, len?): string

Gets an ellipsis terminated string representation that exceeds the range

Parameters

NameTypeDefault valueDescription
stranyundefinedsource string
lennumber4range of string

Returns

string

result string

Defined in

src/util/StringUtil.ts:31


getURLName

getURLName(url): string

get name based on URL

Parameters

NameTypeDescription
urlstringsource url

Returns

string

name

Defined in

src/util/StringUtil.ts:43


getFileFormat

getFileFormat(url): string

get suffix of file name from url

Parameters

NameTypeDescription
urlstringsource url

Returns

string

suffix

Defined in

src/util/StringUtil.ts:57


readLineProperty

readLineProperty(line, data): void

get information stored in a string

Parameters

NameTypeDescription
linestringsource string
dataanyresult data reference

Returns

void

Defined in

src/util/StringUtil.ts:74


getPath

getPath(url): string

Parameters

NameType
urlstring

Returns

string

Defined in

src/util/StringUtil.ts:93


normalizePath

normalizePath(url): string

Parameters

NameType
urlstring

Returns

string

Defined in

src/util/StringUtil.ts:99


getStringList

getStringList(str, char?): string[]

Used to cut specified characters

Parameters

NameTypeDefault valueDescription
strstringundefinedsource string
charstring';'cut string

Returns

string[]

result string array

Defined in

src/util/StringUtil.ts:135


formatTime

formatTime(time): string[]

Format timestamp data

Parameters

NameTypeDescription
timenumbertimestamp

Returns

string[]

Defined in

src/util/StringUtil.ts:144


trim

trim(str): any

trim

Parameters

NameTypeDescription
stranysource string

Returns

any

result string

Defined in

src/util/StringUtil.ts:158


isEmpty

isEmpty(value): boolean

Determine if the string is empty, null, '' or 'null'

Parameters

NameTypeDescription
valueanysource string

Returns

boolean

boolean

Defined in

src/util/StringUtil.ts:167


strCut

strCut(str, len): string

Handle strings that exceed the length range, such as adding strings that exceed the range

Parameters

NameTypeDescription
stranysource string
lenanylength

Returns

string

result string

Defined in

src/util/StringUtil.ts:177


toQueryPair

toQueryPair(key, value, isEncodeURI?): string

According to the splicing request parameters

Parameters

NameTypeDefault valueDescription
keyanyundefinedkey string
valueanyundefinedvalue string
isEncodeURIbooleanfalseisEncodeURI

Returns

string

result string

Defined in

src/util/StringUtil.ts:207


stringFormat

stringFormat(str, ...params): string

format a string

Parameters

NameTypeDescription
strstringsource string
...paramsany[]Pass in a regular processing parameter array

Returns

string

result string

Defined in

src/util/StringUtil.ts:217


parseJson2String

parseJson2String(json, options?): string

Convert JSON objects to strings

Parameters

NameTypeDescription
jsonanyobject of json
options?any

Returns

string

result string

Defined in

src/util/StringUtil.ts:244


compareVersion

compareVersion(v1, v2): 1 | 0 | -1

Compatibility mode - version comparison

Parameters

NameTypeDescription
v1anyVersion 1
v2anyVersion 2

Returns

1 | 0 | -1

Returns 1, -1, or 0, indicating that the version number is greater, less, or equal, respectively

Defined in

src/util/StringUtil.ts:310


buildRandomCode

buildRandomCode(): string

Generate non repeating random string codes

Returns

string

result

Defined in

src/util/StringUtil.ts:340


UUID

UUID(): string

UUID

Returns

string

UUID

Defined in

src/util/StringUtil.ts:356


stringToHash

stringToHash(str): number

make hash code

Parameters

NameTypeDescription
stranysource value

Returns

number

hash code

Defined in

src/util/StringUtil.ts:369


parseUrl

parseUrl(base, url): string

Convert GLTF URL Address

Parameters

NameTypeDescription
basestringbaseURL
urlstringsource url

Returns

string

result url

Defined in

src/util/StringUtil.ts:386

Released under the MIT License