Global

Members

(constant) array2range

Description:
  • Converts a sorted array of numbers into a list of ranges. Consecutive numbers are grouped into a single range [min, max]. Isolated numbers are represented as [num, num].
Source:
Converts a sorted array of numbers into a list of ranges. Consecutive numbers are grouped into a single range [min, max]. Isolated numbers are represented as [num, num].

(constant) arrayHistogram

Description:
  • Generates a Map with unique elements and their occurring frequencies. Transforms an array into a Map of (key -> quantity) using an optional mapping callback.
Source:
Generates a Map with unique elements and their occurring frequencies. Transforms an array into a Map of (key -> quantity) using an optional mapping callback.

(constant) bijective2num

Description:
  • Converts a bijective base-k string to a number.
Source:
Converts a bijective base-k string to a number.

(constant) bijective2numBI

Description:
  • Converts a bijective base-k string to a BigInt.
Source:
Converts a bijective base-k string to a BigInt.

(constant) bin2gray

Description:
  • Transforms an array of binary bits into Gray Code.
Source:
Transforms an array of binary bits into Gray Code.

(constant) binarySearchArr

Description:
  • Performs a binary search for an exact element in a sorted array.
Source:
Performs a binary search for an exact element in a sorted array.

(constant) binarySearchGE

Description:
  • Performs a binary search for the smallest element greater than or equal to the target.
Source:
Performs a binary search for the smallest element greater than or equal to the target.

(constant) binarySearchLE

Description:
  • Performs a binary search for the largest element less than or equal to the target.
Source:
Performs a binary search for the largest element less than or equal to the target.

(constant) binarySearchRangeIncl

Description:
  • Performs a binary search for a range of elements inclusive of the target. Uses binarySearchGE and binarySearchLE.
Source:
Performs a binary search for a range of elements inclusive of the target. Uses binarySearchGE and binarySearchLE.

(constant) combinations

Description:
  • Returns all combinations synchronously. WARNING: Calling this with mathematically large sets will overflow local RAM.
Source:
Returns all combinations synchronously. WARNING: Calling this with mathematically large sets will overflow local RAM.

(constant) combinationsIterator

Description:
  • Generates all possible combinations of size n from a set of size k without repetition. Yields arrays of indices representing the current combination. Optimized with lexicographic progression to skip invalid states, running in O(1) amortized time per sequence instead of O(k^n).
Source:
Generates all possible combinations of size n from a set of size k without repetition. Yields arrays of indices representing the current combination. Optimized with lexicographic progression to skip invalid states, running in O(1) amortized time per sequence instead of O(k^n).

(constant) consumeIteratorNonBlocking

Description:
  • Consume iterator values asynchronously utilizing macro-task queue to prevent Event Loop blocking.
Source:
Consume iterator values asynchronously utilizing macro-task queue to prevent Event Loop blocking.

(constant) copyCase

Description:
  • Copies the case pattern from one string to another. Handles lower case, upper case, and capitalized strings.
Source:
Copies the case pattern from one string to another. Handles lower case, upper case, and capitalized strings.

(constant) crossProduct

Description:
  • Pure 3D Math Engine for Arcball/Trackball raw matrix transformations
Source:
Pure 3D Math Engine for Arcball/Trackball raw matrix transformations

(constant) egcd

Description:
  • Extended Euclidean Algorithm. Computes the greatest common divisor (GCD) of a and b, and the coefficients of Bézout's identity.
Source:
Extended Euclidean Algorithm. Computes the greatest common divisor (GCD) of a and b, and the coefficients of Bézout's identity.

(constant) factors

Description:
  • Calculates the prime factorization of a number.
Source:
Calculates the prime factorization of a number.

(constant) factorsBI

Description:
  • Calculates the prime factorization of a BigInt.
Source:
Calculates the prime factorization of a BigInt.

(constant) formatBigNumber

Description:
  • Formats a BigNumber, Number or string representation of a number by separating thousands with a provided separator.
Source:
Formats a BigNumber, Number or string representation of a number by separating thousands with a provided separator.

(constant) formatBigNumberBI

Description:
  • Formats a BigNumber, Number or string representation of a number by separating thousands with a provided separator. (Alias for BigInt logic)
Source:
Formats a BigNumber, Number or string representation of a number by separating thousands with a provided separator. (Alias for BigInt logic)

(constant) fromBase64

Description:
  • Decodes a Base64 string. Handles Unicode characters correctly.
