@tktb-tess/util-fns 0.11.0 → 0.11.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 -46
- package/dist/bundle.js +132 -128
- package/dist/bundle.min.js +2 -2
- package/dist/main.d.ts +1 -1
- package/dist/math.d.ts +1 -1
- package/dist/util.d.ts +5 -5
- package/package.json +4 -4
- /package/dist/{xoshiro-minimal.d.ts → xoshiro_minimal.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,47 +1 @@
|
|
|
1
1
|
# util-fns
|
|
2
|
-
|
|
3
|
-
Utility functions for personal use
|
|
4
|
-
|
|
5
|
-
Available in both a browser and Node.js environment.
|
|
6
|
-
|
|
7
|
-
## Install
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i @tktb-tess/util-fns
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Usage
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { modPow, bailliePSW } from '@tktb-tess/util-fns';
|
|
17
|
-
|
|
18
|
-
const ans = modPow(2n, 16n, 17n);
|
|
19
|
-
console.log(ans); // 1n
|
|
20
|
-
|
|
21
|
-
// Baillie-PSW primality test
|
|
22
|
-
console.log(bailliePSW(2n)); // true
|
|
23
|
-
console.log(bailliePSW(4n)): // false
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### CDN
|
|
28
|
-
|
|
29
|
-
You can also use it via CDN such as jsDelivr.
|
|
30
|
-
|
|
31
|
-
```html
|
|
32
|
-
<!-- You can import it as a global variable -->
|
|
33
|
-
<script src="https://cdn.jsdelivr.net/npm/@tktb-tess/util-fns@0.10.0/dist/bundle.min.js"></script>
|
|
34
|
-
<script type="module">
|
|
35
|
-
const { modPow } = UtilFns;
|
|
36
|
-
// ...
|
|
37
|
-
</script>
|
|
38
|
-
|
|
39
|
-
<!-- or as an ES Module -->
|
|
40
|
-
<script type="module">
|
|
41
|
-
import { modPow } from 'https://cdn.jsdelivr.net/npm/@tktb-tess/util-fns@0.10.0/+esm';
|
|
42
|
-
// ...
|
|
43
|
-
</script>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const T = new TextEncoder(), Y = (e, t) => [e].includes(t), d = (e, t) => {
|
|
2
2
|
if (typeof e != typeof t) return !1;
|
|
3
3
|
const n = Object.prototype.toString.call(e), r = Object.prototype.toString.call(t);
|
|
4
4
|
if (n !== r) return !1;
|
|
@@ -27,7 +27,7 @@ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
|
|
|
27
27
|
if (n === "[object Object]") {
|
|
28
28
|
const s = e, o = t, i = Object.keys(s), c = Object.keys(o);
|
|
29
29
|
for (const a of i) {
|
|
30
|
-
const l = c.find((
|
|
30
|
+
const l = c.find((p) => p === a);
|
|
31
31
|
if (l === void 0) return !1;
|
|
32
32
|
const [f, h] = [s[a], o[l]];
|
|
33
33
|
if (!d(f, h)) return !1;
|
|
@@ -37,7 +37,7 @@ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
|
|
|
37
37
|
throw Error(`comparing these objects is unavailable: ${e}, ${t}`, {
|
|
38
38
|
cause: [e, t]
|
|
39
39
|
});
|
|
40
|
-
},
|
|
40
|
+
}, Z = () => {
|
|
41
41
|
let e, t;
|
|
42
42
|
return {
|
|
43
43
|
promise: new Promise((r, s) => {
|
|
@@ -46,9 +46,12 @@ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
|
|
|
46
46
|
resolve: e,
|
|
47
47
|
reject: t
|
|
48
48
|
};
|
|
49
|
-
},
|
|
49
|
+
}, Q = (e) => new Promise((t) => {
|
|
50
50
|
setTimeout(() => t(), e);
|
|
51
|
-
}),
|
|
51
|
+
}), tt = (e) => {
|
|
52
|
+
const t = Object.prototype.toString.call(e);
|
|
53
|
+
return t.slice(8, t.length - 1);
|
|
54
|
+
}, et = (e) => (...t) => () => e(...t), nt = (e) => {
|
|
52
55
|
const t = [];
|
|
53
56
|
let n = [], r = "", s = !1;
|
|
54
57
|
for (let o = 0; o < e.length; o++) {
|
|
@@ -57,23 +60,23 @@ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
|
|
|
57
60
|
` && !s ? (n.push(r.trim()), t.push(n), n = [], r = "") : r += i;
|
|
58
61
|
}
|
|
59
62
|
return n.push(r.trim()), t.push(n), t;
|
|
60
|
-
},
|
|
61
|
-
const n =
|
|
63
|
+
}, rt = async (e, t) => {
|
|
64
|
+
const n = T.encode(e), r = await crypto.subtle.digest(t, n);
|
|
62
65
|
return new Uint8Array(r);
|
|
63
|
-
},
|
|
66
|
+
}, st = () => !!globalThis.process && typeof process.version < "u" && typeof process.versions.node < "u", ot = (e) => encodeURIComponent(e).replace(
|
|
64
67
|
/[!'()*]/g,
|
|
65
68
|
(n) => `%${n.charCodeAt(0).toString(16).toUpperCase()}`
|
|
66
|
-
),
|
|
69
|
+
), it = (e) => {
|
|
67
70
|
if (e.includes("+"))
|
|
68
71
|
throw Error("An input string has '+'");
|
|
69
72
|
return decodeURIComponent(e);
|
|
70
|
-
},
|
|
73
|
+
}, ct = async (e, t) => {
|
|
71
74
|
const r = new Blob([e]).stream().pipeThrough(new CompressionStream(t));
|
|
72
75
|
return new Response(r).bytes();
|
|
73
|
-
},
|
|
76
|
+
}, at = async (e, t) => {
|
|
74
77
|
const r = new Blob([e]).stream().pipeThrough(new DecompressionStream(t));
|
|
75
78
|
return new Response(r).bytes();
|
|
76
|
-
},
|
|
79
|
+
}, lt = (e, t) => new Promise((n, r) => {
|
|
77
80
|
setTimeout(async () => {
|
|
78
81
|
try {
|
|
79
82
|
const s = await e();
|
|
@@ -82,12 +85,12 @@ const M = new TextEncoder(), X = (e, t) => [e].includes(t), d = (e, t) => {
|
|
|
82
85
|
r(s);
|
|
83
86
|
}
|
|
84
87
|
}, t);
|
|
85
|
-
});
|
|
86
|
-
class
|
|
88
|
+
}), N = "NamedError";
|
|
89
|
+
class w extends Error {
|
|
87
90
|
constructor(t, n, r) {
|
|
88
91
|
super(n, r), this.errName = t;
|
|
89
92
|
}
|
|
90
|
-
static name =
|
|
93
|
+
static name = N;
|
|
91
94
|
toJSON() {
|
|
92
95
|
const t = (() => {
|
|
93
96
|
const o = this.cause;
|
|
@@ -101,32 +104,32 @@ class m extends Error {
|
|
|
101
104
|
};
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
|
-
Object.defineProperty(
|
|
105
|
-
value:
|
|
107
|
+
Object.defineProperty(w.prototype, Symbol.toStringTag, {
|
|
108
|
+
value: N
|
|
106
109
|
});
|
|
107
|
-
const
|
|
110
|
+
const ut = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
108
111
|
t < 0n && (t *= -1n);
|
|
109
112
|
const n = e % t;
|
|
110
113
|
return n < 0n ? n + t : n;
|
|
111
|
-
},
|
|
114
|
+
}, v = (e, t = !1) => {
|
|
112
115
|
if (!Number.isFinite(e)) throw Error("`length` is not a valid number");
|
|
113
116
|
if (e <= 0) throw Error("`length` must be positive");
|
|
114
117
|
const n = Math.ceil(e / 8), r = crypto.getRandomValues(new Uint8Array(n));
|
|
115
118
|
let s = Array.from(r, (o) => o.toString(2).padStart(8, "0")).join("").slice(0, e);
|
|
116
119
|
return t && (s = s.replace(/^\d/, "1")), BigInt("0b" + s);
|
|
117
|
-
},
|
|
120
|
+
}, P = (e, t) => {
|
|
118
121
|
if (e >= t)
|
|
119
|
-
throw new
|
|
122
|
+
throw new w("RangeError", "min is larger than max");
|
|
120
123
|
const n = t - e, r = n.toString(2).length, s = (() => {
|
|
121
124
|
for (let i = 0; i < 1e5; i++) {
|
|
122
|
-
const c =
|
|
123
|
-
if (c >=
|
|
125
|
+
const c = v(r);
|
|
126
|
+
if (c >= m(2n, BigInt(r), n))
|
|
124
127
|
return c % n;
|
|
125
128
|
}
|
|
126
129
|
throw Error("Failed to generate a random bigint");
|
|
127
130
|
})();
|
|
128
131
|
return e + s;
|
|
129
|
-
},
|
|
132
|
+
}, m = (e, t, n) => {
|
|
130
133
|
if (n < 1n) throw Error("`mod` must be positive");
|
|
131
134
|
if (t < 0n) throw Error("`power` must not be negative");
|
|
132
135
|
if (e = g(e, n), n === 1n) return 0n;
|
|
@@ -136,7 +139,7 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
136
139
|
for (; t > 0n; )
|
|
137
140
|
t & 1n && (r = r * e % n), e = e * e % n, t >>= 1n;
|
|
138
141
|
return r;
|
|
139
|
-
},
|
|
142
|
+
}, _ = (e, t) => {
|
|
140
143
|
if (e === 0n && t === 0n) return { x: 0n, y: 0n, gcd: 0n };
|
|
141
144
|
if (e === 0n)
|
|
142
145
|
return t > 0n ? { x: 0n, y: -1n, gcd: t } : { x: 0n, y: 1n, gcd: -t };
|
|
@@ -149,7 +152,7 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
149
152
|
[n, o] = [o, n - a * o], [r, i] = [i, r - a * i], [s, c] = [c, l];
|
|
150
153
|
}
|
|
151
154
|
return c < 0n && (o *= -1n, i *= -1n, c *= -1n), { x: o, y: i, gcd: c };
|
|
152
|
-
},
|
|
155
|
+
}, I = (e, t) => {
|
|
153
156
|
if (e >= t) return 1n;
|
|
154
157
|
const n = BigInt((t - 2n).toString(2).length), r = (t - e) / 2n;
|
|
155
158
|
if (n * r < 63n) {
|
|
@@ -158,22 +161,22 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
158
161
|
c *= a;
|
|
159
162
|
return c;
|
|
160
163
|
}
|
|
161
|
-
const s = e + r | 1n, o =
|
|
164
|
+
const s = e + r | 1n, o = I(e, s), i = I(s, t);
|
|
162
165
|
return o * i;
|
|
163
|
-
},
|
|
166
|
+
}, j = (e) => {
|
|
164
167
|
let t = 3n, n = 1n, r = 1n;
|
|
165
168
|
const s = BigInt(e.toString(2).length) - 1n;
|
|
166
169
|
for (let o = s - 1n; o > -1n; --o) {
|
|
167
170
|
const i = (e >> o) + 1n | 1n;
|
|
168
|
-
r *=
|
|
171
|
+
r *= I(t, i), t = i, n *= r;
|
|
169
172
|
}
|
|
170
173
|
return n;
|
|
171
|
-
},
|
|
174
|
+
}, ft = (e) => {
|
|
172
175
|
if (e < 0n) throw Error("'n' must be non-negative");
|
|
173
176
|
if (e === 0n) return 1n;
|
|
174
177
|
const t = e - BigInt(e.toString(2).match(/1/g)?.length ?? 0);
|
|
175
|
-
return
|
|
176
|
-
},
|
|
178
|
+
return j(e) << t;
|
|
179
|
+
}, C = (e, t) => (e >>> (t & 31) | e << (-t & 31)) >>> 0, b = (e, t) => BigInt.asUintN(64, e >> (t & 63n) | e << (-t & 63n)), E = (e, t) => {
|
|
177
180
|
if (t < 1n || t % 2n === 0n)
|
|
178
181
|
throw Error("`n` is invalid");
|
|
179
182
|
for (; e < 0n; )
|
|
@@ -189,7 +192,7 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
189
192
|
[e, t] = [t, e], e % 4n === 3n && t % 4n === 3n && (n *= -1n), e %= t;
|
|
190
193
|
}
|
|
191
194
|
return t === 1n ? n : 0n;
|
|
192
|
-
},
|
|
195
|
+
}, O = (e) => {
|
|
193
196
|
if (e < 0n) return !1;
|
|
194
197
|
if (e === 0n) return !0;
|
|
195
198
|
let t = 1n, n = e;
|
|
@@ -198,46 +201,47 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
198
201
|
r * r < e ? t = r : n = r;
|
|
199
202
|
}
|
|
200
203
|
return e === t ** 2n || e === (t + 1n) ** 2n;
|
|
201
|
-
},
|
|
204
|
+
}, F = (e) => {
|
|
202
205
|
if (e <= 1n) return !1;
|
|
203
206
|
if (e % 2n === 0n) return e === 2n;
|
|
204
207
|
let t = e - 1n, n = 0n;
|
|
205
208
|
for (; t % 2n === 0n; )
|
|
206
209
|
t >>= 1n, n += 1n;
|
|
207
210
|
const [r, s] = [t, n];
|
|
208
|
-
let i =
|
|
211
|
+
let i = m(2n, r, e);
|
|
209
212
|
if (i === 1n) return !0;
|
|
210
213
|
for (let c = 0n; c < s; c++) {
|
|
211
214
|
if (i === e - 1n) return !0;
|
|
212
215
|
i = i * i % e;
|
|
213
216
|
}
|
|
214
217
|
return !1;
|
|
215
|
-
},
|
|
218
|
+
}, V = (e) => {
|
|
216
219
|
let t = 5n, n = E(t, e);
|
|
217
220
|
for (; n > 0n; ) {
|
|
218
|
-
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n &&
|
|
221
|
+
if (t = t > 0n ? t + 2n : t - 2n, t *= -1n, t === -15n && O(e))
|
|
219
222
|
return [0n, 0n];
|
|
220
223
|
n = E(t, e);
|
|
221
224
|
}
|
|
222
225
|
return [t, n];
|
|
223
|
-
},
|
|
226
|
+
}, y = (e, t) => (e & 1n) === 1n ? g(e + t >> 1n, t) : g(e >> 1n, t), $ = (e, t, n, r) => {
|
|
224
227
|
let s = 1n, o = n;
|
|
225
228
|
const i = e.toString(2).slice(1);
|
|
226
229
|
for (const c of i)
|
|
227
|
-
[s, o] = [g(s * o, t),
|
|
230
|
+
[s, o] = [g(s * o, t), y(o * o + r * s * s, t)], c === "1" && ([s, o] = [y(n * s + o, t), y(r * s + n * o, t)]);
|
|
228
231
|
return [s, o];
|
|
229
|
-
},
|
|
230
|
-
if (e % 2n !== 1n)
|
|
232
|
+
}, D = (e, t, n, r) => {
|
|
233
|
+
if (e % 2n !== 1n)
|
|
234
|
+
throw Error("`n` must be odd");
|
|
231
235
|
let s = e + 1n, o = 0n;
|
|
232
236
|
for (; s % 2n === 0n; )
|
|
233
237
|
s >>= 1n, o += 1n;
|
|
234
|
-
const [i, c] =
|
|
238
|
+
const [i, c] = $(s, e, n, t);
|
|
235
239
|
let a = c;
|
|
236
240
|
if (i === 0n) return !0;
|
|
237
|
-
r =
|
|
241
|
+
r = m(r, s, e);
|
|
238
242
|
for (let l = 0n; l < o; l++) {
|
|
239
243
|
if (a === 0n) return !0;
|
|
240
|
-
a = g(a * a - 2n * r, e), r =
|
|
244
|
+
a = g(a * a - 2n * r, e), r = m(r, 2n, e);
|
|
241
245
|
}
|
|
242
246
|
return !1;
|
|
243
247
|
}, R = (e) => {
|
|
@@ -274,33 +278,33 @@ const ct = (e, t) => Math.floor(Math.random() * (t - e) + e), g = (e, t) => {
|
|
|
274
278
|
for (const o of t)
|
|
275
279
|
if (e % o === 0n)
|
|
276
280
|
return e === o;
|
|
277
|
-
if (!
|
|
281
|
+
if (!F(e))
|
|
278
282
|
return !1;
|
|
279
|
-
const [n, r] =
|
|
283
|
+
const [n, r] = V(e);
|
|
280
284
|
if (r === 0n) return !1;
|
|
281
285
|
const s = (1n - n) / 4n;
|
|
282
|
-
return
|
|
283
|
-
},
|
|
286
|
+
return D(e, n, 1n, s);
|
|
287
|
+
}, ht = (e, t) => {
|
|
284
288
|
if (t < 2n)
|
|
285
|
-
throw Error("
|
|
289
|
+
throw Error("NoPrimesFound");
|
|
286
290
|
for (let r = 0; r < 1e5; r++) {
|
|
287
|
-
const s =
|
|
291
|
+
const s = P(e, t);
|
|
288
292
|
if (R(s)) return s;
|
|
289
293
|
}
|
|
290
|
-
throw Error("
|
|
291
|
-
},
|
|
294
|
+
throw Error("NoPrimesFound");
|
|
295
|
+
}, dt = (e, t = !1) => {
|
|
292
296
|
if (e < 2)
|
|
293
|
-
throw Error("
|
|
297
|
+
throw Error("NoPrimesFound");
|
|
294
298
|
for (let r = 0; r < 1e5; r++) {
|
|
295
|
-
const s =
|
|
299
|
+
const s = v(e, t);
|
|
296
300
|
if (R(s)) return s;
|
|
297
301
|
}
|
|
298
|
-
throw Error("
|
|
299
|
-
};
|
|
302
|
+
throw Error("NoPrimesFound");
|
|
303
|
+
}, x = "Rational";
|
|
300
304
|
class u {
|
|
301
305
|
#t;
|
|
302
306
|
#e;
|
|
303
|
-
static name =
|
|
307
|
+
static name = x;
|
|
304
308
|
/**
|
|
305
309
|
* fraction (rational) class
|
|
306
310
|
* @param numerator
|
|
@@ -338,7 +342,7 @@ class u {
|
|
|
338
342
|
* reduction
|
|
339
343
|
*/
|
|
340
344
|
#n() {
|
|
341
|
-
const { gcd: t } =
|
|
345
|
+
const { gcd: t } = _(this.#t, this.#e);
|
|
342
346
|
t !== 0n && (this.#t /= t, this.#e /= t);
|
|
343
347
|
}
|
|
344
348
|
/**
|
|
@@ -447,20 +451,20 @@ class u {
|
|
|
447
451
|
}
|
|
448
452
|
}
|
|
449
453
|
Object.defineProperty(u.prototype, Symbol.toStringTag, {
|
|
450
|
-
value:
|
|
454
|
+
value: x
|
|
451
455
|
});
|
|
452
|
-
const
|
|
456
|
+
const k = (e) => {
|
|
453
457
|
const t = Array.from(e, (n) => String.fromCharCode(n));
|
|
454
458
|
return btoa(t.join(""));
|
|
455
|
-
},
|
|
459
|
+
}, q = (e) => {
|
|
456
460
|
const t = atob(e);
|
|
457
461
|
return Uint8Array.from(t, (n) => n.charCodeAt(0));
|
|
458
|
-
},
|
|
462
|
+
}, gt = (e) => k(e).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, ""), mt = (e) => {
|
|
459
463
|
const t = e.length & 3;
|
|
460
464
|
t > 0 && (e = e + "=".repeat(4 - t));
|
|
461
465
|
const n = e.replaceAll("-", "+").replaceAll("_", "/");
|
|
462
|
-
return
|
|
463
|
-
},
|
|
466
|
+
return q(n);
|
|
467
|
+
}, pt = (e) => {
|
|
464
468
|
let t = Array.from(e, (o) => o.toString(16).padStart(2, "0")).join("");
|
|
465
469
|
const n = t.length % 6;
|
|
466
470
|
n && (t = "0".repeat(6 - n) + t);
|
|
@@ -469,7 +473,7 @@ const $ = (e) => {
|
|
|
469
473
|
r,
|
|
470
474
|
(o) => Number.parseInt(o[0], 16).toString(8).padStart(8, "0")
|
|
471
475
|
).join("").replace(/^0+/, "");
|
|
472
|
-
},
|
|
476
|
+
}, yt = (e) => {
|
|
473
477
|
const t = e.length & 7;
|
|
474
478
|
t && (e = "0".repeat(8 - t) + e);
|
|
475
479
|
const n = e.matchAll(/.{8}/g), s = Array.from(n, (o) => {
|
|
@@ -477,13 +481,13 @@ const $ = (e) => {
|
|
|
477
481
|
return Number.parseInt(i, 8).toString(16).padStart(6, "0");
|
|
478
482
|
}).join("").matchAll(/.{2}/g);
|
|
479
483
|
return Uint8Array.from(s, (o) => Number.parseInt(o[0], 16));
|
|
480
|
-
},
|
|
484
|
+
}, K = (e) => {
|
|
481
485
|
const t = e < 0n;
|
|
482
486
|
t && (e *= -1n);
|
|
483
487
|
const n = e.toString(2).length, r = e === 1n << BigInt(n - 1) && !(n % 7) && t, s = Math.floor(n / 7) + 1;
|
|
484
488
|
return r ? s - 1 : s;
|
|
485
|
-
},
|
|
486
|
-
const t =
|
|
489
|
+
}, It = (e) => {
|
|
490
|
+
const t = K(e);
|
|
487
491
|
e = BigInt.asUintN(t * 7, e);
|
|
488
492
|
const n = new Uint8Array(t);
|
|
489
493
|
for (let s = 0; s < t - 1; ++s) {
|
|
@@ -492,7 +496,7 @@ const $ = (e) => {
|
|
|
492
496
|
}
|
|
493
497
|
const r = Number(e & 127n);
|
|
494
498
|
return n[t - 1] = r, e >>= 7n, n;
|
|
495
|
-
},
|
|
499
|
+
}, wt = (e) => {
|
|
496
500
|
const t = e.length;
|
|
497
501
|
let n = 0n;
|
|
498
502
|
for (let r = 0; r < t; ++r) {
|
|
@@ -506,16 +510,16 @@ const $ = (e) => {
|
|
|
506
510
|
for (; e > 0 && !(e & 1); )
|
|
507
511
|
++t, e >>>= 1;
|
|
508
512
|
return t;
|
|
509
|
-
},
|
|
513
|
+
}, M = "FloatRng", S = (e) => {
|
|
510
514
|
if (e === 0n) return 64n;
|
|
511
515
|
let t = 0n;
|
|
512
516
|
for (; e > 0n && !(e & 1n); )
|
|
513
517
|
++t, e >>= 1n;
|
|
514
518
|
return BigInt.asUintN(64, t);
|
|
515
519
|
};
|
|
516
|
-
class
|
|
520
|
+
class G {
|
|
517
521
|
#t;
|
|
518
|
-
static name =
|
|
522
|
+
static name = M;
|
|
519
523
|
constructor(t) {
|
|
520
524
|
this.#t = t;
|
|
521
525
|
}
|
|
@@ -600,8 +604,8 @@ class q {
|
|
|
600
604
|
const f = (() => {
|
|
601
605
|
switch (this.#t.bits) {
|
|
602
606
|
case 32: {
|
|
603
|
-
const h = BigInt(this.#t.getU32Rand() >>> 0),
|
|
604
|
-
return h << 32n |
|
|
607
|
+
const h = BigInt(this.#t.getU32Rand() >>> 0), p = BigInt(this.#t.getU32Rand() >>> 0);
|
|
608
|
+
return h << 32n | p;
|
|
605
609
|
}
|
|
606
610
|
case 64:
|
|
607
611
|
return BigInt.asUintN(64, this.#t.getU64Rand());
|
|
@@ -638,16 +642,16 @@ class q {
|
|
|
638
642
|
throw Error("exceeded loop limit");
|
|
639
643
|
}
|
|
640
644
|
}
|
|
641
|
-
Object.defineProperty(
|
|
642
|
-
value:
|
|
645
|
+
Object.defineProperty(G.prototype, Symbol.toStringTag, {
|
|
646
|
+
value: M
|
|
643
647
|
});
|
|
644
|
-
const
|
|
645
|
-
class
|
|
648
|
+
const W = [0x853c49e6748fea9bn, 0xda3e39cb94b95bdbn], z = 0x5851f42d4c957f2dn, A = "PCGMinimal";
|
|
649
|
+
class X {
|
|
646
650
|
/**
|
|
647
651
|
* length = 2, `[state, increment]`
|
|
648
652
|
*/
|
|
649
653
|
#t;
|
|
650
|
-
static name =
|
|
654
|
+
static name = A;
|
|
651
655
|
bits = 32;
|
|
652
656
|
/**
|
|
653
657
|
* @param seeds
|
|
@@ -663,16 +667,16 @@ class U {
|
|
|
663
667
|
* const betterRng = new PCGMinimal(seed);
|
|
664
668
|
*/
|
|
665
669
|
constructor(t) {
|
|
666
|
-
t && t.length >= 2 ? (this.#t = new BigUint64Array(2), this.#t[1] = t[1] << 1n | 1n, this.#e(), this.#t[0] += t[0], this.#e()) : this.#t = BigUint64Array.from(
|
|
670
|
+
t && t.length >= 2 ? (this.#t = new BigUint64Array(2), this.#t[1] = t[1] << 1n | 1n, this.#e(), this.#t[0] += t[0], this.#e()) : this.#t = BigUint64Array.from(W);
|
|
667
671
|
}
|
|
668
672
|
/** step inner state */
|
|
669
673
|
#e() {
|
|
670
|
-
this.#t[0] = this.#t[0] *
|
|
674
|
+
this.#t[0] = this.#t[0] * z + this.#t[1];
|
|
671
675
|
}
|
|
672
676
|
/** 32bit 乱数を返す (内部状態は変わらない) */
|
|
673
677
|
get #n() {
|
|
674
678
|
const t = this.#t[0], n = Number(t >> 59n), r = Number(BigInt.asUintN(32, (t ^ t >> 18n) >> 27n));
|
|
675
|
-
return
|
|
679
|
+
return C(r, n);
|
|
676
680
|
}
|
|
677
681
|
/**
|
|
678
682
|
*
|
|
@@ -711,16 +715,16 @@ class U {
|
|
|
711
715
|
yield typeof n == "number" ? this.getBoundedU32Rand(n) : this.getU32Rand();
|
|
712
716
|
}
|
|
713
717
|
}
|
|
714
|
-
Object.defineProperty(
|
|
715
|
-
value:
|
|
718
|
+
Object.defineProperty(X.prototype, Symbol.toStringTag, {
|
|
719
|
+
value: A
|
|
716
720
|
});
|
|
717
|
-
const
|
|
721
|
+
const H = [
|
|
718
722
|
0xbe562cb412e2260en,
|
|
719
723
|
0x2e4284137d641affn,
|
|
720
724
|
0x4e19b36ee933e27en,
|
|
721
725
|
0x7581cf8c4f4d4f7dn
|
|
722
726
|
];
|
|
723
|
-
class
|
|
727
|
+
class U {
|
|
724
728
|
bits = 64;
|
|
725
729
|
#t;
|
|
726
730
|
static name = "XoshiroMinimal";
|
|
@@ -738,7 +742,7 @@ class v {
|
|
|
738
742
|
* const betterRng = new XoshiroMinimal(seed);
|
|
739
743
|
*/
|
|
740
744
|
constructor(t) {
|
|
741
|
-
t && t.length >= 4 ? (this.#t = new BigUint64Array(4), this.#t[0] = t[0], this.#t[1] = t[1], this.#e(), this.#t[2] += t[2], this.#t[3] += t[3]) : this.#t = BigUint64Array.from(
|
|
745
|
+
t && t.length >= 4 ? (this.#t = new BigUint64Array(4), this.#t[0] = t[0], this.#t[1] = t[1], this.#e(), this.#t[2] += t[2], this.#t[3] += t[3]) : this.#t = BigUint64Array.from(H);
|
|
742
746
|
}
|
|
743
747
|
#e() {
|
|
744
748
|
const t = this.#t[1] << 17n;
|
|
@@ -791,11 +795,11 @@ class v {
|
|
|
791
795
|
yield n === void 0 ? this.getU32Rand() : this.getBoundedU32Rand(n);
|
|
792
796
|
}
|
|
793
797
|
}
|
|
794
|
-
Object.defineProperty(
|
|
795
|
-
value:
|
|
798
|
+
Object.defineProperty(U.prototype, Symbol.toStringTag, {
|
|
799
|
+
value: U.name
|
|
796
800
|
});
|
|
797
801
|
const L = "WorkerStream";
|
|
798
|
-
class
|
|
802
|
+
class J extends ReadableStream {
|
|
799
803
|
close;
|
|
800
804
|
#t;
|
|
801
805
|
static name = L;
|
|
@@ -808,7 +812,7 @@ class z extends ReadableStream {
|
|
|
808
812
|
i.enqueue(c.data);
|
|
809
813
|
}, s = (c) => {
|
|
810
814
|
t.removeEventListener("message", r), t.removeEventListener("error", s);
|
|
811
|
-
const a = new
|
|
815
|
+
const a = new w("WorkerStreamError", c.message, {
|
|
812
816
|
cause: c.error
|
|
813
817
|
});
|
|
814
818
|
i.error(a);
|
|
@@ -827,50 +831,50 @@ class z extends ReadableStream {
|
|
|
827
831
|
this.#t.postMessage(t, n);
|
|
828
832
|
}
|
|
829
833
|
}
|
|
830
|
-
Object.defineProperty(
|
|
834
|
+
Object.defineProperty(J.prototype, Symbol.toStringTag, {
|
|
831
835
|
value: L
|
|
832
836
|
});
|
|
833
837
|
export {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
838
|
+
G as FloatRng,
|
|
839
|
+
w as NamedError,
|
|
840
|
+
X as PCGMinimal,
|
|
837
841
|
u as Rational,
|
|
838
|
-
|
|
839
|
-
|
|
842
|
+
J as WorkerStream,
|
|
843
|
+
U as XoshiroMinimal,
|
|
840
844
|
R as bailliePSW,
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
845
|
+
ct as compress,
|
|
846
|
+
wt as decodeLEB128,
|
|
847
|
+
it as decodeRFC3986URIComponent,
|
|
848
|
+
at as decompress,
|
|
849
|
+
It as encodeLEB128,
|
|
850
|
+
ot as encodeRFC3986URIComponent,
|
|
851
|
+
_ as exEuclidean,
|
|
852
|
+
ft as factorial,
|
|
853
|
+
q as fromBase64,
|
|
854
|
+
mt as fromBase64Url,
|
|
855
|
+
yt as fromOct,
|
|
856
|
+
rt as getHash,
|
|
857
|
+
v as getRandBIByBitLength,
|
|
858
|
+
P as getRandBIByRange,
|
|
859
|
+
dt as getRandPrimeByBitLength,
|
|
860
|
+
ht as getRandPrimeByRange,
|
|
861
|
+
ut as getRndInt,
|
|
862
|
+
tt as getStringTag,
|
|
859
863
|
d as isDeepStrictEqual,
|
|
860
|
-
|
|
861
|
-
|
|
864
|
+
st as isNode,
|
|
865
|
+
O as isSquare,
|
|
862
866
|
E as jacobiSymbol,
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
867
|
+
et as lazify,
|
|
868
|
+
m as modPow,
|
|
869
|
+
nt as parseCSV,
|
|
866
870
|
g as residue,
|
|
867
|
-
|
|
871
|
+
C as rot32,
|
|
868
872
|
b as rot64,
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
873
|
+
Y as sameValueZero,
|
|
874
|
+
lt as setTimeoutPromise,
|
|
875
|
+
Q as sleep,
|
|
876
|
+
k as toBase64,
|
|
877
|
+
gt as toBase64Url,
|
|
878
|
+
pt as toOct,
|
|
879
|
+
Z as withResolvers
|
|
876
880
|
};
|
package/dist/bundle.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var UtilFns=(function(c){"use strict";const
|
|
2
|
-
`&&!s?(e.push(r.trim()),t.push(e),e=[],r=""):r+=o}return e.push(r.trim()),t.push(e),t},z=async(n,t)=>{const e=$.encode(n),r=await crypto.subtle.digest(t,e);return new Uint8Array(r)},X=()=>!!globalThis.process&&typeof process.version<"u"&&typeof process.versions.node<"u",H=n=>encodeURIComponent(n).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),J=n=>{if(n.includes("+"))throw Error("An input string has '+'");return decodeURIComponent(n)},Y=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new CompressionStream(t));return new Response(r).bytes()},Z=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(r).bytes()},x=(n,t)=>new Promise((e,r)=>{setTimeout(async()=>{try{const s=await n();e(s)}catch(s){r(s)}},t)});class y extends Error{constructor(t,e,r){super(e,r),this.errName=t}static name="NamedError";toJSON(){const t=(()=>{const i=this.cause;return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?i:typeof i=="bigint"?i.toString():typeof i=="object"&&i!==null?i instanceof Set||i instanceof Map?Object.fromEntries(i):i:void 0})(),{errName:e,message:r,stack:s}=this;return{errName:e,message:r,stack:s,cause:t}}}Object.defineProperty(y.prototype,Symbol.toStringTag,{value:y.name});const Q=(n,t)=>Math.floor(Math.random()*(t-n)+n),m=(n,t)=>{t<0n&&(t*=-1n);const e=n%t;return e<0n?e+t:e},I=(n,t=!1)=>{if(!Number.isFinite(n))throw Error("`length` is not a valid number");if(n<=0)throw Error("`length` must be positive");const e=Math.ceil(n/8),r=crypto.getRandomValues(new Uint8Array(e));let s=Array.from(r,i=>i.toString(2).padStart(8,"0")).join("").slice(0,n);return t&&(s=s.replace(/^\d/,"1")),BigInt("0b"+s)},N=(n,t)=>{if(n>=t)throw new y("RangeError","min is larger than max");const e=t-n,r=e.toString(2).length,s=(()=>{for(let o=0;o<1e5;o++){const a=I(r);if(a>=p(2n,BigInt(r),e))return a%e}throw Error("Failed to generate a random bigint")})();return n+s},p=(n,t,e)=>{if(e<1n)throw Error("`mod` must be positive");if(t<0n)throw Error("`power` must not be negative");if(n=m(n,e),e===1n)return 0n;if(n%e===1n||n%e===0n)return n;if(n===e-1n)return t&1n?e-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*n%e),n=n*n%e,t>>=1n;return r},L=(n,t)=>{if(n===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(n===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return n>0n?{x:1n,y:0n,gcd:n}:{x:-1n,y:0n,gcd:-n};let[e,r,s]=[1n,0n,n],[i,o,a]=[0n,-1n,t];for(;;){const l=s/a,u=s-l*a;if(u===0n)break;[e,i]=[i,e-l*i],[r,o]=[o,r-l*o],[s,a]=[a,u]}return a<0n&&(i*=-1n,o*=-1n,a*=-1n),{x:i,y:o,gcd:a}},w=(n,t)=>{if(n>=t)return 1n;const e=BigInt((t-2n).toString(2).length),r=(t-n)/2n;if(e*r<63n){let a=n;for(let l=n+2n;l<t;l+=2n)a*=l;return a}const s=n+r|1n,i=w(n,s),o=w(s,t);return i*o},tt=n=>{let t=3n,e=1n,r=1n;const s=BigInt(n.toString(2).length)-1n;for(let i=s-1n;i>-1n;--i){const o=(n>>i)+1n|1n;r*=w(t,o),t=o,e*=r}return e},nt=n=>{if(n<0n)throw Error("'n' must be non-negative");if(n===0n)return 1n;const t=n-BigInt(n.toString(2).match(/1/g)?.length??0);return tt(n)<<t},M=(n,t)=>(n>>>(t&31)|n<<(-t&31))>>>0,b=(n,t)=>BigInt.asUintN(64,n>>(t&63n)|n<<(-t&63n)),B=(n,t)=>{if(t<1n||t%2n===0n)throw Error("`n` is invalid");for(;n<0n;)n+=t;n%=t;let e=1n;for(;n!==0n;){for(;n%2n===0n;){n/=2n;const r=t%8n;(r===3n||r===5n)&&(e*=-1n)}[n,t]=[t,n],n%4n===3n&&t%4n===3n&&(e*=-1n),n%=t}return t===1n?e:0n},T=n=>{if(n<0n)return!1;if(n===0n)return!0;let t=1n,e=n;for(;t+1n<e;){const r=(t+e)/2n;r*r<n?t=r:e=r}return n===t**2n||n===(t+1n)**2n},et=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;let t=n-1n,e=0n;for(;t%2n===0n;)t>>=1n,e+=1n;const[r,s]=[t,e];let o=p(2n,r,n);if(o===1n)return!0;for(let a=0n;a<s;a++){if(o===n-1n)return!0;o=o*o%n}return!1},rt=n=>{let t=5n,e=B(t,n);for(;e>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&T(n))return[0n,0n];e=B(t,n)}return[t,e]},E=(n,t)=>(n&1n)===1n?m(n+t>>1n,t):m(n>>1n,t),st=(n,t,e,r)=>{let s=1n,i=e;const o=n.toString(2).slice(1);for(const a of o)[s,i]=[m(s*i,t),E(i*i+r*s*s,t)],a==="1"&&([s,i]=[E(e*s+i,t),E(r*s+e*i,t)]);return[s,i]},it=(n,t,e,r)=>{if(n%2n!==1n)throw Error("`n` must be odd");let s=n+1n,i=0n;for(;s%2n===0n;)s>>=1n,i+=1n;const[o,a]=st(s,n,e,t);let l=a;if(o===0n)return!0;r=p(r,s,n);for(let u=0n;u<i;u++){if(l===0n)return!0;l=m(l*l-2n*r,n),r=p(r,2n,n)}return!1},S=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;const t=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n];for(const i of t)if(n%i===0n)return n===i;if(!et(n))return!1;const[e,r]=rt(n);if(r===0n)return!1;const s=(1n-e)/4n;return it(n,e,1n,s)},ot=(n,t)=>{if(t<2n)throw Error("noPrimesFound");for(let r=0;r<1e5;r++){const s=N(n,t);if(S(s))return s}throw Error("noPrimesFound")},ct=(n,t=!1)=>{if(n<2)throw Error("noPrimesFound");for(let r=0;r<1e5;r++){const s=I(n,t);if(S(s))return s}throw Error("noPrimesFound")};class f{#t;#n;static name="Rational";constructor(t,e){e===0n?(this.#n=0n,this.#t=t===0n?0n:t>0n?1n:-1n):e>0n?(this.#t=t,this.#n=e):(this.#t=-t,this.#n=-e),this.#e()}static fromDecimal(t,e=5){if(Number.isNaN(t))return new f(0n,0n);if(Math.abs(t)===1/0)return new f(t>0?1n:-1n,0n);const r=t<0;r&&(t*=-1);const s=BigInt(Math.floor(t)),i=t-Number(s);if(i===0)return new f(r?-s:s,1n);t=1/i;let[o,a]=[1n,s],[l,u]=[0n,1n];for(;`${u}`.length<e+1;){const h=BigInt(Math.floor(t)),d=t-Number(h);if([o,a]=[a,h*a+o],[l,u]=[u,h*u+l],d===0)return new f(r?-a:a,u);t=1/d}return new f(r?-o:o,l)}#e(){const{gcd:t}=L(this.#t,this.#n);t!==0n&&(this.#t/=t,this.#n/=t)}minus(){return new f(-this.#t,this.#n)}inverse(){return new f(this.#n,this.#t)}add(t){const e=this.#n*t.#n,r=this.#t*t.#n+t.#t*this.#n;return new f(r,e)}substr(t){return this.add(t.minus())}multiply(t){const e=this.#n*t.#n,r=this.#t*t.#t;return new f(r,e)}divide(t){return this.multiply(t.inverse())}mediant(t){const e=this.#n+t.#n,r=this.#t+t.#t;return new f(r,e)}toDecimal(){return Number(this.#t)/Number(this.#n)}toString(){return this.#t===0n&&this.#n===0n?"NaN":this.#t===0n?"0":this.#n===0n?this.#t<0n?"-Infinity":"Infinity":this.#n===1n?`${this.#t}`:`${this.#t}/${this.#n}`}valueOf(){return this.toDecimal()}toJSON(){return{type:"Rational",value:["0x"+this.#t.toString(16),"0x"+this.#n.toString(16)]}}static fromData(t){const e=BigInt(t.value[0]),r=BigInt(t.value[1]);return new f(e,r)}static parse(t){const r=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!r)throw Error("cannot parse");const s=r.at(1),i=r.at(2);if(!s||!i)throw Error("cannot parse");return new f(BigInt(s),BigInt(i))}}Object.defineProperty(f.prototype,Symbol.toStringTag,{value:f.name});const A=n=>{const t=Array.from(n,e=>String.fromCharCode(e));return btoa(t.join(""))},P=n=>{const t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))},at=n=>A(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""),lt=n=>{const t=n.length&3;t>0&&(n=n+"=".repeat(4-t));const e=n.replaceAll("-","+").replaceAll("_","/");return P(e)},ut=n=>{let t=Array.from(n,i=>i.toString(16).padStart(2,"0")).join("");const e=t.length%6;e&&(t="0".repeat(6-e)+t);const r=t.matchAll(/.{6}/g);return Array.from(r,i=>Number.parseInt(i[0],16).toString(8).padStart(8,"0")).join("").replace(/^0+/,"")},ft=n=>{const t=n.length&7;t&&(n="0".repeat(8-t)+n);const e=n.matchAll(/.{8}/g),s=Array.from(e,i=>{const o=i[0];return Number.parseInt(o,8).toString(16).padStart(6,"0")}).join("").matchAll(/.{2}/g);return Uint8Array.from(s,i=>Number.parseInt(i[0],16))},ht=n=>{const t=n<0n;t&&(n*=-1n);const e=n.toString(2).length,r=n===1n<<BigInt(e-1)&&!(e%7)&&t,s=Math.floor(e/7)+1;return r?s-1:s},dt=n=>{const t=ht(n);n=BigInt.asUintN(t*7,n);const e=new Uint8Array(t);for(let s=0;s<t-1;++s){const i=Number(n&127n)|128;e[s]=i,n>>=7n}const r=Number(n&127n);return e[t-1]=r,n>>=7n,e},gt=n=>{const t=n.length;let e=0n;for(let r=0;r<t;++r){const s=BigInt(n[r]&127);e+=s<<BigInt(7*r)}return BigInt.asIntN(7*t,e)},j=n=>{if(n===0)return 32;let t=0;for(;n>0&&!(n&1);)++t,n>>>=1;return t},C="FloatRng",_=n=>{if(n===0n)return 64n;let t=0n;for(;n>0n&&!(n&1n);)++t,n>>=1n;return BigInt.asUintN(64,t)};class O{#t;static name=C;constructor(t){this.#t=t}#n(){const r=(()=>{switch(this.#t.bits){case 32:return this.#t.getU32Rand()>>>0;case 64:{const l=this.#t.getU64Rand()&0xffffffffn;return Number(l)}}})(),s=r&255;let i=126;if(s===0){i-=8;const l=1e5;let u=0;t:for(;;){if(u>l)throw Error("loop exceeded limit");const h=(()=>{switch(this.#t.bits){case 32:return this.#t.getU32Rand()>>>0;case 64:{const d=BigInt.asUintN(32,this.#t.getU64Rand());return Number(d)}}})();if(h===0){if(i-=32,i<0){i=0;break t}}else{i-=j(h);break t}++u}}else i-=j(s);const o=r>>>8&8388607;o===0&&r>>>31&&++i;const a=Uint32Array.from([i<<23|o]);return new Float32Array(a.buffer)[0]}getF32Rand(){for(let e=0;e<1e5;++e){const r=this.#n();if(r<1)return r}throw Error("exceeded loop limit")}#e(){const t=0n,e=1023n,r=(()=>{switch(this.#t.bits){case 32:{const l=BigInt(this.#t.getU32Rand()>>>0),u=BigInt(this.#t.getU32Rand()>>>0);return l<<32n|u}case 64:return BigInt.asUintN(64,this.#t.getU64Rand())}})(),s=r&0x7ffn;let i=e-1n;if(s===0n){i-=11n;const l=1e5;let u=0;t:for(;;){if(u>l)throw Error("loop exceeded limit");const h=(()=>{switch(this.#t.bits){case 32:{const d=BigInt(this.#t.getU32Rand()>>>0),v=BigInt(this.#t.getU32Rand()>>>0);return d<<32n|v}case 64:return BigInt.asUintN(64,this.#t.getU64Rand())}})();if(h===0n){if(i-=64n,i<t){i=t;break t}}else{i-=_(h);break t}++u}}else i-=_(s);const o=BigInt.asUintN(52,r>>11n);o===0n&&r>>63n&&++i;const a=BigUint64Array.from([i<<52n|o]);return new Float64Array(a.buffer)[0]}getF64Rand(){for(let e=0;e<1e5;++e){const r=this.#e();if(r<1)return r}throw Error("exceeded loop limit")}}Object.defineProperty(O.prototype,Symbol.toStringTag,{value:C});const mt=[0x853c49e6748fea9bn,0xda3e39cb94b95bdbn],yt=0x5851f42d4c957f2dn;class U{#t;static name="PCGMinimal";bits=32;constructor(t){t&&t.length>=2?(this.#t=new BigUint64Array(2),this.#t[1]=t[1]<<1n|1n,this.#n(),this.#t[0]+=t[0],this.#n()):this.#t=BigUint64Array.from(mt)}#n(){this.#t[0]=this.#t[0]*yt+this.#t[1]}get#e(){const t=this.#t[0],e=Number(t>>59n),r=Number(BigInt.asUintN(32,(t^t>>18n)>>27n));return M(r,e)}getU32Rand(){return this.#n(),this.#e}getBoundedU32Rand(t){if(t>4294967296)throw Error("`bound` exceeded limit (2^32)");if(t<=0)throw Error("'bound' must be positive");const r=4294967296%t,s=1e5;for(let i=0;i<s;++i){const o=this.getU32Rand();if(o>=r)return o%t}throw Error("exceeded loop limit")}*genU32Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;r++)yield typeof e=="number"?this.getBoundedU32Rand(e):this.getU32Rand()}}Object.defineProperty(U.prototype,Symbol.toStringTag,{value:U.name});const pt=[0xbe562cb412e2260en,0x2e4284137d641affn,0x4e19b36ee933e27en,0x7581cf8c4f4d4f7dn];class R{bits=64;#t;static name="XoshiroMinimal";constructor(t){t&&t.length>=4?(this.#t=new BigUint64Array(4),this.#t[0]=t[0],this.#t[1]=t[1],this.#n(),this.#t[2]+=t[2],this.#t[3]+=t[3]):this.#t=BigUint64Array.from(pt)}#n(){const t=this.#t[1]<<17n;this.#t[2]^=this.#t[0],this.#t[3]^=this.#t[1],this.#t[1]^=this.#t[2],this.#t[0]^=this.#t[3],this.#t[2]^=t,this.#t[3]=b(this.#t[3],45n)}get value(){const t=b(this.#t[0]+this.#t[3],23n)+this.#t[0];return BigInt.asUintN(64,t)}getU64Rand(){const t=this.value;return this.#n(),t}getU32Rand(){const t=BigInt.asUintN(32,this.getU64Rand());return Number(t)}getBoundedU64Rand(t){const e=1n<<64n;if(t>e)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=e%t,s=1e5;for(let i=0;i<s;++i){const o=this.getU64Rand();if(o>=r)return o%t}throw Error("exceeded loop limit")}getBoundedU32Rand(t){if(t>4294967296)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=this.getBoundedU64Rand(BigInt(t));return Number(r)}*genU64Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getU64Rand():this.getBoundedU64Rand(e)}*genU32Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getU32Rand():this.getBoundedU32Rand(e)}}Object.defineProperty(R.prototype,Symbol.toStringTag,{value:R.name});const F="WorkerStream";class V extends ReadableStream{close;#t;static name=F;constructor(t,e){let r,s,i;super({start:o=>{r=a=>{o.enqueue(a.data)},s=a=>{t.removeEventListener("message",r),t.removeEventListener("error",s);const l=new y("WorkerStreamError",a.message,{cause:a.error});o.error(l)},i=()=>{t.removeEventListener("message",r),t.removeEventListener("error",s),o.close()},t.addEventListener("message",r),t.addEventListener("error",s)},cancel:o=>{console.log("Canceled reason:",o),t.removeEventListener("message",r),t.removeEventListener("error",s)}},e),this.close=i,this.#t=t}postMessage(t,e){this.#t.postMessage(t,e)}}return Object.defineProperty(V.prototype,Symbol.toStringTag,{value:F}),c.FloatRng=O,c.NamedError=y,c.PCGMinimal=U,c.Rational=f,c.WorkerStream=V,c.XoshiroMinimal=R,c.bailliePSW=S,c.compress=Y,c.decodeLEB128=gt,c.decodeRFC3986URIComponent=J,c.decompress=Z,c.encodeLEB128=dt,c.encodeRFC3986URIComponent=H,c.exEuclidean=L,c.factorial=nt,c.fromBase64=P,c.fromBase64Url=lt,c.fromOct=ft,c.getHash=z,c.getRandBIByBitLength=I,c.getRandBIByRange=N,c.getRandPrimeByBitLength=ct,c.getRandPrimeByRange=ot,c.getRndInt=Q,c.getStringTag=K,c.isDeepStrictEqual=g,c.isNode=X,c.isSquare=T,c.jacobiSymbol=B,c.lazify=W,c.modPow=p,c.parseCSV=G,c.residue=m,c.rot32=M,c.rot64=b,c.sameValueZero=D,c.setTimeoutPromise=x,c.sleep=k,c.toBase64=A,c.toBase64Url=at,c.toOct=ut,c.withResolvers=q,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
|
|
1
|
+
var UtilFns=(function(c){"use strict";const k=new TextEncoder,K=(n,t)=>[n].includes(t),g=(n,t)=>{if(typeof n!=typeof t)return!1;const e=Object.prototype.toString.call(n),r=Object.prototype.toString.call(t);if(e!==r)return!1;if(typeof n=="string"||typeof n=="bigint"||typeof n=="boolean"||typeof n=="symbol"||n==null)return n===t;if(typeof n=="number")return n!==n&&t!==t||n===t;if(typeof n=="function")return!1;if(Array.isArray(n)&&Array.isArray(t)){if(n.length!==t.length)return!1;for(let s=0;s<n.length;s++)if(!g(n[s],t[s]))return!1;return!0}if(n instanceof Set&&t instanceof Set){const s=[...n.values()],i=[...t.values()];return!!g(s,i)}if(n instanceof Map&&t instanceof Map){const s=[...n.keys()],i=[...t.keys()];if(!g(s,i))return!1;const o=[...n.values()],a=[...t.values()];return!!g(o,a)}if(e==="[object Object]"){const s=n,i=t,o=Object.keys(s),a=Object.keys(i);for(const l of o){const u=a.find(R=>R===l);if(u===void 0)return!1;const[h,d]=[s[l],i[u]];if(!g(h,d))return!1}return!0}throw Error(`comparing these objects is unavailable: ${n}, ${t}`,{cause:[n,t]})},W=()=>{let n,t;return{promise:new Promise((r,s)=>{n=r,t=s}),resolve:n,reject:t}},G=n=>new Promise(t=>{setTimeout(()=>t(),n)}),z=n=>{const t=Object.prototype.toString.call(n);return t.slice(8,t.length-1)},X=n=>(...t)=>()=>n(...t),H=n=>{const t=[];let e=[],r="",s=!1;for(let i=0;i<n.length;i++){const o=n[i];o==='"'&&(i===0||n[i-1]!=="\\")?s=!s:o===","&&!s?(e.push(r.trim()),r=""):o===`
|
|
2
|
+
`&&!s?(e.push(r.trim()),t.push(e),e=[],r=""):r+=o}return e.push(r.trim()),t.push(e),t},J=async(n,t)=>{const e=k.encode(n),r=await crypto.subtle.digest(t,e);return new Uint8Array(r)},Y=()=>!!globalThis.process&&typeof process.version<"u"&&typeof process.versions.node<"u",Z=n=>encodeURIComponent(n).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),x=n=>{if(n.includes("+"))throw Error("An input string has '+'");return decodeURIComponent(n)},Q=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new CompressionStream(t));return new Response(r).bytes()},tt=async(n,t)=>{const r=new Blob([n]).stream().pipeThrough(new DecompressionStream(t));return new Response(r).bytes()},nt=(n,t)=>new Promise((e,r)=>{setTimeout(async()=>{try{const s=await n();e(s)}catch(s){r(s)}},t)}),N="NamedError";class p extends Error{constructor(t,e,r){super(e,r),this.errName=t}static name=N;toJSON(){const t=(()=>{const i=this.cause;return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?i:typeof i=="bigint"?i.toString():typeof i=="object"&&i!==null?i instanceof Set||i instanceof Map?Object.fromEntries(i):i:void 0})(),{errName:e,message:r,stack:s}=this;return{errName:e,message:r,stack:s,cause:t}}}Object.defineProperty(p.prototype,Symbol.toStringTag,{value:N});const et=(n,t)=>Math.floor(Math.random()*(t-n)+n),m=(n,t)=>{t<0n&&(t*=-1n);const e=n%t;return e<0n?e+t:e},I=(n,t=!1)=>{if(!Number.isFinite(n))throw Error("`length` is not a valid number");if(n<=0)throw Error("`length` must be positive");const e=Math.ceil(n/8),r=crypto.getRandomValues(new Uint8Array(e));let s=Array.from(r,i=>i.toString(2).padStart(8,"0")).join("").slice(0,n);return t&&(s=s.replace(/^\d/,"1")),BigInt("0b"+s)},v=(n,t)=>{if(n>=t)throw new p("RangeError","min is larger than max");const e=t-n,r=e.toString(2).length,s=(()=>{for(let o=0;o<1e5;o++){const a=I(r);if(a>=y(2n,BigInt(r),e))return a%e}throw Error("Failed to generate a random bigint")})();return n+s},y=(n,t,e)=>{if(e<1n)throw Error("`mod` must be positive");if(t<0n)throw Error("`power` must not be negative");if(n=m(n,e),e===1n)return 0n;if(n%e===1n||n%e===0n)return n;if(n===e-1n)return t&1n?e-1n:1n;let r=1n;for(;t>0n;)t&1n&&(r=r*n%e),n=n*n%e,t>>=1n;return r},L=(n,t)=>{if(n===0n&&t===0n)return{x:0n,y:0n,gcd:0n};if(n===0n)return t>0n?{x:0n,y:-1n,gcd:t}:{x:0n,y:1n,gcd:-t};if(t===0n)return n>0n?{x:1n,y:0n,gcd:n}:{x:-1n,y:0n,gcd:-n};let[e,r,s]=[1n,0n,n],[i,o,a]=[0n,-1n,t];for(;;){const l=s/a,u=s-l*a;if(u===0n)break;[e,i]=[i,e-l*i],[r,o]=[o,r-l*o],[s,a]=[a,u]}return a<0n&&(i*=-1n,o*=-1n,a*=-1n),{x:i,y:o,gcd:a}},w=(n,t)=>{if(n>=t)return 1n;const e=BigInt((t-2n).toString(2).length),r=(t-n)/2n;if(e*r<63n){let a=n;for(let l=n+2n;l<t;l+=2n)a*=l;return a}const s=n+r|1n,i=w(n,s),o=w(s,t);return i*o},rt=n=>{let t=3n,e=1n,r=1n;const s=BigInt(n.toString(2).length)-1n;for(let i=s-1n;i>-1n;--i){const o=(n>>i)+1n|1n;r*=w(t,o),t=o,e*=r}return e},st=n=>{if(n<0n)throw Error("'n' must be non-negative");if(n===0n)return 1n;const t=n-BigInt(n.toString(2).match(/1/g)?.length??0);return rt(n)<<t},M=(n,t)=>(n>>>(t&31)|n<<(-t&31))>>>0,b=(n,t)=>BigInt.asUintN(64,n>>(t&63n)|n<<(-t&63n)),E=(n,t)=>{if(t<1n||t%2n===0n)throw Error("`n` is invalid");for(;n<0n;)n+=t;n%=t;let e=1n;for(;n!==0n;){for(;n%2n===0n;){n/=2n;const r=t%8n;(r===3n||r===5n)&&(e*=-1n)}[n,t]=[t,n],n%4n===3n&&t%4n===3n&&(e*=-1n),n%=t}return t===1n?e:0n},A=n=>{if(n<0n)return!1;if(n===0n)return!0;let t=1n,e=n;for(;t+1n<e;){const r=(t+e)/2n;r*r<n?t=r:e=r}return n===t**2n||n===(t+1n)**2n},it=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;let t=n-1n,e=0n;for(;t%2n===0n;)t>>=1n,e+=1n;const[r,s]=[t,e];let o=y(2n,r,n);if(o===1n)return!0;for(let a=0n;a<s;a++){if(o===n-1n)return!0;o=o*o%n}return!1},ot=n=>{let t=5n,e=E(t,n);for(;e>0n;){if(t=t>0n?t+2n:t-2n,t*=-1n,t===-15n&&A(n))return[0n,0n];e=E(t,n)}return[t,e]},B=(n,t)=>(n&1n)===1n?m(n+t>>1n,t):m(n>>1n,t),ct=(n,t,e,r)=>{let s=1n,i=e;const o=n.toString(2).slice(1);for(const a of o)[s,i]=[m(s*i,t),B(i*i+r*s*s,t)],a==="1"&&([s,i]=[B(e*s+i,t),B(r*s+e*i,t)]);return[s,i]},at=(n,t,e,r)=>{if(n%2n!==1n)throw Error("`n` must be odd");let s=n+1n,i=0n;for(;s%2n===0n;)s>>=1n,i+=1n;const[o,a]=ct(s,n,e,t);let l=a;if(o===0n)return!0;r=y(r,s,n);for(let u=0n;u<i;u++){if(l===0n)return!0;l=m(l*l-2n*r,n),r=y(r,2n,n)}return!1},S=n=>{if(n<=1n)return!1;if(n%2n===0n)return n===2n;const t=[2n,3n,5n,7n,11n,13n,17n,19n,23n,29n,31n,37n,41n,43n,47n,53n,59n,61n,67n,71n,73n,79n,83n,89n,97n,101n];for(const i of t)if(n%i===0n)return n===i;if(!it(n))return!1;const[e,r]=ot(n);if(r===0n)return!1;const s=(1n-e)/4n;return at(n,e,1n,s)},lt=(n,t)=>{if(t<2n)throw Error("NoPrimesFound");for(let r=0;r<1e5;r++){const s=v(n,t);if(S(s))return s}throw Error("NoPrimesFound")},ut=(n,t=!1)=>{if(n<2)throw Error("NoPrimesFound");for(let r=0;r<1e5;r++){const s=I(n,t);if(S(s))return s}throw Error("NoPrimesFound")},T="Rational";class f{#t;#n;static name=T;constructor(t,e){e===0n?(this.#n=0n,this.#t=t===0n?0n:t>0n?1n:-1n):e>0n?(this.#t=t,this.#n=e):(this.#t=-t,this.#n=-e),this.#e()}static fromDecimal(t,e=5){if(Number.isNaN(t))return new f(0n,0n);if(Math.abs(t)===1/0)return new f(t>0?1n:-1n,0n);const r=t<0;r&&(t*=-1);const s=BigInt(Math.floor(t)),i=t-Number(s);if(i===0)return new f(r?-s:s,1n);t=1/i;let[o,a]=[1n,s],[l,u]=[0n,1n];for(;`${u}`.length<e+1;){const h=BigInt(Math.floor(t)),d=t-Number(h);if([o,a]=[a,h*a+o],[l,u]=[u,h*u+l],d===0)return new f(r?-a:a,u);t=1/d}return new f(r?-o:o,l)}#e(){const{gcd:t}=L(this.#t,this.#n);t!==0n&&(this.#t/=t,this.#n/=t)}minus(){return new f(-this.#t,this.#n)}inverse(){return new f(this.#n,this.#t)}add(t){const e=this.#n*t.#n,r=this.#t*t.#n+t.#t*this.#n;return new f(r,e)}substr(t){return this.add(t.minus())}multiply(t){const e=this.#n*t.#n,r=this.#t*t.#t;return new f(r,e)}divide(t){return this.multiply(t.inverse())}mediant(t){const e=this.#n+t.#n,r=this.#t+t.#t;return new f(r,e)}toDecimal(){return Number(this.#t)/Number(this.#n)}toString(){return this.#t===0n&&this.#n===0n?"NaN":this.#t===0n?"0":this.#n===0n?this.#t<0n?"-Infinity":"Infinity":this.#n===1n?`${this.#t}`:`${this.#t}/${this.#n}`}valueOf(){return this.toDecimal()}toJSON(){return{type:"Rational",value:["0x"+this.#t.toString(16),"0x"+this.#n.toString(16)]}}static fromData(t){const e=BigInt(t.value[0]),r=BigInt(t.value[1]);return new f(e,r)}static parse(t){const r=/^\s*(\d+)\s*\/\s*(\d+)\s*$/.exec(t);if(!r)throw Error("cannot parse");const s=r.at(1),i=r.at(2);if(!s||!i)throw Error("cannot parse");return new f(BigInt(s),BigInt(i))}}Object.defineProperty(f.prototype,Symbol.toStringTag,{value:T});const P=n=>{const t=Array.from(n,e=>String.fromCharCode(e));return btoa(t.join(""))},C=n=>{const t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))},ft=n=>P(n).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,""),ht=n=>{const t=n.length&3;t>0&&(n=n+"=".repeat(4-t));const e=n.replaceAll("-","+").replaceAll("_","/");return C(e)},dt=n=>{let t=Array.from(n,i=>i.toString(16).padStart(2,"0")).join("");const e=t.length%6;e&&(t="0".repeat(6-e)+t);const r=t.matchAll(/.{6}/g);return Array.from(r,i=>Number.parseInt(i[0],16).toString(8).padStart(8,"0")).join("").replace(/^0+/,"")},gt=n=>{const t=n.length&7;t&&(n="0".repeat(8-t)+n);const e=n.matchAll(/.{8}/g),s=Array.from(e,i=>{const o=i[0];return Number.parseInt(o,8).toString(16).padStart(6,"0")}).join("").matchAll(/.{2}/g);return Uint8Array.from(s,i=>Number.parseInt(i[0],16))},mt=n=>{const t=n<0n;t&&(n*=-1n);const e=n.toString(2).length,r=n===1n<<BigInt(e-1)&&!(e%7)&&t,s=Math.floor(e/7)+1;return r?s-1:s},yt=n=>{const t=mt(n);n=BigInt.asUintN(t*7,n);const e=new Uint8Array(t);for(let s=0;s<t-1;++s){const i=Number(n&127n)|128;e[s]=i,n>>=7n}const r=Number(n&127n);return e[t-1]=r,n>>=7n,e},pt=n=>{const t=n.length;let e=0n;for(let r=0;r<t;++r){const s=BigInt(n[r]&127);e+=s<<BigInt(7*r)}return BigInt.asIntN(7*t,e)},j=n=>{if(n===0)return 32;let t=0;for(;n>0&&!(n&1);)++t,n>>>=1;return t},_="FloatRng",O=n=>{if(n===0n)return 64n;let t=0n;for(;n>0n&&!(n&1n);)++t,n>>=1n;return BigInt.asUintN(64,t)};class F{#t;static name=_;constructor(t){this.#t=t}#n(){const r=(()=>{switch(this.#t.bits){case 32:return this.#t.getU32Rand()>>>0;case 64:{const l=this.#t.getU64Rand()&0xffffffffn;return Number(l)}}})(),s=r&255;let i=126;if(s===0){i-=8;const l=1e5;let u=0;t:for(;;){if(u>l)throw Error("loop exceeded limit");const h=(()=>{switch(this.#t.bits){case 32:return this.#t.getU32Rand()>>>0;case 64:{const d=BigInt.asUintN(32,this.#t.getU64Rand());return Number(d)}}})();if(h===0){if(i-=32,i<0){i=0;break t}}else{i-=j(h);break t}++u}}else i-=j(s);const o=r>>>8&8388607;o===0&&r>>>31&&++i;const a=Uint32Array.from([i<<23|o]);return new Float32Array(a.buffer)[0]}getF32Rand(){for(let e=0;e<1e5;++e){const r=this.#n();if(r<1)return r}throw Error("exceeded loop limit")}#e(){const t=0n,e=1023n,r=(()=>{switch(this.#t.bits){case 32:{const l=BigInt(this.#t.getU32Rand()>>>0),u=BigInt(this.#t.getU32Rand()>>>0);return l<<32n|u}case 64:return BigInt.asUintN(64,this.#t.getU64Rand())}})(),s=r&0x7ffn;let i=e-1n;if(s===0n){i-=11n;const l=1e5;let u=0;t:for(;;){if(u>l)throw Error("loop exceeded limit");const h=(()=>{switch(this.#t.bits){case 32:{const d=BigInt(this.#t.getU32Rand()>>>0),R=BigInt(this.#t.getU32Rand()>>>0);return d<<32n|R}case 64:return BigInt.asUintN(64,this.#t.getU64Rand())}})();if(h===0n){if(i-=64n,i<t){i=t;break t}}else{i-=O(h);break t}++u}}else i-=O(s);const o=BigInt.asUintN(52,r>>11n);o===0n&&r>>63n&&++i;const a=BigUint64Array.from([i<<52n|o]);return new Float64Array(a.buffer)[0]}getF64Rand(){for(let e=0;e<1e5;++e){const r=this.#e();if(r<1)return r}throw Error("exceeded loop limit")}}Object.defineProperty(F.prototype,Symbol.toStringTag,{value:_});const It=[0x853c49e6748fea9bn,0xda3e39cb94b95bdbn],wt=0x5851f42d4c957f2dn,V="PCGMinimal";class ${#t;static name=V;bits=32;constructor(t){t&&t.length>=2?(this.#t=new BigUint64Array(2),this.#t[1]=t[1]<<1n|1n,this.#n(),this.#t[0]+=t[0],this.#n()):this.#t=BigUint64Array.from(It)}#n(){this.#t[0]=this.#t[0]*wt+this.#t[1]}get#e(){const t=this.#t[0],e=Number(t>>59n),r=Number(BigInt.asUintN(32,(t^t>>18n)>>27n));return M(r,e)}getU32Rand(){return this.#n(),this.#e}getBoundedU32Rand(t){if(t>4294967296)throw Error("`bound` exceeded limit (2^32)");if(t<=0)throw Error("'bound' must be positive");const r=4294967296%t,s=1e5;for(let i=0;i<s;++i){const o=this.getU32Rand();if(o>=r)return o%t}throw Error("exceeded loop limit")}*genU32Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;r++)yield typeof e=="number"?this.getBoundedU32Rand(e):this.getU32Rand()}}Object.defineProperty($.prototype,Symbol.toStringTag,{value:V});const bt=[0xbe562cb412e2260en,0x2e4284137d641affn,0x4e19b36ee933e27en,0x7581cf8c4f4d4f7dn];class U{bits=64;#t;static name="XoshiroMinimal";constructor(t){t&&t.length>=4?(this.#t=new BigUint64Array(4),this.#t[0]=t[0],this.#t[1]=t[1],this.#n(),this.#t[2]+=t[2],this.#t[3]+=t[3]):this.#t=BigUint64Array.from(bt)}#n(){const t=this.#t[1]<<17n;this.#t[2]^=this.#t[0],this.#t[3]^=this.#t[1],this.#t[1]^=this.#t[2],this.#t[0]^=this.#t[3],this.#t[2]^=t,this.#t[3]=b(this.#t[3],45n)}get value(){const t=b(this.#t[0]+this.#t[3],23n)+this.#t[0];return BigInt.asUintN(64,t)}getU64Rand(){const t=this.value;return this.#n(),t}getU32Rand(){const t=BigInt.asUintN(32,this.getU64Rand());return Number(t)}getBoundedU64Rand(t){const e=1n<<64n;if(t>e)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=e%t,s=1e5;for(let i=0;i<s;++i){const o=this.getU64Rand();if(o>=r)return o%t}throw Error("exceeded loop limit")}getBoundedU32Rand(t){if(t>4294967296)throw Error("'bound' exceeded limit");if(t<=0n)throw Error("'bound' must be positive");const r=this.getBoundedU64Rand(BigInt(t));return Number(r)}*genU64Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getU64Rand():this.getBoundedU64Rand(e)}*genU32Rands(t,e){if(t<=0)throw Error("'step' must be positive");for(let r=0;r<t;++r)yield e===void 0?this.getU32Rand():this.getBoundedU32Rand(e)}}Object.defineProperty(U.prototype,Symbol.toStringTag,{value:U.name});const D="WorkerStream";class q extends ReadableStream{close;#t;static name=D;constructor(t,e){let r,s,i;super({start:o=>{r=a=>{o.enqueue(a.data)},s=a=>{t.removeEventListener("message",r),t.removeEventListener("error",s);const l=new p("WorkerStreamError",a.message,{cause:a.error});o.error(l)},i=()=>{t.removeEventListener("message",r),t.removeEventListener("error",s),o.close()},t.addEventListener("message",r),t.addEventListener("error",s)},cancel:o=>{console.log("Canceled reason:",o),t.removeEventListener("message",r),t.removeEventListener("error",s)}},e),this.close=i,this.#t=t}postMessage(t,e){this.#t.postMessage(t,e)}}return Object.defineProperty(q.prototype,Symbol.toStringTag,{value:D}),c.FloatRng=F,c.NamedError=p,c.PCGMinimal=$,c.Rational=f,c.WorkerStream=q,c.XoshiroMinimal=U,c.bailliePSW=S,c.compress=Q,c.decodeLEB128=pt,c.decodeRFC3986URIComponent=x,c.decompress=tt,c.encodeLEB128=yt,c.encodeRFC3986URIComponent=Z,c.exEuclidean=L,c.factorial=st,c.fromBase64=C,c.fromBase64Url=ht,c.fromOct=gt,c.getHash=J,c.getRandBIByBitLength=I,c.getRandBIByRange=v,c.getRandPrimeByBitLength=ut,c.getRandPrimeByRange=lt,c.getRndInt=et,c.getStringTag=z,c.isDeepStrictEqual=g,c.isNode=Y,c.isSquare=A,c.jacobiSymbol=E,c.lazify=X,c.modPow=y,c.parseCSV=H,c.residue=m,c.rot32=M,c.rot64=b,c.sameValueZero=K,c.setTimeoutPromise=nt,c.sleep=G,c.toBase64=P,c.toBase64Url=ft,c.toOct=dt,c.withResolvers=W,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c})({});
|
package/dist/main.d.ts
CHANGED
package/dist/math.d.ts
CHANGED
package/dist/util.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export declare const sleep: (delay: number) => Promise<void>;
|
|
|
30
30
|
* @param obj
|
|
31
31
|
* @returns
|
|
32
32
|
*/
|
|
33
|
-
export declare const getStringTag: (obj: unknown) => string
|
|
33
|
+
export declare const getStringTag: (obj: unknown) => string;
|
|
34
34
|
/**
|
|
35
35
|
* makes a function lazy
|
|
36
36
|
* @param func function
|
|
@@ -72,9 +72,9 @@ export declare const decodeRFC3986URIComponent: (encodedURIComponent: string) =>
|
|
|
72
72
|
export declare const compress: (raw: Uint8Array<ArrayBuffer>, format: CompressionFormat) => Promise<Uint8Array<ArrayBuffer>>;
|
|
73
73
|
export declare const decompress: (compressed: Uint8Array<ArrayBuffer>, format: CompressionFormat) => Promise<Uint8Array<ArrayBuffer>>;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
75
|
+
* Schedules execution of a one-time `callback` after `delay` milliseconds, and returns promise resolved by a return value of `callback`.
|
|
76
|
+
* @param callback
|
|
77
|
+
* @param delay **Default:** `1`
|
|
78
78
|
* @returns
|
|
79
79
|
*/
|
|
80
|
-
export declare const setTimeoutPromise: <
|
|
80
|
+
export declare const setTimeoutPromise: <TRtrn>(callback: () => TRtrn, delay?: number) => Promise<TRtrn>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tktb-tess/util-fns",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Utility functions for personal use",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/tktb-tess/util-fns/blob/main/README.md",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^25.0.3",
|
|
30
30
|
"tsx": "^4.21.0",
|
|
31
31
|
"typescript": "^5.9.3",
|
|
32
|
-
"vite": "^7.
|
|
32
|
+
"vite": "^7.3.0",
|
|
33
33
|
"vite-plugin-dts": "^4.5.4",
|
|
34
|
-
"vitest": "^4.0.
|
|
34
|
+
"vitest": "^4.0.16"
|
|
35
35
|
},
|
|
36
36
|
"volta": {
|
|
37
37
|
"node": "22.21.0"
|
|
File without changes
|