@gkucmierz/utils 2.3.0 → 2.3.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.
- package/README.md +0 -4
- package/package.json +1 -1
- package/src/golden-ratio.mjs +2 -2
- package/src/measure-performance.mjs +3 -3
package/README.md
CHANGED
|
@@ -13,10 +13,6 @@ A collection of useful utility functions and data structures for solving algorit
|
|
|
13
13
|
npm install @gkucmierz/utils
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
## 🚀 What's New in v2.0.0
|
|
17
|
-
- **Combinatorics Arsenal**: High-performance, memory-safe O(1) generators powered by native `BigInt`.
|
|
18
|
-
- **OOP Encapsulation**: `Heap` and `Trie` data structures were refactored into robust ES6 Classes (`new Heap()`, `new Trie()`).
|
|
19
|
-
|
|
20
16
|
## ✨ Features
|
|
21
17
|
|
|
22
18
|
This library provides a wide range of mathematical functions and data structures, including:
|
package/package.json
CHANGED
package/src/golden-ratio.mjs
CHANGED
|
@@ -25,8 +25,8 @@ export const goldenRatioBI = precision => {
|
|
|
25
25
|
|
|
26
26
|
// Wrap primitive BigInt in an Object (Boxing)
|
|
27
27
|
const boxedResult = Object(result);
|
|
28
|
-
boxedResult.toString =
|
|
29
|
-
const str =
|
|
28
|
+
boxedResult.toString = () => {
|
|
29
|
+
const str = result.toString();
|
|
30
30
|
if (precision === 0) return str;
|
|
31
31
|
|
|
32
32
|
// The Golden Ratio is ~1.618, so the integer part is always '1'.
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Useful for micro-benchmarking and performance comparison.
|
|
4
4
|
*
|
|
5
5
|
* @param {Function} fn - The function to benchmark.
|
|
6
|
-
* @param {number} [
|
|
6
|
+
* @param {number} [steps=1e8] - The number of iterations to run the function.
|
|
7
7
|
* @param {string} [memo='noop'] - A descriptive label for the benchmark result.
|
|
8
8
|
* @returns {Object} An object containing the `memo` and the `duration` (in milliseconds).
|
|
9
9
|
*/
|
|
10
|
-
export const measurePerformance = (fn,
|
|
10
|
+
export const measurePerformance = (fn, steps = 1e8, memo = 'noop') => {
|
|
11
11
|
const t1 = Date.now();
|
|
12
|
-
while (
|
|
12
|
+
while (steps--) {
|
|
13
13
|
fn();
|
|
14
14
|
}
|
|
15
15
|
const t2 = Date.now();
|