Source:
Decodes a Base64 string. Handles Unicode characters correctly.

(constant) fromBase64Url

Description:
  • Decodes a Base64Url string. Replaces '-' with '+' and '_' with '/'.
Source:
Decodes a Base64Url string. Replaces '-' with '+' and '_' with '/'.

(constant) gcd

Description:
  • Calculates the Greatest Common Divisor (GCD) of two numbers.
Source:
Calculates the Greatest Common Divisor (GCD) of two numbers.

(constant) gcdBI

Description:
  • Calculates the Greatest Common Divisor (GCD) of two BigInts.
Source:
Calculates the Greatest Common Divisor (GCD) of two BigInts.

(constant) getType

Description:
  • Returns the type of the value as a lowercase string. More specific than the typeof operator (e.g., distinguishes 'array', 'null', 'date').
Source:
Returns the type of the value as a lowercase string. More specific than the typeof operator (e.g., distinguishes 'array', 'null', 'date').

(constant) gpn

Description:
  • Generalized Pentagonal Numbers (GPN). Formula: P_k = k(3k - 1) / 2 The sequence includes k = 0, 1, -1, 2, -2, 3, -3... https://oeis.org/A001318
Source:
Generalized Pentagonal Numbers (GPN). Formula: P_k = k(3k - 1) / 2 The sequence includes k = 0, 1, -1, 2, -2, 3, -3... https://oeis.org/A001318

(constant) gpnBI

Description:
  • Generalized Pentagonal Numbers (GPN) - BigInt version.
Source:
Generalized Pentagonal Numbers (GPN) - BigInt version.

(constant) gray2bin

Description:
  • Decodes a Gray code array back into standard binary formatting.
Source:
Decodes a Gray code array back into standard binary formatting.

(constant) heronsFormula

Description:
  • Calculates the area of a triangle given the lengths of its three sides. Uses Heron's formula.
Source:
Calculates the area of a triangle given the lengths of its three sides. Uses Heron's formula.

(constant) heronsFormulaBI

Description:
  • Calculates the area of a triangle given the lengths of its three sides (BigInt version). Returns the integer part of the area (truncated).
Source:
Calculates the area of a triangle given the lengths of its three sides (BigInt version). Returns the integer part of the area (truncated).

(constant) lcm

Description:
  • Calculates the Least Common Multiple (LCM) of two numbers.
Source:
Calculates the Least Common Multiple (LCM) of two numbers.

(constant) lcmBI

Description:
  • Calculates the Least Common Multiple (LCM) of two BigInts.
Source:
Calculates the Least Common Multiple (LCM) of two BigInts.

(constant) matrixAsArray

Description:
  • Represents a 2D matrix as a flat 1D array using a Proxy. Allows accessing elements using a single index (row-major order).
Source:
Represents a 2D matrix as a flat 1D array using a Proxy. Allows accessing elements using a single index (row-major order).

(constant) memoize

Description:
  • Creates a memoized version of a function. Uses a tree structure to store results based on arguments. Compares arguments by reference.
Source:
Creates a memoized version of a function. Uses a tree structure to store results based on arguments. Compares arguments by reference.

(constant) mod

Description:
  • Calculates the modulo of two numbers (Python-like behavior for negative numbers).
Source:
Calculates the modulo of two numbers (Python-like behavior for negative numbers).

(constant) modBI

Description:
  • Calculates the modulo of two BigInts (Python-like behavior for negative numbers).
Source:
Calculates the modulo of two BigInts (Python-like behavior for negative numbers).

(constant) nChooseK

Description:
  • Newton's formula (Binomial Coefficient) n choose k. Evaluates the number of possible combinations. Built strictly on BigInt and optimized iterative fraction reduction to prevent RAM and precision loss during massive factorial expansions.
Source:
Newton's formula (Binomial Coefficient) n choose k. Evaluates the number of possible combinations. Built strictly on BigInt and optimized iterative fraction reduction to prevent RAM and precision loss during massive factorial expansions.

(constant) naturalSearch

Description:
  • Natural Search Algorithm by gkucmierz Mathematically finds the exponential boundary and binary searches bounds for a conditional function. Useful for finding bounds in sigmoidal functions without known boundaries.
Source:
Natural Search Algorithm by gkucmierz Mathematically finds the exponential boundary and binary searches bounds for a conditional function. Useful for finding bounds in sigmoidal functions without known boundaries.

