@gkucmierz/utils 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/src/automata/langtons-ant.mjs +4 -0
  3. package/src/combinatorics/combinations.mjs +4 -0
  4. package/src/combinatorics/gray-code.mjs +4 -0
  5. package/src/combinatorics/n-choose-k.mjs +4 -0
  6. package/src/combinatorics/permutations.mjs +4 -0
  7. package/src/data-structures/SetCnt.mjs +4 -0
  8. package/src/data-structures/Trie.mjs +4 -0
  9. package/src/data-structures/heap.mjs +4 -0
  10. package/src/data-structures/list-node.mjs +4 -0
  11. package/src/developer-utils/binary-search.mjs +4 -0
  12. package/src/developer-utils/consume-iterator.mjs +4 -0
  13. package/src/developer-utils/get-type.mjs +4 -0
  14. package/src/developer-utils/measure-performance.mjs +4 -0
  15. package/src/developer-utils/memoize.mjs +4 -0
  16. package/src/developer-utils/natural-search.mjs +4 -0
  17. package/src/developer-utils/rand-normal.mjs +4 -0
  18. package/src/developer-utils/range-array.mjs +4 -0
  19. package/src/developer-utils/set-safe-interval.mjs +4 -0
  20. package/src/geometry/barycentric.mjs +4 -0
  21. package/src/geometry/math3d.mjs +4 -0
  22. package/src/geometry/matrix.mjs +4 -0
  23. package/src/number-theory/egcd.mjs +4 -0
  24. package/src/number-theory/factors.mjs +4 -0
  25. package/src/number-theory/gcd.mjs +4 -0
  26. package/src/number-theory/lcm.mjs +4 -0
  27. package/src/number-theory/lucas-lehmer.mjs +4 -0
  28. package/src/number-theory/mobius.mjs +4 -0
  29. package/src/number-theory/mod.mjs +4 -0
  30. package/src/number-theory/phi.mjs +4 -0
  31. package/src/number-theory/pow-mod.mjs +4 -0
  32. package/src/number-theory/tonelli-shanks.mjs +4 -0
  33. package/src/optimization/nelder-mead.mjs +4 -0
  34. package/src/optimization/particle-swarm.mjs +4 -0
  35. package/src/optimization/simulated-annealing.mjs +4 -0
  36. package/src/sequences/golden-ratio.mjs +4 -0
  37. package/src/sequences/gpn.mjs +4 -0
  38. package/src/sequences/herons-formula.mjs +4 -0
  39. package/src/sequences/square-root.mjs +4 -0
  40. package/src/string-arrays/array-histogram.mjs +4 -0
  41. package/src/string-arrays/base64.mjs +4 -0
  42. package/src/string-arrays/bijective-numeration.mjs +4 -0
  43. package/src/string-arrays/chunks.mjs +5 -0
  44. package/src/string-arrays/copy-case.mjs +4 -0
  45. package/src/string-arrays/format-big-number.mjs +4 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gkucmierz/utils",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "type": "module",
5
5
  "description": "Usefull functions for solving programming tasks",
