Core Modules and Functions - JavaScript API#
A brief overview of common methods that may be useful when writing any module.
Core
#
clone(object: Object): Object
#
Creates a deep-clone of the provided object by value, removing any references on the original element, including arrays. However, this does not clone references to non-plain objects, these instances will be copied by reference.
1 2 3 4 5 6 7 |
|
extend(base: Object, ...merge: Object[]): Object
#
Accepts an infinite amount of plain objects as parameters, values will be copied from the 2nd...nth object into the first object. The first parameter will be cloned and the resulting object is returned.
1 2 3 4 5 6 7 8 9 10 |
|
inherit(base: Object, target: Object, merge?: Object)
#
Derives the second object's prototype from the first object, afterwards the
derived class will pass the instanceof
check against the original class.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
isPlainObject(object: Object): boolean
#
Verifies if an object is a plain JavaScript object and not an object instance.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
triggerEvent(element: Element, eventName: string)
#
Creates and dispatches a synthetic JavaScript event on an element.
1 2 3 4 |
|
Language
#
add(key: string, value: string)
#
Registers a new phrase.
1 2 3 4 5 |
|
addObject(object: Object)
#
Registers a list of phrases using a plain object.
1 2 3 4 5 6 7 |
|
get(key: string, parameters?: Object): string
#
Retrieves a phrase by its key, optionally supporting basic template scripting
with dynamic variables passed using the parameters
object.
1 2 3 4 5 6 |
|
StringUtil
#
escapeHTML(str: string): string
#
Escapes special HTML characters by converting them into an HTML entity.
Character | Replacement |
---|---|
& |
& |
" |
" |
< |
< |
> |
> |
escapeRegExp(str: string): string
#
Escapes a list of characters that have a special meaning in regular expressions and could alter the behavior when embedded into regular expressions.
lcfirst(str: string): string
#
Makes a string's first character lowercase.
ucfirst(str: string): string
#
Makes a string's first character uppercase.
unescapeHTML(str: string): string
#
Converts some HTML entities into their original character. This is the reverse
function of escapeHTML()
.