Members

(constant) BinarySearchTreeInstance

Example
BinarySearchTreeInstance.add(1);
BinarySearchTreeInstance.add(0);
BinarySearchTreeInstance.delete(0);

(constant) EventSystemInstance

Examples
// 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.

Type:
  • number
Example
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.

Parameters:
NameTypeDescription
stringstring | Array

string to check

Returns:
Type: 
boolean
Example
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]); // false

and(args) → {boolean}

Compare if there is truthy value. Return true if all values are truthy.

Parameters:
NameTypeDescription
argsany

values to check

Returns:
Type: 
boolean
Example
and(false, false, false); // false
and(true, false, false); // false
and(true, false, true); // false
and(true, true, true); // true

binary2Decimal(binary) → {number}

Convert a binary number to a decimal

Parameters:
NameTypeDescription
binarystring

the value to be converted

Returns:
  • conversion decimal
Type: 
number
Example
binary2Decimal("101010"); // 42

calcDistanceBetweenTwoPointObjects(point1, point2) → {number}

Calculates the distance between two point objects.

Parameters:
NameTypeDescription
point1object

The first point object with x and y properties.

point2object

The second point object with x and y properties.

Returns:

The distance between two points.

Type: 
number
Example
calculateDistanceBetweenTwoPointObjects({ x: 0, y: 0 }, { x: 3, y: 4 }); // 5

calcDistanceBetweenTwoPoints(x1, y1, x2, y2) → {number}

Calculates the distance between two points.

Parameters:
NameTypeDescription
x1number

The x-coordinate of the first point.

y1number

The y-coordinate of the first point.

x2number

The x-coordinate of the second point.

y2number

The y-coordinate of the second point.

Returns:

The distance between two points.

Type: 
number
Example
calculateDistanceBetweenTwoPoints(0, 0, 3, 4); // 5

choiceTrend(options) → {number}

This function will return the index of the random selected item of a array based in the passed probably

Parameters:
NameTypeDescription
optionsArray.<number>
Returns:

returns the index of the selected

Type: 
number
Examples
choiceTrend([0.25, 0.5, 0.25]); // 1
choiceTrend([0.5, 0.5]); // 0
choiceTrend([0.1, 0.9]); // 1
choiceTrend([0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]); // 7

clone(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...

Parameters:
NameTypeDescription
originalobject | Array.<any>

the original object/array to copy/clone

Returns:
Type: 
object | Array.<any>

compare2Objects(object1, object2) → {boolean}

Compare if two object are equal

Parameters:
NameTypeDescription
object1*

the first object/array to compare

object2*

the second object/array to compare

Returns:
  • true if the two object are equal
Type: 
boolean
Example
compare2Objects({a:1, b:2}, {a: 1}); // false
compare2Objects({a:1, b:2}, {a: 1, b: 2 }); // true

decimal2Binary(decimal) → {string}

Convert a number to a binary

Parameters:
NameTypeDescription
decimalnumber

the number to be converted

Returns:
  • conversion binary string
Type: 
string
Example
decimal2binary(42); // "101010"

divideEvenlyWithSpread(numberDivisionsopt, spreadopt) → {Array.<number>}

Returns a array of numbers with the spaced divisions. The division starts on 0

Parameters:
NameTypeAttributesDefaultDescription
numberDivisionsnumber<optional>
3

number of number to divide

spreadnumber<optional>
5

space between 0 and the last number

Returns:

An array of evenly spaced numbers.

Type: 
Array.<number>
Example
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

Parameters:
NameTypeDescription
startnumber

number to start the sequence

endnumber

max number to stop

Returns:
Type: 
Array.<number>
Examples
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

Parameters:
NameTypeDescription
timesnumber

number of times to run

Returns:
Type: 
Array.<number>
Examples
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

Parameters:
NameTypeDescription
maxnumber

max number to get

Returns:
Type: 
Array.<number>
Examples
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

Returns:
Type: 
Object
Example
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

Returns:
Type: 
string
Example
getDateFormatted() // "1/1/2021"
getDateFormatted() // "26/5/2022"
getDateFormatted() // "25/12/2042"

getDay() → {number}

Returns the day of the month (from 1-31)

Returns:

current day

Type: 
number
Example
getDay() // 1
getDay() // 23
getDay() // 31

getHours() → {number}

Returns the current hour (from 0-23)

Returns:

current hours

Type: 
number
Example
getHours() // 4
getHours() // 23

getMilliseconds() → {number}

Returns the current milliseconds (from 0-999)

Returns:

current milliseconds

Type: 
number
Example
getMilliseconds() // 134
getMilliseconds() // 952

getMinutes() → {number}

Returns the current minutes (from 0-59)

Returns:

current minutes

Type: 
number
Example
getMinutes() // 0
getMinutes() // 24

getMonth() → {number}

Returns the month (from 1-12)

Returns:

current month

Type: 
number
Example
getDay() // 1
getDay() // 6
getDay() // 12

getSeconds() → {number}

Returns the current seconds (from 0-59)

Returns:

current seconds

Type: 
number
Example
getSeconds() // 0
getSeconds() // 24

getTime() → {number}

Returns the number of milliseconds since midnight Jan 1 1970, and a specified date

Returns:
Type: 
number
Example
getTime() // 1653573577063

getVersion() → {String}

Returns the current version of the library

Returns:
Type: 
String
Example
getVersion(); // "1.4.0"

getWeek() → {number}

Returns the current week in the year

Returns:

current week in the year

Type: 
number
Example
getWeek() // 21
getWeek() // 50

getWeekDay() → {number}

Returns the current day of the week (from 1-7)

Returns:

current day of the week

Type: 
number
Example
getWeekDay() // 1
getWeekDay() // 5
getWeekDay() // 7

getYear() → {number}

Returns the year

Returns:

current year

Type: 
number
Example
getDay() // 1970
getDay() // 2000
getDay() // 2042

isFalsy(value) → {boolean}

Check if the given value is a falsy value

Parameters:
NameTypeDescription
value*

the value to check

Returns:
Type: 
boolean
Example
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) // false

