StringUtils class

Helper class containing string utility methods.

Methods

ellipsis(string, number)

Truncate string with ...

ellipsisHash(string, number)

EllipsisHash - create truncated string with unique hash for the truncated part.

hash(string)

UniqueHash - create a unique hash from a string.

Method Details

ellipsis(string, number)

Truncate string with ...

static function ellipsis(text: string, length: number): string

Parameters

text

string

Text.

length

number

Length to truncate text.

Returns

string

Original string modified.

ellipsisHash(string, number)

EllipsisHash - create truncated string with unique hash for the truncated part.

static function ellipsisHash(text: string, length: number): string

Parameters

text

string

Text to truncate.

length

number

Length to truncate at.

Returns

string

The truncated string with unique hash for the truncated part.

hash(string)

UniqueHash - create a unique hash from a string.

static function hash(text: string): string

Parameters

text

string

Text to hash.

Returns

string

A string which is an unique hash.

Remarks

The source for this function was derived from the following article:

https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/