(constant) nelderMead

Description:
  • Nelder-Mead Simplex Algorithm (Direct Search Gradient-Free Optimization) Maximizes continuous N-dimensional spaces through contraction and expansion.
Source:
Nelder-Mead Simplex Algorithm (Direct Search Gradient-Free Optimization) Maximizes continuous N-dimensional spaces through contraction and expansion.

(constant) num2bijective

Description:
  • Converts a number to a bijective base-k string.
Source:
Converts a number to a bijective base-k string.

(constant) num2bijectiveBI

Description:
  • Converts a BigInt to a bijective base-k string.
Source:
Converts a BigInt to a bijective base-k string.

(constant) particleSwarmOptimization

Description:
  • Particle Swarm Optimization (PSO) A stochastic, population-based metaheuristic for maximizing complex multidimensional bounds.
Source:
Particle Swarm Optimization (PSO) A stochastic, population-based metaheuristic for maximizing complex multidimensional bounds.

(constant) permutations

Description:
  • Returns all permutations synchronously. WARNING: Generates size! (factorial) elements. Scales in O(N!).
Source:
Returns all permutations synchronously. WARNING: Generates size! (factorial) elements. Scales in O(N!).

(constant) permutationsIterator

Description:
  • Creates a permutations generator from a specified size or an array of elements.
Source:
Creates a permutations generator from a specified size or an array of elements.

(constant) phi

Description:
  • Euler's Totient Function (Phi). Counts the positive integers less than or equal to n that are relatively prime to n. Uses Euler's product formula based on prime factorization.
Source:
Euler's Totient Function (Phi). Counts the positive integers less than or equal to n that are relatively prime to n. Uses Euler's product formula based on prime factorization.

(constant) phiBI

Description:
  • Euler's Totient Function (Phi) - BigInt version.
Source:
Euler's Totient Function (Phi) - BigInt version.

(constant) powMod

Description:
  • Calculates the power of a base to an exponent, optionally modulo a number. Similar to Python's pow(base, exponent, modulus).
Source:
Calculates the power of a base to an exponent, optionally modulo a number. Similar to Python's pow(base, exponent, modulus).

(constant) powModBI

Description:
  • Calculates the power of a base to an exponent, optionally modulo a BigInt. Similar to Python's pow(base, exponent, modulus).
Source:
Calculates the power of a base to an exponent, optionally modulo a BigInt. Similar to Python's pow(base, exponent, modulus).

(constant) range2array

Description:
  • Converts a list of ranges into a flat array of numbers.
Source:
Converts a list of ranges into a flat array of numbers.

(constant) simulatedAnnealing

Description:
  • Simulated Annealing (Derivative-Free Stochastic Optimization) Maximizes the evaluate function payload.
Source:
Simulated Annealing (Derivative-Free Stochastic Optimization) Maximizes the evaluate function payload.

(constant) squareRoot

Description:
  • Calculates the square root of a number.
Source:
Calculates the square root of a number.

(constant) squareRootBI

Description:
  • Calculates the integer square root of a BigInt using Newton's method.
Source:
Calculates the integer square root of a BigInt using Newton's method.

(constant) toBase64

Description:
  • Encodes a string to Base64. Handles Unicode characters correctly.
Source:
Encodes a string to Base64. Handles Unicode characters correctly.

(constant) toBase64Url

Description:
  • Encodes a string to Base64Url format. Replaces '+' with '-' and '/' with '_'.
Source:
Encodes a string to Base64Url format. Replaces '+' with '-' and '/' with '_'.

(constant) tonelliShanksBI

Description:
  • Computes the modular square root of n modulo p using the Tonelli-Shanks algorithm. Solves the congruence r^2 = n (mod p) where p is an odd prime.
Source:
Computes the modular square root of n modulo p using the Tonelli-Shanks algorithm. Solves the congruence r^2 = n (mod p) where p is an odd prime.

Methods

convertBit()

Description:
  • Internal logic for toggling bit state based on MSB progression.
Source:

formatBigNumberBoth(num, separatoropt, wrapFnopt) → {string}

Description:
  • Formats a BigNumber, Number or string representation of a number by separating thousands with a provided separator.
Source:
Parameters:
Name Type Attributes Default Description
num number | string | bigint The number to format.
separator string <optional>
'' The string to use as a thousand separator.
wrapFn function <optional>
_=>_ Optional function to wrap each part of the number.
Returns:
The formatted number.
Type
string