isObjectEmpty(obj) → {boolean}

Check is the given object is empty

Parameters:
NameTypeDescription
objObject

The object to check

Returns:
Type: 
boolean
Example
isObjectEmpty({}); // true
isObjectEmpty({beep: "beep"}); // false

isTruthy(value) → {boolean}

Check if the given value is a Truthy value

Parameters:
NameTypeDescription
value*

the value to check

Returns:
Type: 
boolean
Example
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) // true

or(args) → {boolean}

Compare if one of the value are truthy. Return true if one are truthy.

Parameters:
NameTypeDescription
argsany

values to check

Returns:
Type: 
boolean
Example
or(false, false, false); // false
or(true, false, true); // true
or(false, true, false); // true
or(true, true, true); // true

randomColor() → {string}

Returns a random color hexadecimal

Returns:

a new random color

Type: 
string
Example
randomColor() // '#243ff4'
randomColor() // '#64e30f'

randomColor0X() → {string}

Returns a random color hexadecimal

Returns:

a new random color

Type: 
string
Example
randomColor0X() // '0x53df30'
randomColor0X() // '0x7c2f15'

randomFloat(minopt, maxopt, precisionopt) → {number}

Return a random float number between the given values and the given precision

Parameters:
NameTypeAttributesDefaultDescription
minnumber<optional>
0

min value

maxnumber<optional>
1

max value

precisionnumber<optional>
2

the float precision

Returns:
  • random float number
Type: 
number
Example
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

Parameters:
NameTypeDescription
minnumber

min value

maxnumber

max value

Returns:

random integer number

Type: 
number
Example
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

Parameters:
NameTypeDescription
minnumber

min value

maxnumber

max value

Returns:
  • random number
Type: 
number
Example
randomNumber(0, 1);
randomNumber(-10, 0, 5);
randomNumber(-550, 444);

randomRGBAColor() → {string}

Export a random rgba color (red, green, blue, alpha)

Returns:
Type: 
string
Example
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)

Returns:
Type: 
string
Example
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

Parameters:
NameTypeDescription
optionsObject

options to generate a random string

Properties
NameTypeDescription
numberCharactersnumber

number of characters that string will have

capitalboolean

enable to generate character with capital letters

smallboolean

enable to generate character with small letters

numbersboolean

enable to generate character with numbers

symbolsboolean

enable to generate character with symbols

Returns:
Type: 
string
Examples
randomString(); // yUeMTTvP+kO8
randomString({numberCharacters: 6,numbers: false, symbols: true, capital: false, small: false,}); // [+"()‰
randomString({numberCharacters: 3,numbers: false, symbols: true, capital: true, small: true,}); // TGm

randomWalk(steps, dimension) → {Array.<number>}

Generates a random walk in the specified dimension.

Parameters:
NameTypeDescription
stepsnumber

The number of steps to take in the random walk.

dimensionnumber

The dimensionality of the random walk (1, 2, or 3).

Returns:

The coordinates of the random walk in the specified dimension.

Type: 
Array.<number>
Example
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.

Parameters:
NameTypeDescription
termsnumber

number of terms

Returns:
Type: 
number
Examples
recursiveFibonacci(5); // 5
recursiveFibonacci(8); // 21
recursiveFibonacci(10); // 55

reverseString(str) → {string}

Invert all letters from a given text

Parameters:
NameTypeDescription
strstring

the text to transform

Returns:
Type: 
string
Examples
reverseString("beep"); // peeb
reverseString("Beep"); // peeB
reverseString("Beep Boop"); // pooB peeB
reverseString("beep boop 1 20"); // 02 1 poob peeb

sleep(time) → {any}

Pause the thread for the determined time

Parameters:
NameTypeDescription
timenumber

time in ms to pause the thread

Returns:
Type: 
any
Examples
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.

Parameters:
NameTypeDescription
value1any

value 1 to compare

value2any

value 2 to compare

Returns:
Type: 
boolean
Example
xor(false, false); // false
xor(true, false); // true
xor(false, true); // true
xor(true, true); // false

Type Definitions

Point

Type:
  • Object
Properties
NameTypeDescription
xnumber

The X Coordinate

ynumber

The Y Coordinate