@gkucmierz/utils 4.0.0 → 4.0.2
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.
- package/package.json +1 -1
- package/src/automata/langtons-ant.mjs +4 -0
- package/src/combinatorics/combinations.mjs +4 -0
- package/src/combinatorics/gray-code.mjs +4 -0
- package/src/combinatorics/n-choose-k.mjs +4 -0
- package/src/combinatorics/permutations.mjs +4 -0
- package/src/data-structures/SetCnt.mjs +4 -0
- package/src/data-structures/Trie.mjs +4 -0
- package/src/data-structures/heap.mjs +4 -0
- package/src/data-structures/list-node.mjs +4 -0
- package/src/developer-utils/binary-search.mjs +4 -0
- package/src/developer-utils/consume-iterator.mjs +4 -0
- package/src/developer-utils/get-type.mjs +4 -0
- package/src/developer-utils/measure-performance.mjs +4 -0
- package/src/developer-utils/memoize.mjs +4 -0
- package/src/developer-utils/natural-search.mjs +4 -0
- package/src/developer-utils/rand-normal.mjs +4 -0
- package/src/developer-utils/range-array.mjs +4 -0
- package/src/developer-utils/set-safe-interval.mjs +4 -0
- package/src/geometry/barycentric.mjs +4 -0
- package/src/geometry/math3d.mjs +4 -0
- package/src/geometry/matrix.mjs +4 -0
- package/src/number-theory/egcd.mjs +4 -0
- package/src/number-theory/factors.mjs +4 -0
- package/src/number-theory/gcd.mjs +4 -0
- package/src/number-theory/lcm.mjs +4 -0
- package/src/number-theory/lucas-lehmer.mjs +4 -0
- package/src/number-theory/mobius.mjs +4 -0
- package/src/number-theory/mod.mjs +4 -0
- package/src/number-theory/phi.mjs +4 -0
- package/src/number-theory/pow-mod.mjs +4 -0
- package/src/number-theory/tonelli-shanks.mjs +4 -0
- package/src/optimization/nelder-mead.mjs +4 -0
- package/src/optimization/particle-swarm.mjs +4 -0
- package/src/optimization/simulated-annealing.mjs +4 -0
- package/src/sequences/golden-ratio.mjs +4 -0
- package/src/sequences/gpn.mjs +4 -0
- package/src/sequences/herons-formula.mjs +4 -0
- package/src/sequences/square-root.mjs +4 -0
- package/src/string-arrays/array-histogram.mjs +4 -0
- package/src/string-arrays/base64.mjs +4 -0
- package/src/string-arrays/bijective-numeration.mjs +4 -0
- package/src/string-arrays/chunks.mjs +5 -0
- package/src/string-arrays/copy-case.mjs +4 -0
- package/src/string-arrays/format-big-number.mjs +13 -1
package/package.json
CHANGED
package/src/geometry/math3d.mjs
CHANGED
|
@@ -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}
|
package/src/geometry/matrix.mjs
CHANGED
package/src/sequences/gpn.mjs
CHANGED
|
@@ -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
|
|
@@ -11,7 +15,7 @@
|
|
|
11
15
|
const formatBigNumberBoth = (num, separator = '', wrapFn = _ => _) => {
|
|
12
16
|
const str = String(num);
|
|
13
17
|
const rev = [...str].reverse().join('');
|
|
14
|
-
const match = rev.match(/(\d
|
|
18
|
+
const match = rev.match(/(\d*\.[+-]?)|(\d{3}[+-]?)|(\d{1,3}[+-]?)|([+-])/g);
|
|
15
19
|
const revInside = (match && match.join('') === rev)
|
|
16
20
|
? match.map(part => [...part].reverse().join(''))
|
|
17
21
|
: [str];
|
|
@@ -41,6 +45,13 @@ export const formatBigNumber = formatBigNumberBoth;
|
|
|
41
45
|
*/
|
|
42
46
|
export const formatBigNumberBI = formatBigNumberBoth;
|
|
43
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Creates an alternating span wrapper function for number segments with 'even' and 'odd' classes.
|
|
50
|
+
* Useful for syntax highlighting or alternating styles of formatted number segments.
|
|
51
|
+
*
|
|
52
|
+
* @returns {function(string): string} A wrapper callback function for number segments.
|
|
53
|
+
* @see {@link https://instacode.app/run/FASwtgDg9gTgLgAgN4IO4wIYQGIDsEC+CAZjFGAgEQACA5gNYCuAxmCAKYwBeA9I3CAA2AZ0oBuYMHRY8EoA|▶ Try it live in Instacode}
|
|
54
|
+
*/
|
|
44
55
|
export const wrapFn = () => {
|
|
45
56
|
let even = true;
|
|
46
57
|
return part => {
|
|
@@ -49,3 +60,4 @@ export const wrapFn = () => {
|
|
|
49
60
|
return `<span class="${cls}">${part}</span>`;
|
|
50
61
|
};
|
|
51
62
|
};
|
|
63
|
+
|