CUI.util.assert(condition, caller, description, debug)

Parameter Type Comment
condition Boolean Condition to evaluate
caller String The caller
description String Additional information
debug Map Debug Output

CUI.defaults.asserts determines whether an assert check is performed or not. Default is true.

CUI.defaults.asserts_alert determines, what happens in case of an assert:

  • debugger: Starts the debugger
  • js: Uses Javascript window.alert to display the assert.
  • cui: Uses CUI.problem to display
  • off: Surpresses the assert

In all cases, an window.Error is thrown. Default is off.


assert(typeof(myvar) == "string", "new MyClass", "myvar needs to be string", myvar: myvar)


Returns true if obj is undefined.


Returns true if obj is null. An object is null if it is undefined or null.


Returns true if obj is String.


Returns true if obj is empty. An object is empty, if it is null, "", false, [], or {}.


Returns true if obj is true. True is 1, true, "1" or "true".


Returns true if obj is false. False is 0, false, "0" or "false".


Returns true if obj is true or false.


Returns true if obj is instance of HTMLElement.


Returns true if obj is a number and and Integer.


Returns true if obj is a positive Integer.


Returns true if obj is a number and Float.


Returns true if obj is a CUI.Promise or CUI.Deferred.


Returns true if obj is considered a CUI-Content, that is HTMLElement, HTMLCollection, NodeList, Array, Function, or an object with a DOM-property which is an HTMLElement.


Returns true if obj is a CUI.Deferred.


Returns str escaped for use inside a RegExp.


Returns the name of the Function used to create obj.


Returns the parsed Integer or null if no Integer is received.


Checks str, if it is parses as Integer, returns the Integer, str otherwise.


Returns the str parsed as Float, or null if otherwise.

CUI.util.xor(a, b)

Returns a XOR b. Returns true if a or b are considered true, false if a and b are both true or false.

CUI.util.toHtml(str, space2nbsp)

Returns str HTML-escaped, replaces space chars with if second parameter is given.


Returns str converted from CamelCase to a dash-notation.

CUI.util.toCamel(str, include_first)

Returns str converted from dash-notation to CamelCase. include_first can be set to true, to also camel-case the first character.


Returns str suitable to be used as class name. Replaces _ to - and spaces to -.


Returns str suitable to be used in CSS, replaces - to .

CUI.util.removeFromArray(value, array, compFunc)

Removes value from array. Returns number of items removed.

A compFunc can be used to return _true _or _false _for each item in array. If compFunc is set, value is ignored.

CUI.util.pushOntoArray(value, array, compFunc)

Appends value to the given array, if is not already in array.

A compFunc can be used to return _true _or _false _on each item in array.

Returns the idx of the pushed or existing value.

CUI.util.idxInArray(value, array, compFunc)

Returns the index of the given value in array. -1 if not found.

A compFunc can be used to return _true _or _false _for each item in array. If compFunc is set, value is ignored.

CUI.util.findInArray(value, array, compFunc)

Returns the item in array either matching value or using the compFunc. This is a handy function for searching thru an Array of Maps, where you want to match a certain property of the Map values.

CUI.util.compareIndex(a, b)

Returns -1 if a < b, 1 if a > b and 0 otherwise.

CUI.util.copyObject(obj, deep)

Returns a copy of the obj. With deep set to true, a deep copy is created. For instances of CUI.Element the "copy" method is called.

Types which are copied:

  • string
  • number
  • boolean
  • function (as reference)
  • null
  • undefined
  • CUI.Element (copy method is called)
  • CUI.Dummy (as reference)
  • HTMLElement (as reference)
  • Map
  • Array

CUI.util.dump(obj, space)

Returns a String suitable for output in console.debug. This replaces all undefined and null values by "<undefined>" and "<null>" resp., and then calls JSON.stringify to obtain a printable String of obj.

space is passed to JSON.stringify to format the JSON, defaults to \t.


Uses window.alert to dump obj to a Javascript-Alert.


Returns Base64 encoded ASCII representation of the passed UCS-2 String.


Returns UCS-2 String representation from passed Base64 encoded ASCII.


Implements startsWith for Strings.


Implements endsWith for Strings.


Returns str escaped for use inside a RegExp.

results matching ""

    No results matching ""