cafe-utility 27.12.0 → 27.13.0
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/index.d.ts +4 -1
- package/index.js +24 -22
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ declare function replaceDeep(object: CafeObject, path: string, value: unknown):
|
|
|
49
49
|
declare function getFirstDeep(object: CafeObject, paths: string[], fallbackToAnyKey?: boolean): unknown;
|
|
50
50
|
declare function forever(callable: (() => Promise<void>) | (() => void), millis: number, log?: (message: string, metadata: object) => void): Promise<never>;
|
|
51
51
|
declare function runAndSetInterval(callable: () => void, millis: number): () => void;
|
|
52
|
+
declare function whereAmI(): 'browser' | 'node';
|
|
52
53
|
declare function asMegabytes(number: number): number;
|
|
53
54
|
declare function convertBytes(bytes: number): string;
|
|
54
55
|
declare function hexToRgb(hex: string): [number, number, number];
|
|
@@ -767,6 +768,7 @@ export declare const System: {
|
|
|
767
768
|
waitFor: typeof waitFor;
|
|
768
769
|
expandError: typeof expandError;
|
|
769
770
|
runAndSetInterval: typeof runAndSetInterval;
|
|
771
|
+
whereAmI: typeof whereAmI;
|
|
770
772
|
};
|
|
771
773
|
export declare const Numbers: {
|
|
772
774
|
make: typeof makeNumber;
|
|
@@ -1044,4 +1046,5 @@ export declare const Vector: {
|
|
|
1044
1046
|
raycastCircle: typeof raycastCircle;
|
|
1045
1047
|
getLineIntersectionPoint: typeof getLineIntersectionPoint;
|
|
1046
1048
|
};
|
|
1047
|
-
export {};
|
|
1049
|
+
export { };
|
|
1050
|
+
|
package/index.js
CHANGED
|
@@ -253,6 +253,9 @@ function runAndSetInterval(n, e) {
|
|
|
253
253
|
}, e)
|
|
254
254
|
return () => clearInterval(t)
|
|
255
255
|
}
|
|
256
|
+
function whereAmI() {
|
|
257
|
+
return Object.prototype.hasOwnProperty.call(globalThis, 'process') ? 'node' : 'browser'
|
|
258
|
+
}
|
|
256
259
|
function asMegabytes(n) {
|
|
257
260
|
return n / 1024 / 1024
|
|
258
261
|
}
|
|
@@ -1113,7 +1116,7 @@ function uint8ArrayToBase(n, e) {
|
|
|
1113
1116
|
)
|
|
1114
1117
|
}
|
|
1115
1118
|
function hexToUint8Array(n) {
|
|
1116
|
-
n.startsWith('0x') && (n = n.slice(2))
|
|
1119
|
+
;(n.startsWith('0x') || n.startsWith('0X')) && (n = n.slice(2))
|
|
1117
1120
|
const e = n.length / 2,
|
|
1118
1121
|
t = new Uint8Array(e)
|
|
1119
1122
|
for (let r = 0; r < e; r++) {
|
|
@@ -2316,8 +2319,8 @@ function keccakPermutate(n) {
|
|
|
2316
2319
|
S = (n[4] << 30) | (n[5] >>> 2),
|
|
2317
2320
|
R = (n[6] << 28) | (n[7] >>> 4),
|
|
2318
2321
|
D = (n[7] << 28) | (n[6] >>> 4),
|
|
2319
|
-
|
|
2320
|
-
|
|
2322
|
+
C = (n[8] << 27) | (n[9] >>> 5),
|
|
2323
|
+
I = (n[9] << 27) | (n[8] >>> 5),
|
|
2321
2324
|
v = (n[11] << 4) | (n[10] >>> 28),
|
|
2322
2325
|
B = (n[10] << 4) | (n[11] >>> 28),
|
|
2323
2326
|
P = (n[13] << 12) | (n[12] >>> 20),
|
|
@@ -2328,8 +2331,8 @@ function keccakPermutate(n) {
|
|
|
2328
2331
|
z = (n[16] << 23) | (n[17] >>> 9),
|
|
2329
2332
|
F = (n[18] << 20) | (n[19] >>> 12),
|
|
2330
2333
|
q = (n[19] << 20) | (n[18] >>> 12),
|
|
2331
|
-
|
|
2332
|
-
|
|
2334
|
+
W = (n[20] << 3) | (n[21] >>> 29),
|
|
2335
|
+
H = (n[21] << 3) | (n[20] >>> 29),
|
|
2333
2336
|
V = (n[22] << 10) | (n[23] >>> 22),
|
|
2334
2337
|
J = (n[23] << 10) | (n[22] >>> 22),
|
|
2335
2338
|
K = (n[25] << 11) | (n[24] >>> 21),
|
|
@@ -2368,12 +2371,12 @@ function keccakPermutate(n) {
|
|
|
2368
2371
|
(n[7] = cn ^ (~xn & M)),
|
|
2369
2372
|
(n[8] = yn ^ (~E & P)),
|
|
2370
2373
|
(n[9] = xn ^ (~M & U)),
|
|
2371
|
-
(n[10] = R ^ (~F &
|
|
2372
|
-
(n[11] = D ^ (~q &
|
|
2373
|
-
(n[12] = F ^ (~
|
|
2374
|
-
(n[13] = q ^ (~
|
|
2375
|
-
(n[14] =
|
|
2376
|
-
(n[15] =
|
|
2374
|
+
(n[10] = R ^ (~F & W)),
|
|
2375
|
+
(n[11] = D ^ (~q & H)),
|
|
2376
|
+
(n[12] = F ^ (~W & en)),
|
|
2377
|
+
(n[13] = q ^ (~H & tn)),
|
|
2378
|
+
(n[14] = W ^ (~en & pn)),
|
|
2379
|
+
(n[15] = H ^ (~tn & mn)),
|
|
2377
2380
|
(n[16] = en ^ (~pn & R)),
|
|
2378
2381
|
(n[17] = tn ^ (~mn & D)),
|
|
2379
2382
|
(n[18] = pn ^ (~R & F)),
|
|
@@ -2388,16 +2391,16 @@ function keccakPermutate(n) {
|
|
|
2388
2391
|
(n[27] = fn ^ (~an & k)),
|
|
2389
2392
|
(n[28] = ln ^ (~O & L)),
|
|
2390
2393
|
(n[29] = an ^ (~k & j)),
|
|
2391
|
-
(n[30] =
|
|
2392
|
-
(n[31] =
|
|
2394
|
+
(n[30] = C ^ (~v & V)),
|
|
2395
|
+
(n[31] = I ^ (~B & J)),
|
|
2393
2396
|
(n[32] = v ^ (~V & rn)),
|
|
2394
2397
|
(n[33] = B ^ (~J & on)),
|
|
2395
2398
|
(n[34] = V ^ (~rn & gn)),
|
|
2396
2399
|
(n[35] = J ^ (~on & wn)),
|
|
2397
|
-
(n[36] = rn ^ (~gn &
|
|
2398
|
-
(n[37] = on ^ (~wn &
|
|
2399
|
-
(n[38] = gn ^ (~
|
|
2400
|
-
(n[39] = wn ^ (~
|
|
2400
|
+
(n[36] = rn ^ (~gn & C)),
|
|
2401
|
+
(n[37] = on ^ (~wn & I)),
|
|
2402
|
+
(n[38] = gn ^ (~C & v)),
|
|
2403
|
+
(n[39] = wn ^ (~I & B)),
|
|
2401
2404
|
(n[40] = T ^ (~N & G)),
|
|
2402
2405
|
(n[41] = S ^ (~z & Y)),
|
|
2403
2406
|
(n[42] = N ^ (~G & X)),
|
|
@@ -2758,10 +2761,9 @@ class FixedPointNumber {
|
|
|
2758
2761
|
}
|
|
2759
2762
|
divmod(e) {
|
|
2760
2763
|
if (e === 0n) throw new Error('Division by zero is not allowed')
|
|
2761
|
-
const t =
|
|
2762
|
-
r =
|
|
2763
|
-
|
|
2764
|
-
return [new FixedPointNumber(r, this.scale), new FixedPointNumber(o, this.scale)]
|
|
2764
|
+
const t = this.value / e,
|
|
2765
|
+
r = this.value % e
|
|
2766
|
+
return [new FixedPointNumber(t, this.scale), new FixedPointNumber(r, this.scale)]
|
|
2765
2767
|
}
|
|
2766
2768
|
exchange(e, t, r) {
|
|
2767
2769
|
if (e === '*') {
|
|
@@ -3173,7 +3175,7 @@ class AsyncQueue {
|
|
|
3173
3175
|
multicall,
|
|
3174
3176
|
maxBy
|
|
3175
3177
|
}),
|
|
3176
|
-
(exports.System = { sleepMillis, forever, scheduleMany, waitFor, expandError, runAndSetInterval }),
|
|
3178
|
+
(exports.System = { sleepMillis, forever, scheduleMany, waitFor, expandError, runAndSetInterval, whereAmI }),
|
|
3177
3179
|
(exports.Numbers = {
|
|
3178
3180
|
make: makeNumber,
|
|
3179
3181
|
sum,
|