6
6
  "keywords": [
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module automata
3
+ */
4
+
1
5
  /**
2
6
  * Creates an unlimited, dynamically expanding 2D grid using nested Maps.
3
7
  * Ideal for sparse matrices or algorithms operating on an infinite plane (e.g., Langton's Ant, Game of Life).
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module combinatorics
3
+ */
4
+
1
5
  /**
2
6
  * Generates all possible combinations of size n from a set of size k without repetition.
3
7
  * Yields arrays of indices representing the current combination.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module combinatorics
3
+ */
4
+
1
5
  /**
2
6
  * Internal logic for toggling bit state based on MSB progression.
3
7
  */
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module combinatorics
3
+ */
4
+
1
5
  /**
2
6
  * Newton's formula (Binomial Coefficient) n choose k.
3
7
  * Evaluates the number of possible combinations.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module combinatorics
3
+ */
4
+
1
5
  /**
2
6
  * Creates a permutations generator from a specified size or an array of elements.
3
7
  *
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module data-structures
3
+ */
4
+
1
5
  /**
2
6
  * Set-like data structure built using Map with elements counter.
3
7
  * Allows adding multiple occurrences of the same element.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module data-structures
3
+ */
4
+
1
5
  /**
2
6
  * Creates a Trie (prefix tree) data structure.
3
7
  * Implemented as a proper ES6 Class to fix prototyping documentation and encapsulate nodes.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module data-structures
3
+ */
4
+
1
5
  /**
2
6
  * Creates a Min Heap data structure.
3
7
  * Implemented as a ES6 Class to fix prototyping documentation
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module data-structures
3
+ */
4
+
1
5
 
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Performs a binary search for an exact element in a sorted array.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
  /**
2
6
  * Consume iterator values asynchronously utilizing macro-task queue
3
7
  * to prevent Event Loop blocking.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Returns the type of the value as a lowercase string.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
  /**
2
6
  * Measures the execution time of a given function by running it multiple times.
3
7
  * Useful for micro-benchmarking and performance comparison.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Creates a memoized version of a function.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
  /**
2
6
  * Natural Search Algorithm by gkucmierz
3
7
  * Mathematically finds the exponential boundary and binary searches bounds for a conditional function.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
  /**
2
6
  * Generates a random number from a normal (Gaussian) distribution.
3
7
  * Uses the Box-Muller transform.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
 
2
6
  // https://www.codewars.com/kata/57d83dfc950d842dcb00005b/train/javascript
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module developer-utils
3
+ */
4
+
1
5
  /**
2
6
  * A safe alternative to setInterval that uses recursive setTimeout.
3
7
  * It waits for the callback (even if it's async) to finish before scheduling the next tick,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module geometry
3
+ */
4
+
1
5
  /**
2
6
  * Calculates the barycentric coordinates of a 2D point P relative to a triangle ABC.
3
7
  * @param {Array<number>} p - Point [x, y]
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module geometry
3
+ */
4
+
1
5
  /**
2
6
  * Pure 3D Math Engine for Arcball/Trackball raw matrix transformations
3
7
  * @see {@link https://instacode.app/run/FASwtgDg9gTgLgAgN4IMYygZ0wBQwEwFdVEBfBAMwzAQCIABAcwGtiwQBTGALwHpC4IADaZaAbmDB0WXAWJwJQA|▶ Try it live in Instacode}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module geometry
3
+ */
4
+
1
5
 
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Extended Euclidean Algorithm.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Calculates the prime factorization of a number.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  const getGCD = ZERO => {
3
7
  return (a, b) => {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  import {
3
7
  gcd,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
  /**
2
6
  * Calculates whether a given Mersenne number (2^p - 1) is prime using the Lucas-Lehmer primality test.
3
7
  *
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
  import { factors, factorsBI } from './factors.mjs';
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  const getMod = ZERO => {
3
7
  return (dividend, divisor) => {
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  import {
3
7
  gcd,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  // implementation of power function with modulus like native python pow
3
7
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module number-theory
3
+ */
4
+
1
5
 
2
6
  import {
3
7
  powModBI,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module optimization
3
+ */
4
+
1
5
  /**
2
6
  * Nelder-Mead Simplex Algorithm (Direct Search Gradient-Free Optimization)
3
7
  * Maximizes continuous N-dimensional spaces through contraction and expansion.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module optimization
3
+ */
4
+
1
5
  /**
2
6
  * Particle Swarm Optimization (PSO)
3
7
  * A stochastic, population-based metaheuristic for maximizing complex multidimensional bounds.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module optimization
3
+ */
4
+
1
5
  /**
2
6
  * Simulated Annealing (Derivative-Free Stochastic Optimization)
3
7
  * Maximizes the evaluate function payload.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module sequences
3
+ */
4
+
1
5
  import { squareRootBI } from './square-root.mjs';
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module sequences
3
+ */
4
+
1
5
 
2
6
  // Generalized pentagonal numbers
3
7
  // https://oeis.org/A001318
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module sequences
3
+ */
4
+
1
5
 
2
6
  import {
3
7
  squareRootBI,
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module sequences
3
+ */
4
+
1
5
 
2
6
 
3
7
  /**
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module string-arrays
3
+ */
4
+
1
5
  /**
2
6
  * Generates a Map with unique elements and their occurring frequencies.
3
7
  * Transforms an array into a Map of (key -> quantity) using an optional mapping callback.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module string-arrays
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Encodes a string to Base64.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module string-arrays
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Converts a number to a bijective base-k string.
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @module string-arrays
3
+ * @see {@link https://instacode.app/run/FASwtgDg9gTgLgAgN4IMYAsCuA7A1gZwQF8EAzGKMBAIgAEBzXTVMEAUxgC8B6TOEADb5qAbmDAMOAmKA|▶ Try it live in Instacode}
4
+ */
5
+
1
6
  export const chunks = (input, size = 1) => {
2
7
  if (size < 1) size = 1;
3
8
 
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module string-arrays
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Copies the case pattern from one string to another.
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @module string-arrays
3
+ */
4
+
1
5
 
2
6
  /**
3
7
  * Formats a BigNumber, Number or string representation of a number