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 |
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 |
Returns:
- Type
- Boolean
arrayShuffle(array)
Shuffle the array (in place)
by Knuth algorithm.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array |
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.
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 < |
Returns:
-1, 0, 1
- Type
- integer
cssAddClass(htmlElement, name)
Add the CSS class name to a HTML element (if doesn't exist yet).
Parameters:
Name | Type | Description |
---|---|---|
htmlElement |
HTMLElement | |
name |
String | !== "" |
cssHasClass(htmlElement, name) → {Boolean}
Returns true iff the HTML element has the CSS class name.
Parameters:
Name | Type | Description |
---|---|---|
htmlElement |
HTMLElement | |
name |
String | !== "" |
Returns:
- Type
- Boolean
cssInvertClass(htmlElement, name)
If the HTML element has the CSS class name
then remove it,
else add it.
Parameters:
Name | Type | Description |
---|---|---|
htmlElement |
HTMLElement | |
name |
String | !== "" |
cssRemoveClass(htmlElement, name)
Remove the CSS class name to a HTML element (if exist).
Parameters:
Name | Type | Description |
---|---|---|
htmlElement |
HTMLElement | |
name |
String | !== "" |
cssSetClass(htmlElement, name, add)
Add or remove a CSS class to a HTML element.
Parameters:
Name | Type | Description |
---|---|---|
htmlElement |
HTMLElement | |
name |
String | !== "" |
add |
Boolean |
getRandom(min, max) → {Number}
Returns a number between min (included) and max (excluded),
choiced randomly.
Parameters:
Name | Type | Description |
---|---|---|
min |
Number | |
max |
Number |
Returns:
- Type
- Number
getRandomBoolean() → {Boolean}
Returns false or true,
choiced randomly.
Returns:
- Type
- Boolean
getRandomInteger(min, max) → {integer}
Returns a integer between min (included) and max (excluded),
choiced randomly.
Parameters:
Name | Type | Description |
---|---|---|
min |
Number | |
max |
Number |
Returns:
- Type
- integer
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.
Returns:
- Type
- boolean
isFloat0(x, epsilon) → {Boolean}
Returns true iff |x| <= epsilon.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
x |
Number | ||
epsilon |
Number | 0.000001 | >= 0 |
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 |
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 |
Returns:
- Type
- Boolean
s(n) → {String}
Returns "s" if n >= 2
else return "".
Parameters:
Name | Type | Description |
---|---|---|
n |
Number |
Returns:
- Type
- String
setUnion(setA, setB) → {Set}
Returns a new set union of setA and setB.
Parameters:
Name | Type | Description |
---|---|---|
setA |
Set | |
setB |
Set |
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 |
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 |
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 |