Members
(constant) BinarySearchTreeInstance
BinarySearchTreeInstance.add(1);
BinarySearchTreeInstance.add(0);
BinarySearchTreeInstance.delete(0);(constant) EventSystemInstance
- Source
// Normal Event
EventSystemInstance.on("test", (num1, num2) => { console.log(num1, num2); });
EventSystemInstance.emit("test", 1, 2);
EventSystemInstance.off("test");
EventSystemInstance.emit("test", 3, 4);// Once Event
EventSystemInstance.on("testOnce", (num1, num2) => { console.log("testOnceOn", num1, num2); });
EventSystemInstance.once("testOnce", (num1, num2) => { console.log("testOnceOnce", num1, num2); });
EventSystemInstance.emit("testOnce", 5, 6);(constant) MEGABYTE_IN_KILOBYTES :number
Represents the number of kilobytes in one megabyte.
- number
- Source
console.log(MEGABYTE_IN_KILOBYTES * 5); // 5120 -> (5 MB)Methods
allCharactersSame(string) → {boolean}
Check if all characters are equal in a string or a array Returns true if all characters are equal. And false if not.
| Name | Type | Description |
|---|---|---|
string | string | | string to check |
- Source
- Type:
- boolean
allCharactersSame("beep") // false
allCharactersSame("aaaaaaaaaaaa") // true
allCharactersSame("b") // true
allCharactersSame("") // true
allCharactersSame(["a", "a"]) // true
allCharactersSame(["beep", "beep"]) // true
allCharactersSame(["a", "b"]) // false
allCharactersSame([1, 1]); // true
allCharactersSame([1, 2]); // falseand(args) → {boolean}
Compare if there is truthy value. Return true if all values are truthy.
| Name | Type | Description |
|---|---|---|
args | any | values to check |
- Source
- Type:
- boolean
and(false, false, false); // false
and(true, false, false); // false
and(true, false, true); // false
and(true, true, true); // truebinary2Decimal(binary) → {number}
Convert a binary number to a decimal
| Name | Type | Description |
|---|---|---|
binary | string | the value to be converted |
- Source
- conversion decimal
- Type:
- number
binary2Decimal("101010"); // 42calcDistanceBetweenTwoPointObjects(point1, point2) → {number}
Calculates the distance between two point objects.
| Name | Type | Description |
|---|---|---|
point1 | object | The first point object with x and y properties. |
point2 | object | The second point object with x and y properties. |
The distance between two points.
- Type:
- number
calculateDistanceBetweenTwoPointObjects({ x: 0, y: 0 }, { x: 3, y: 4 }); // 5calcDistanceBetweenTwoPoints(x1, y1, x2, y2) → {number}
Calculates the distance between two points.
| Name | Type | Description |
|---|---|---|
x1 | number | The x-coordinate of the first point. |
y1 | number | The y-coordinate of the first point. |
x2 | number | The x-coordinate of the second point. |
y2 | number | The y-coordinate of the second point. |
The distance between two points.
- Type:
- number
calculateDistanceBetweenTwoPoints(0, 0, 3, 4); // 5choiceTrend(options) → {number}
This function will return the index of the random selected item of a array based in the passed probably
| Name | Type | Description |
|---|---|---|
options | Array.<number> |
- Source
returns the index of the selected
- Type:
- number
choiceTrend([0.25, 0.5, 0.25]); // 1choiceTrend([0.5, 0.5]); // 0choiceTrend([0.1, 0.9]); // 1choiceTrend([0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]); // 7clone(original) → {object|Array.<any>}
Return a copy/clone of the given array or object
Utils for array of object, or objects with Properties with objects, et...
| Name | Type | Description |
|---|---|---|
original | object | | the original object/array to copy/clone |
- Type:
- object |
Array.<any>
compare2Objects(object1, object2) → {boolean}
Compare if two object are equal
| Name | Type | Description |
|---|---|---|
object1 | * | the first object/array to compare |
object2 | * | the second object/array to compare |
- Source
- true if the two object are equal
- Type:
- boolean
compare2Objects({a:1, b:2}, {a: 1}); // false
compare2Objects({a:1, b:2}, {a: 1, b: 2 }); // truedecimal2Binary(decimal) → {string}
Convert a number to a binary
| Name | Type | Description |
|---|---|---|
decimal | number | the number to be converted |
- Source
- conversion binary string
- Type:
- string
decimal2binary(42); // "101010"divideEvenlyWithSpread(numberDivisionsopt, spreadopt) → {Array.<number>}
Returns a array of numbers with the spaced divisions. The division starts on 0
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
numberDivisions | number | <optional> | 3 | number of number to divide |
spread | number | <optional> | 5 | space between 0 and the last number |
- Source
An array of evenly spaced numbers.
- Type:
- Array.<number>
divideEvenlyWithSpread(10, 5); // [-5, -3.888888888888889, -2.7777777777777777, -1.6666666666666665, -0.5555555555555554, 0.5555555555555554, 1.666666666666667, 2.7777777777777777, 3.8888888888888893, 5]fibonacciCustomSequence(start, end) → {Array.<number>}
Create a fibonacci sequence starts and end with a given values
| Name | Type | Description |
|---|---|---|
start | number | number to start the sequence |
end | number | max number to stop |
- Source
- Type:
- Array.<number>
fibonacciCustomSequence(5, 20); // [5,10,15,25]fibonacciCustomSequence(10, 120); // [10,20,30,50,80,130]fibonacciCustomSequence(50); // [50,100,150]fibonacciSequence(times) → {Array.<number>}
Runs the fibonacci sequence for the given times
| Name | Type | Description |
|---|---|---|
times | number | number of times to run |
- Source
- Type:
- Array.<number>
fibonacci(2); // [0,1]fibonacci(5); // [0,1,1,2,3]fibonacci(10); // [0,1,1,2,3,5,8,13,21,34]fibonacciUntil(max) → {Array.<number>}
Runs the fibonacci sequence until the maximum given number
| Name | Type | Description |
|---|---|---|
max | number | max number to get |
- Source
- Type:
- Array.<number>
fibonacciUntil(2); // [0,1,1]fibonacciUntil(5); // [0,1,1,2,3]fibonacciUntil(100); // [0,1,1,2,3,5,8,13,21,34,55,89]getDate() → {Object}
Returns the date
- Source
- Type:
- Object
getDate() // {
time: 1653573577063,
milliseconds: 134,
seconds: 24,
minutes: 24,
hours: 15,
day: 31,
weekDay: 7,
week: 50,
month: 5,
year: 2022,
dateFormatted: "1/1/2021",
}getDateFormatted() → {string}
Return a string with a formatted date in Day-Month-Year system
- Source
- Type:
- string
getDateFormatted() // "1/1/2021"
getDateFormatted() // "26/5/2022"
getDateFormatted() // "25/12/2042"getDay() → {number}
Returns the day of the month (from 1-31)
- Source
current day
- Type:
- number
getDay() // 1
getDay() // 23
getDay() // 31getHours() → {number}
Returns the current hour (from 0-23)
- Source
current hours
- Type:
- number
getHours() // 4
getHours() // 23getMilliseconds() → {number}
Returns the current milliseconds (from 0-999)
- Source
current milliseconds
- Type:
- number
getMilliseconds() // 134
getMilliseconds() // 952getMinutes() → {number}
Returns the current minutes (from 0-59)
- Source
current minutes
- Type:
- number
getMinutes() // 0
getMinutes() // 24getMonth() → {number}
Returns the month (from 1-12)
- Source
current month
- Type:
- number
getDay() // 1
getDay() // 6
getDay() // 12getSeconds() → {number}
Returns the current seconds (from 0-59)
- Source
current seconds
- Type:
- number
getSeconds() // 0
getSeconds() // 24getTime() → {number}
Returns the number of milliseconds since midnight Jan 1 1970, and a specified date
- Source
- Type:
- number
getTime() // 1653573577063getVersion() → {String}
Returns the current version of the library
- Source
- Type:
- String
getVersion(); // "1.4.0"getWeek() → {number}
Returns the current week in the year
- Source
current week in the year
- Type:
- number
getWeek() // 21
getWeek() // 50getWeekDay() → {number}
Returns the current day of the week (from 1-7)
- Source
current day of the week
- Type:
- number
getWeekDay() // 1
getWeekDay() // 5
getWeekDay() // 7getYear() → {number}
Returns the year
- Source
current year
- Type:
- number
getDay() // 1970
getDay() // 2000
getDay() // 2042isFalsy(value) → {boolean}
Check if the given value is a falsy value
| Name | Type | Description |
|---|---|---|
value | * | the value to check |
- Source
- Type:
- boolean
isFalsy(false) // true
isFalsy("") // true
isFalsy(0) // true
isFalsy([]) // true
isFalsy({}) // true
isFalsy(null) // true
isFalsy(undefined) // true
isFalsy(NaN) // true
isFalsy("beep") // false
isFalsy(1) // false
isFalsy({dog:"Lua"}) // false
isFalsy(["Snoopy","Ninica","Lua"]) // false
isFalsy(console) // falseisObjectEmpty(obj) → {boolean}
Check is the given object is empty
| Name | Type | Description |
|---|---|---|
obj | Object | The object to check |
- Source
- Type:
- boolean
isObjectEmpty({}); // true
isObjectEmpty({beep: "beep"}); // falseisTruthy(value) → {boolean}
Check if the given value is a Truthy value
| Name | Type | Description |
|---|---|---|
value | * | the value to check |
- Source
- Type:
- boolean
isTruthy(false) // false
isTruthy("") // false
isTruthy(0) // false
isTruthy([]) // false
isTruthy({}) // false
isTruthy(null) // false
isTruthy(undefined) // false
isTruthy(NaN) // false
isTruthy("beep") // true
isTruthy(1) // true
isTruthy({dog:"Lua"}) // true
isTruthy(["Snoopy","Ninica","Lua"]) // true
isTruthy(console) // trueor(args) → {boolean}
Compare if one of the value are truthy. Return true if one are truthy.
| Name | Type | Description |
|---|---|---|
args | any | values to check |
- Source
- Type:
- boolean
or(false, false, false); // false
or(true, false, true); // true
or(false, true, false); // true
or(true, true, true); // truerandomColor() → {string}
Returns a random color hexadecimal
- Source
a new random color
- Type:
- string
randomColor() // '#243ff4'
randomColor() // '#64e30f'randomColor0X() → {string}
Returns a random color hexadecimal
- Source
a new random color
- Type:
- string
randomColor0X() // '0x53df30'
randomColor0X() // '0x7c2f15'randomFloat(minopt, maxopt, precisionopt) → {number}
Return a random float number between the given values and the given precision
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
min | number | <optional> | 0 | min value |
max | number | <optional> | 1 | max value |
precision | number | <optional> | 2 | the float precision |
- Source
- random float number
- Type:
- number
randomFloat(0, 1);
randomFloat(-10, 0, 5);
randomFloat(-550, 444);randomInt(min, max) → {number}
Return a random integer number between the given values and the given precision
| Name | Type | Description |
|---|---|---|
min | number | min value |
max | number | max value |
- Source
random integer number
- Type:
- number
randomInt(0, 1);
randomInt(-10, 0);
randomInt(-550, 444);randomNumber(min, max) → {number}
Return a random number between the given values and the given precision
| Name | Type | Description |
|---|---|---|
min | number | min value |
max | number | max value |
- Source
- random number
- Type:
- number
randomNumber(0, 1);
randomNumber(-10, 0, 5);
randomNumber(-550, 444);randomRGBAColor() → {string}
Export a random rgba color (red, green, blue, alpha)
- Source
- Type:
- string
randomRGBAColor() // 'rgba(73.67, 177.51, 5.37, 0.82158)'
randomRGBAColor() // 'rgba(187.17, 195.28, 28.24, 0.73586)'randomRGBColor() → {string}
Export a random rgb color (red, green, blue)
- Source
- Type:
- string
randomRGBColor() // 'rgb(67.77, 251.89, 163.64)'
randomRGBColor() // 'rgb(142.84, 37.61, 173.32)'randomString(options) → {string}
Generates a random string, with capital and small letters, numbers and symbols
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | Object | options to generate a random string Properties
|
- Source
- Type:
- string
randomString(); // yUeMTTvP+kO8randomString({numberCharacters: 6,numbers: false, symbols: true, capital: false, small: false,}); // [+"()‰randomString({numberCharacters: 3,numbers: false, symbols: true, capital: true, small: true,}); // TGmrandomWalk(steps, dimension) → {Array.<number>}
Generates a random walk in the specified dimension.
| Name | Type | Description |
|---|---|---|
steps | number | The number of steps to take in the random walk. |
dimension | number | The dimensionality of the random walk (1, 2, or 3). |
- Source
The coordinates of the random walk in the specified dimension.
- Type:
- Array.<number>
randomWalk(100, 2); // [x, y] -> [3, -2]
randomWalk(35, 3); // [x, y, z] -> [1, -5, 2]recursiveFibonacci(terms) → {number}
A other way to solve the fibonacci sequence, with recursion.
| Name | Type | Description |
|---|---|---|
terms | number | number of terms |
- Source
- Type:
- number
recursiveFibonacci(5); // 5recursiveFibonacci(8); // 21recursiveFibonacci(10); // 55reverseString(str) → {string}
Invert all letters from a given text
| Name | Type | Description |
|---|---|---|
str | string | the text to transform |
- Source
- Type:
- string
reverseString("beep"); // peebreverseString("Beep"); // peeBreverseString("Beep Boop"); // pooB peeBreverseString("beep boop 1 20"); // 02 1 poob peebsleep(time) → {any}
Pause the thread for the determined time
| Name | Type | Description |
|---|---|---|
time | number | time in ms to pause the thread |
- Type:
- any
sleep();
sleep(2000);(async function () {
console.log("Beep");
await sleep(5000);
console.log("Boop");
})();xor(value1, value2) → {boolean}
Return false if both values are truthy ou falsy.
| Name | Type | Description |
|---|---|---|
value1 | any | value 1 to compare |
value2 | any | value 2 to compare |
- Source
- Type:
- boolean
xor(false, false); // false
xor(true, false); // true
xor(false, true); // true
xor(true, true); // falseType Definitions
Point
- Object
| Name | Type | Description |
|---|---|---|
x | number | The X Coordinate |
y | number | The Y Coordinate |