Global

Methods

arrayIsEquals(arrayA, arrayB, compareFct:) → {boolean}

Returns true iff arrays are equal.
Parameters:
Name Type Description
arrayA Array
arrayB Array
compareFct: function function (a, b) --> number
Source:
Returns:
Type
boolean

arrayRemoveFirst(array, value, compareFct:) → {boolean}

Remove from the array the first item equals to value according to compareFct. Returns true iff one item was removed.
Parameters:
Name Type Description
array Array
value
compareFct: function function (a, b) --> number
Source:
Returns:
Type
boolean

arrayShuffle(array)

Shuffle the array (in place) by Knuth algorithm.
Parameters:
Name Type Description
array Array
Source:

assert()

Assertion function. If its first parameter is true then does nothing, else prints to the console next parameters. If !isAssert() then always does nothing.
Source:

classHtmlTrueFalse(bool) → {String}

Returns a with class "true" and true symbol if bool, else with class "false" and false symbol.
Parameters:
Name Type Description
bool boolean
Source:
Returns:
Type
String

compare(a, b) → {integer}

If a < 0 then return -1, if a = 0 then return 0, if a > 0 then return 1.
Parameters:
Name Type Description
a object that can be compared with <
b object that can be compared with <
Source:
Returns:
-1, 0, 1
Type
integer

cssAddClass(htmlElement, name)

Add a CSS class to a HTML element (if doesn't exist yet).
Parameters:
Name Type Description
htmlElement HTMLElement
name String !== ""
Source:

cssRemoveClass(htmlElement, name)

Remove a CSS class to a HTML element (if exist).
Parameters:
Name Type Description
htmlElement HTMLElement
name String !== ""
Source:

cssSetClass(htmlElement, name, Boolean)

Add or remove a CSS class to a HTML element.
Parameters:
Name Type Description
htmlElement HTMLElement
name String !== ""
Boolean add
Source:

getRandom(min, max) → {number}

Returns a number between min (included) and max (excluded), choiced randomly.
Parameters:
Name Type Description
min number
max number
Source:
Returns:
Type
number

getRandomBoolean() → {boolean}

Returns false or true, choiced randomly.
Source:
Returns:
Type
boolean

getRandomInteger(min, max) → {number}

Returns a integer between min (included) and max (excluded), choiced randomly.
Parameters:
Name Type Description
min number
max number
Source:
Returns:
integer
Type
number

htmlTrueFalse(bool) → {String}

Returns a HTML entity for true or false.
Parameters:
Name Type Description
bool boolean
Source:
Returns:
Type
String

isAssert() → {boolean}

Returns true iff assertions are enabled iff window.ASSERT_ENABLED is defined.
Source:
Returns:
Type
boolean

isFloat0(x, epsilon) → {boolean}

Returns true iff |x| <= epsilon.
Parameters:
Name Type Default Description
x number
epsilon number 0.000001 >= 0
Source:
Returns:
Type
boolean

isFloatAlmostEqual(x, y, epsilon) → {boolean}

Returns true iff |x - y| <= max(|x|, |y|)*epsilon. Cf. "Relative epsilon comparisons" in https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
Parameters:
Name Type Default Description
x number
y number
epsilon number 0.0001 >= 0
Source:
Returns:
Type
boolean

isFloatEqual(x, y, epsilon) → {boolean}

Returns true iff |x - y| <= epsilon.
Parameters:
Name Type Default Description
x number
y number
epsilon number 0.000001 >= 0
Source:
Returns:
Type
boolean

s(n) → {String}

Returns "s" if n >= 2 else return "".
Parameters:
Name Type Description
n number
Source:
Returns:
Type
String

setUnion(setA, setB) → {Set}

Returns a new set union of setA and setB.
Parameters:
Name Type Description
setA Set
setB Set
Source:
Returns:
Type
Set

sortedArrayBisectionLeft(sorted, value, compareFct:) → {integer}

Returns the insertion point of the value in the array to maintain sorted order according to compareFct. Like https://docs.python.org/3/library/bisect.html#bisect.bisect_left
Parameters:
Name Type Description
sorted Array Array according to compareFct
value
compareFct: function function (a, b) --> boolean
Source:
Returns:
0 <= integer <= array.length
Type
integer

sortedArrayInsert(sorted, value, compareFct:)

Returns the insertion point of the value in the array to maintain sorted order according to compareFct. Like https://docs.python.org/3/library/bisect.html#bisect.insort_left
Parameters:
Name Type Description
sorted Array Array according to compareFct
value
compareFct: function function (a, b) --> number
Source:

strPad(x, length, pad)

Returns x in a string with left padding to have at least length characters.
Parameters:
Name Type Default Description
x
length Number > 0
pad String not empty
Source: