cafe-utility 26.5.0 → 26.6.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/index.d.ts +2 -0
- package/index.js +27 -21
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -511,6 +511,7 @@ declare function proximity(one: Uint8Array, other: Uint8Array, max: number): num
|
|
|
511
511
|
declare function commonPrefix(one: Uint8Array, other: Uint8Array): Uint8Array;
|
|
512
512
|
declare function setBit(bytes: Uint8Array, index: number, value: 0 | 1): void;
|
|
513
513
|
declare function getBit(bytes: Uint8Array, index: number): 0 | 1;
|
|
514
|
+
declare function binaryIndexOf(array: Uint8Array, value: Uint8Array, start?: number): number;
|
|
514
515
|
interface Uint8ArrayIO {
|
|
515
516
|
max: () => number;
|
|
516
517
|
}
|
|
@@ -623,6 +624,7 @@ export declare const Binary: {
|
|
|
623
624
|
commonPrefix: typeof commonPrefix;
|
|
624
625
|
setBit: typeof setBit;
|
|
625
626
|
getBit: typeof getBit;
|
|
627
|
+
indexOf: typeof binaryIndexOf;
|
|
626
628
|
};
|
|
627
629
|
export declare const Random: {
|
|
628
630
|
intBetween: typeof intBetween;
|
package/index.js
CHANGED
|
@@ -2178,10 +2178,10 @@ function keccakPermutate(n) {
|
|
|
2178
2178
|
h = (o << 1) | (i >>> 31),
|
|
2179
2179
|
bn = (i << 1) | (o >>> 31),
|
|
2180
2180
|
p = l ^ h,
|
|
2181
|
-
|
|
2181
|
+
d = a ^ bn,
|
|
2182
2182
|
$n = (u << 1) | (s >>> 31),
|
|
2183
2183
|
An = (s << 1) | (u >>> 31),
|
|
2184
|
-
|
|
2184
|
+
m = t ^ $n,
|
|
2185
2185
|
g = r ^ An,
|
|
2186
2186
|
Mn = (c << 1) | (f >>> 31),
|
|
2187
2187
|
On = (f << 1) | (c >>> 31),
|
|
@@ -2196,8 +2196,8 @@ function keccakPermutate(n) {
|
|
|
2196
2196
|
$ = c ^ kn,
|
|
2197
2197
|
A = f ^ Dn
|
|
2198
2198
|
;(n[0] ^= p),
|
|
2199
|
-
(n[1] ^=
|
|
2200
|
-
(n[2] ^=
|
|
2199
|
+
(n[1] ^= d),
|
|
2200
|
+
(n[2] ^= m),
|
|
2201
2201
|
(n[3] ^= g),
|
|
2202
2202
|
(n[4] ^= y),
|
|
2203
2203
|
(n[5] ^= w),
|
|
@@ -2206,8 +2206,8 @@ function keccakPermutate(n) {
|
|
|
2206
2206
|
(n[8] ^= $),
|
|
2207
2207
|
(n[9] ^= A),
|
|
2208
2208
|
(n[10] ^= p),
|
|
2209
|
-
(n[11] ^=
|
|
2210
|
-
(n[12] ^=
|
|
2209
|
+
(n[11] ^= d),
|
|
2210
|
+
(n[12] ^= m),
|
|
2211
2211
|
(n[13] ^= g),
|
|
2212
2212
|
(n[14] ^= y),
|
|
2213
2213
|
(n[15] ^= w),
|
|
@@ -2216,8 +2216,8 @@ function keccakPermutate(n) {
|
|
|
2216
2216
|
(n[18] ^= $),
|
|
2217
2217
|
(n[19] ^= A),
|
|
2218
2218
|
(n[20] ^= p),
|
|
2219
|
-
(n[21] ^=
|
|
2220
|
-
(n[22] ^=
|
|
2219
|
+
(n[21] ^= d),
|
|
2220
|
+
(n[22] ^= m),
|
|
2221
2221
|
(n[23] ^= g),
|
|
2222
2222
|
(n[24] ^= y),
|
|
2223
2223
|
(n[25] ^= w),
|
|
@@ -2226,8 +2226,8 @@ function keccakPermutate(n) {
|
|
|
2226
2226
|
(n[28] ^= $),
|
|
2227
2227
|
(n[29] ^= A),
|
|
2228
2228
|
(n[30] ^= p),
|
|
2229
|
-
(n[31] ^=
|
|
2230
|
-
(n[32] ^=
|
|
2229
|
+
(n[31] ^= d),
|
|
2230
|
+
(n[32] ^= m),
|
|
2231
2231
|
(n[33] ^= g),
|
|
2232
2232
|
(n[34] ^= y),
|
|
2233
2233
|
(n[35] ^= w),
|
|
@@ -2236,8 +2236,8 @@ function keccakPermutate(n) {
|
|
|
2236
2236
|
(n[38] ^= $),
|
|
2237
2237
|
(n[39] ^= A),
|
|
2238
2238
|
(n[40] ^= p),
|
|
2239
|
-
(n[41] ^=
|
|
2240
|
-
(n[42] ^=
|
|
2239
|
+
(n[41] ^= d),
|
|
2240
|
+
(n[42] ^= m),
|
|
2241
2241
|
(n[43] ^= g),
|
|
2242
2242
|
(n[44] ^= y),
|
|
2243
2243
|
(n[45] ^= w),
|
|
@@ -2289,8 +2289,8 @@ function keccakPermutate(n) {
|
|
|
2289
2289
|
an = (n[41] << 18) | (n[40] >>> 14),
|
|
2290
2290
|
hn = (n[42] << 2) | (n[43] >>> 30),
|
|
2291
2291
|
pn = (n[43] << 2) | (n[42] >>> 30),
|
|
2292
|
-
|
|
2293
|
-
|
|
2292
|
+
dn = (n[45] << 29) | (n[44] >>> 3),
|
|
2293
|
+
mn = (n[44] << 29) | (n[45] >>> 3),
|
|
2294
2294
|
gn = (n[47] << 24) | (n[46] >>> 8),
|
|
2295
2295
|
yn = (n[46] << 24) | (n[47] >>> 8),
|
|
2296
2296
|
wn = (n[48] << 14) | (n[49] >>> 18),
|
|
@@ -2309,12 +2309,12 @@ function keccakPermutate(n) {
|
|
|
2309
2309
|
(n[11] = S ^ (~W & V)),
|
|
2310
2310
|
(n[12] = q ^ (~H & en)),
|
|
2311
2311
|
(n[13] = W ^ (~V & tn)),
|
|
2312
|
-
(n[14] = H ^ (~en &
|
|
2313
|
-
(n[15] = V ^ (~tn &
|
|
2314
|
-
(n[16] = en ^ (~
|
|
2315
|
-
(n[17] = tn ^ (~
|
|
2316
|
-
(n[18] =
|
|
2317
|
-
(n[19] =
|
|
2312
|
+
(n[14] = H ^ (~en & dn)),
|
|
2313
|
+
(n[15] = V ^ (~tn & mn)),
|
|
2314
|
+
(n[16] = en ^ (~dn & R)),
|
|
2315
|
+
(n[17] = tn ^ (~mn & S)),
|
|
2316
|
+
(n[18] = dn ^ (~R & q)),
|
|
2317
|
+
(n[19] = mn ^ (~S & W)),
|
|
2318
2318
|
(n[20] = E ^ (~j & _)),
|
|
2319
2319
|
(n[21] = T ^ (~U & Q)),
|
|
2320
2320
|
(n[22] = j ^ (~_ & sn)),
|
|
@@ -2443,6 +2443,11 @@ function getBit(n, e) {
|
|
|
2443
2443
|
r = e % 8
|
|
2444
2444
|
return (n[t] >> (7 - r)) & 1
|
|
2445
2445
|
}
|
|
2446
|
+
function binaryIndexOf(n, e, t = 0) {
|
|
2447
|
+
for (let r = t; r < n.length; r++)
|
|
2448
|
+
for (let o = 0; o < e.length && n[r + o] === e[o]; o++) if (o === e.length - 1) return r
|
|
2449
|
+
return -1
|
|
2450
|
+
}
|
|
2446
2451
|
class Uint8ArrayReader {
|
|
2447
2452
|
constructor(e) {
|
|
2448
2453
|
;(this.cursor = 0), (this.buffer = e)
|
|
@@ -2801,7 +2806,8 @@ class AsyncQueue {
|
|
|
2801
2806
|
proximity,
|
|
2802
2807
|
commonPrefix,
|
|
2803
2808
|
setBit,
|
|
2804
|
-
getBit
|
|
2809
|
+
getBit,
|
|
2810
|
+
indexOf: binaryIndexOf
|
|
2805
2811
|
}),
|
|
2806
2812
|
(exports.Random = {
|
|
2807
2813
|
intBetween,
|