misc_utils
Source: functions.
Property
Property
exit
[Global] Exits the program (alias for process.exit)
Parameter
Name | Type | Optional | Description |
---|---|---|---|
exit_code |
(number or string) |
Yes |
Defaults to |
- Returns
-
void
Methods
corners(area) → number
Finds the number of corners in an area
Parameter
Name | Type | Optional | Description |
---|---|---|---|
area |
|
The area to find corners in |
- Returns
-
number
eq(a, b) → boolean
[Global] Checks a
and b
are equal. In theory this works for any two values,
whether they're primitives, arrays or some other object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
a |
any |
|
|
b |
any |
|
- Returns
-
boolean
len(value) → number
[Global] Tries to get the length property of value
otherwise tries to get size
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
any |
|
Value to get the length/size of |
- Returns
-
nullable number
neq(a, b) → boolean
[Global] Checks a
and b
are not equal (by negating misc_utils.eq
)
Parameters
Name | Type | Optional | Description |
---|---|---|---|
a |
any |
|
|
b |
any |
|
- Returns
-
boolean
pr(value) → T
[Global] Same as misc_utils.print
but niladic (so that it becomes a getter)
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
T |
|
Value to print |
- Returns
-
T
print(...values) → (T or Array of T)
[Global] Same as console.log
its arg(s)
Parameter
Name | Type | Optional | Description |
---|---|---|---|
values |
T |
|
Values to print Value can be repeated. |
- Returns
-
(T or Array of T)
range(a[, b][, step]) → Array of number
[Global] Creates the range [a, b)
in an array with an optional step size
Examples
range(4) // [0, 1, 2, 3]
range(2, 5) // [2, 3, 4]
range(1, 10, 2) // [1, 3, 5, 7, 9]
Parameters
Name | Type | Optional | Description |
---|---|---|---|
a |
number |
|
End of the range (if |
b |
number |
Yes |
End of the range (if provided, in which case Defaults to |
step |
number |
Yes |
Defaults to |
- Returns
-
Array of number
wrap(value) → Array of T
Wraps a value in a singleton list
Parameter
Name | Type | Optional | Description |
---|---|---|---|
value |
T |
|
Value to wrap |
- Returns
-
Array of T