Home Manual Reference Source Test Repository
public class | source

StringUtil

Provides common string utilities.

Static Member Summary

Static Public Members
public static get

Returns the SafeEntry constructor which is used by safeStringsObject and safeStringsPrependObject.

Static Method Summary

Static Public Methods
public static

compare(lhs: string, rhs: string): number

Compares two strings.

public static

incrementIndent(indentation: number, amount: number): number

Increments the indentation amount.

public static

indent(indentation: number, string: string): string

Creates an indentation string given the indentation amount.

public static

safeStringObject(string: string, object: object, accessor: string, newLine: number, appendString: string, tagFunction: function): string

Provides a way to output a given string value with concatenated data from safely accessing an objects data / entries given an accessor string which describes the entries to walk.

public static

safeStringsObject(object: object, entries: string | SafeEntry | Array<string | SafeEntry>): string

Provides a convenience method producing a block of safeStringObject results.

public static

safeStringsPrependObject(origPrepend: *, object: object, entries: string | SafeEntry | Array<string | SafeEntry>): string

Provides a convenience method producing a block of safeStringObject results with the option to prepend a given string.

public static

tagEscapeHTML(literal: Array<string>, values: Array<*>): string

Provides a tagged template method to escape HTML elements.

Static Public Members

public static get SafeEntry: SafeEntry: * source

Returns the SafeEntry constructor which is used by safeStringsObject and safeStringsPrependObject.

Return:

SafeEntry

Static Public Methods

public static compare(lhs: string, rhs: string): number source

Compares two strings.

Params:

NameTypeAttributeDescription
lhs string

Left-hand side.

rhs string

Right-hand side.

Return:

number

public static incrementIndent(indentation: number, amount: number): number source

Increments the indentation amount.

Params:

NameTypeAttributeDescription
indentation number

Current indentation amount.

amount number

(Optional) indentation amount; default: 3.

Return:

number

public static indent(indentation: number, string: string): string source

Creates an indentation string given the indentation amount.

Params:

NameTypeAttributeDescription
indentation number

Current indentation amount.

string string

A string to append.

Return:

string

public static safeStringObject(string: string, object: object, accessor: string, newLine: number, appendString: string, tagFunction: function): string source

Provides a way to output a given string value with concatenated data from safely accessing an objects data / entries given an accessor string which describes the entries to walk. To access deeper entries into the object format the accessor string with . between entries to walk.

Params:

NameTypeAttributeDescription
string string

A string to prepend to the object data received.

object object

An object to access entry data.

accessor string

A string describing the entries to access.

newLine number

(Optional) A number of new line characters to append; default: 1.

appendString string

(Optional) A string to potentially append; default: '';

tagFunction function

(Optional) A template tag function to apply; default: void 0;

Return:

string

public static safeStringsObject(object: object, entries: string | SafeEntry | Array<string | SafeEntry>): string source

Provides a convenience method producing a block of safeStringObject results.

Params:

NameTypeAttributeDescription
object object

An object to access entry data.

entries string | SafeEntry | Array<string | SafeEntry>

Multiple arrays or strings. If an entry is not a SafeEntry it will simply be appended. If the entry is an array then entries in this array correspond to the following parameters which are forwarded onto safeStringObject.

Return:

string

public static safeStringsPrependObject(origPrepend: *, object: object, entries: string | SafeEntry | Array<string | SafeEntry>): string source

Provides a convenience method producing a block of safeStringObject results with the option to prepend a given string.

Params:

NameTypeAttributeDescription
origPrepend *

An additional value to prepend to all results.

object object

An object to access entry data.

entries string | SafeEntry | Array<string | SafeEntry>

Multiple arrays or strings. If an entry is not a SafeEntry it will simply be appended. If the entry is an array then entries in this array correspond to the following parameters which are forwarded onto safeStringObject.

Return:

string

public static tagEscapeHTML(literal: Array<string>, values: Array<*>): string source

Provides a tagged template method to escape HTML elements.

Params:

NameTypeAttributeDescription
literal Array<string>

Literal components of template string.

values Array<*>

Values to substitute.

Return:

string