cafe-utility 27.14.1 → 27.15.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 -0
- package/index.js +56 -40
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -229,6 +229,7 @@ declare function indexOfRegex(string: string, regex: RegExp, start?: number): Re
|
|
|
229
229
|
declare function lineMatches(haystack: string, needles: (string | RegExp)[], orderMatters?: boolean): boolean;
|
|
230
230
|
declare function linesMatchInOrder(lines: string[], expectations: (string | RegExp)[][], orderMatters?: boolean): boolean;
|
|
231
231
|
declare function csvEscape(string: string): string;
|
|
232
|
+
declare function allIndexOf(string: string, searchString: string, start?: number): number[];
|
|
232
233
|
declare function indexOfEarliest(string: string, searchStrings: string[], start?: number): number;
|
|
233
234
|
declare function lastIndexOfBefore(string: string, searchString: string, start?: number): number;
|
|
234
235
|
declare function findWeightedPair(string: string, start?: number, opening?: string, closing?: string): number;
|
|
@@ -276,6 +277,7 @@ declare function containsWord(string: string, word: string): boolean;
|
|
|
276
277
|
declare function containsWords(string: string, words: string[], mode: 'any' | 'all'): boolean;
|
|
277
278
|
declare function parseHtmlAttributes(string: string): Record<string, string>;
|
|
278
279
|
declare function readNextWord(string: string, index: number, allowedCharacters?: string[]): string;
|
|
280
|
+
declare function readWordsAfterAll(string: string, after: string, allowedCharacters?: string[]): string[];
|
|
279
281
|
declare function resolveVariables(string: string, variables: Record<string, string>, prefix?: string, separator?: string): string;
|
|
280
282
|
declare function resolveVariableWithDefaultSyntax(string: string, key: string, value: string, prefix?: string, separator?: string): string;
|
|
281
283
|
declare function resolveRemainingVariablesWithDefaults(string: string, prefix?: string, separator?: string): string;
|
|
@@ -988,6 +990,7 @@ export declare const Strings: {
|
|
|
988
990
|
lastIndexOfBefore: typeof lastIndexOfBefore;
|
|
989
991
|
parseHtmlAttributes: typeof parseHtmlAttributes;
|
|
990
992
|
readNextWord: typeof readNextWord;
|
|
993
|
+
readWordsAfterAll: typeof readWordsAfterAll;
|
|
991
994
|
resolveVariables: typeof resolveVariables;
|
|
992
995
|
resolveVariableWithDefaultSyntax: typeof resolveVariableWithDefaultSyntax;
|
|
993
996
|
resolveRemainingVariablesWithDefaults: typeof resolveRemainingVariablesWithDefaults;
|
|
@@ -997,6 +1000,7 @@ export declare const Strings: {
|
|
|
997
1000
|
isValidObjectPathCharacter: typeof isValidObjectPathCharacter;
|
|
998
1001
|
insert: typeof insertString;
|
|
999
1002
|
indexOfRegex: typeof indexOfRegex;
|
|
1003
|
+
allIndexOf: typeof allIndexOf;
|
|
1000
1004
|
lineMatches: typeof lineMatches;
|
|
1001
1005
|
linesMatchInOrder: typeof linesMatchInOrder;
|
|
1002
1006
|
represent: typeof represent;
|
package/index.js
CHANGED
|
@@ -446,6 +446,8 @@ function asString(n, e) {
|
|
|
446
446
|
function asHexString(n, e) {
|
|
447
447
|
if (!isHexString(n)) throw new TypeError(`Expected hex string${e?.name ? ` for ${e.name}` : ''}, got: ` + n)
|
|
448
448
|
const t = n.replace(/^0x/, '')
|
|
449
|
+
if (t.length % 2 !== 0)
|
|
450
|
+
throw RangeError(`Expected even number of hex digits${e?.name ? ` for ${e.name}` : ''}; got: ` + n)
|
|
449
451
|
if (e && e.byteLength && t.length !== e.byteLength * 2)
|
|
450
452
|
throw RangeError(
|
|
451
453
|
`Expected hex string${e?.name ? ` for ${e.name}` : ''} of byte length ${e.byteLength}; got: ` + t
|
|
@@ -925,6 +927,12 @@ function linesMatchInOrder(n, e, t = !0) {
|
|
|
925
927
|
function csvEscape(n) {
|
|
926
928
|
return n.match(/"|,/) ? `"${n.replace(/"/g, '""')}"` : n
|
|
927
929
|
}
|
|
930
|
+
function allIndexOf(n, e, t = 0) {
|
|
931
|
+
const r = []
|
|
932
|
+
let o = n.indexOf(e, t)
|
|
933
|
+
for (; o !== -1; ) r.push(o), (o = n.indexOf(e, o + e.length))
|
|
934
|
+
return r
|
|
935
|
+
}
|
|
928
936
|
function indexOfEarliest(n, e, t = 0) {
|
|
929
937
|
let r = -1
|
|
930
938
|
for (const o of e) {
|
|
@@ -1244,6 +1252,12 @@ function readNextWord(n, e, t = []) {
|
|
|
1244
1252
|
for (; e < n.length && (isLetterOrDigit(n[e]) || t.includes(n[e])); ) r += n[e++]
|
|
1245
1253
|
return r
|
|
1246
1254
|
}
|
|
1255
|
+
function readWordsAfterAll(n, e, t = []) {
|
|
1256
|
+
const r = allIndexOf(n, e),
|
|
1257
|
+
o = []
|
|
1258
|
+
for (const i of r) o.push(readNextWord(n, i + e.length, t))
|
|
1259
|
+
return o
|
|
1260
|
+
}
|
|
1247
1261
|
function resolveVariables(n, e, t = '$', r = ':') {
|
|
1248
1262
|
for (const o in e) n = resolveVariableWithDefaultSyntax(n, o, e[o], t, r)
|
|
1249
1263
|
return (n = resolveRemainingVariablesWithDefaults(n)), n
|
|
@@ -2244,26 +2258,26 @@ function keccakPermutate(n) {
|
|
|
2244
2258
|
a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
|
|
2245
2259
|
h = (o << 1) | (i >>> 31),
|
|
2246
2260
|
bn = (i << 1) | (o >>> 31),
|
|
2247
|
-
|
|
2248
|
-
|
|
2261
|
+
d = l ^ h,
|
|
2262
|
+
p = a ^ bn,
|
|
2249
2263
|
$n = (u << 1) | (s >>> 31),
|
|
2250
2264
|
An = (s << 1) | (u >>> 31),
|
|
2251
2265
|
m = t ^ $n,
|
|
2252
2266
|
g = r ^ An,
|
|
2253
2267
|
En = (c << 1) | (f >>> 31),
|
|
2254
|
-
|
|
2268
|
+
On = (f << 1) | (c >>> 31),
|
|
2255
2269
|
w = o ^ En,
|
|
2256
|
-
y = i ^
|
|
2257
|
-
|
|
2270
|
+
y = i ^ On,
|
|
2271
|
+
Mn = (l << 1) | (a >>> 31),
|
|
2258
2272
|
kn = (a << 1) | (l >>> 31),
|
|
2259
|
-
x = u ^
|
|
2273
|
+
x = u ^ Mn,
|
|
2260
2274
|
b = s ^ kn,
|
|
2261
2275
|
Tn = (t << 1) | (r >>> 31),
|
|
2262
2276
|
Sn = (r << 1) | (t >>> 31),
|
|
2263
2277
|
$ = c ^ Tn,
|
|
2264
2278
|
A = f ^ Sn
|
|
2265
|
-
;(n[0] ^=
|
|
2266
|
-
(n[1] ^=
|
|
2279
|
+
;(n[0] ^= d),
|
|
2280
|
+
(n[1] ^= p),
|
|
2267
2281
|
(n[2] ^= m),
|
|
2268
2282
|
(n[3] ^= g),
|
|
2269
2283
|
(n[4] ^= w),
|
|
@@ -2272,8 +2286,8 @@ function keccakPermutate(n) {
|
|
|
2272
2286
|
(n[7] ^= b),
|
|
2273
2287
|
(n[8] ^= $),
|
|
2274
2288
|
(n[9] ^= A),
|
|
2275
|
-
(n[10] ^=
|
|
2276
|
-
(n[11] ^=
|
|
2289
|
+
(n[10] ^= d),
|
|
2290
|
+
(n[11] ^= p),
|
|
2277
2291
|
(n[12] ^= m),
|
|
2278
2292
|
(n[13] ^= g),
|
|
2279
2293
|
(n[14] ^= w),
|
|
@@ -2282,8 +2296,8 @@ function keccakPermutate(n) {
|
|
|
2282
2296
|
(n[17] ^= b),
|
|
2283
2297
|
(n[18] ^= $),
|
|
2284
2298
|
(n[19] ^= A),
|
|
2285
|
-
(n[20] ^=
|
|
2286
|
-
(n[21] ^=
|
|
2299
|
+
(n[20] ^= d),
|
|
2300
|
+
(n[21] ^= p),
|
|
2287
2301
|
(n[22] ^= m),
|
|
2288
2302
|
(n[23] ^= g),
|
|
2289
2303
|
(n[24] ^= w),
|
|
@@ -2292,8 +2306,8 @@ function keccakPermutate(n) {
|
|
|
2292
2306
|
(n[27] ^= b),
|
|
2293
2307
|
(n[28] ^= $),
|
|
2294
2308
|
(n[29] ^= A),
|
|
2295
|
-
(n[30] ^=
|
|
2296
|
-
(n[31] ^=
|
|
2309
|
+
(n[30] ^= d),
|
|
2310
|
+
(n[31] ^= p),
|
|
2297
2311
|
(n[32] ^= m),
|
|
2298
2312
|
(n[33] ^= g),
|
|
2299
2313
|
(n[34] ^= w),
|
|
@@ -2302,8 +2316,8 @@ function keccakPermutate(n) {
|
|
|
2302
2316
|
(n[37] ^= b),
|
|
2303
2317
|
(n[38] ^= $),
|
|
2304
2318
|
(n[39] ^= A),
|
|
2305
|
-
(n[40] ^=
|
|
2306
|
-
(n[41] ^=
|
|
2319
|
+
(n[40] ^= d),
|
|
2320
|
+
(n[41] ^= p),
|
|
2307
2321
|
(n[42] ^= m),
|
|
2308
2322
|
(n[43] ^= g),
|
|
2309
2323
|
(n[44] ^= w),
|
|
@@ -2313,15 +2327,15 @@ function keccakPermutate(n) {
|
|
|
2313
2327
|
(n[48] ^= $),
|
|
2314
2328
|
(n[49] ^= A)
|
|
2315
2329
|
const E = n[0],
|
|
2316
|
-
|
|
2317
|
-
|
|
2330
|
+
O = n[1],
|
|
2331
|
+
M = (n[2] << 1) | (n[3] >>> 31),
|
|
2318
2332
|
k = (n[3] << 1) | (n[2] >>> 31),
|
|
2319
2333
|
T = (n[5] << 30) | (n[4] >>> 2),
|
|
2320
2334
|
S = (n[4] << 30) | (n[5] >>> 2),
|
|
2321
2335
|
R = (n[6] << 28) | (n[7] >>> 4),
|
|
2322
2336
|
D = (n[7] << 28) | (n[6] >>> 4),
|
|
2323
|
-
|
|
2324
|
-
|
|
2337
|
+
I = (n[8] << 27) | (n[9] >>> 5),
|
|
2338
|
+
C = (n[9] << 27) | (n[8] >>> 5),
|
|
2325
2339
|
B = (n[11] << 4) | (n[10] >>> 28),
|
|
2326
2340
|
P = (n[10] << 4) | (n[11] >>> 28),
|
|
2327
2341
|
v = (n[13] << 12) | (n[12] >>> 20),
|
|
@@ -2355,63 +2369,63 @@ function keccakPermutate(n) {
|
|
|
2355
2369
|
ln = (n[40] << 18) | (n[41] >>> 14),
|
|
2356
2370
|
an = (n[41] << 18) | (n[40] >>> 14),
|
|
2357
2371
|
hn = (n[42] << 2) | (n[43] >>> 30),
|
|
2358
|
-
|
|
2359
|
-
|
|
2372
|
+
dn = (n[43] << 2) | (n[42] >>> 30),
|
|
2373
|
+
pn = (n[45] << 29) | (n[44] >>> 3),
|
|
2360
2374
|
mn = (n[44] << 29) | (n[45] >>> 3),
|
|
2361
2375
|
gn = (n[47] << 24) | (n[46] >>> 8),
|
|
2362
2376
|
wn = (n[46] << 24) | (n[47] >>> 8),
|
|
2363
2377
|
yn = (n[48] << 14) | (n[49] >>> 18),
|
|
2364
2378
|
xn = (n[49] << 14) | (n[48] >>> 18)
|
|
2365
2379
|
;(n[0] = E ^ (~v & K)),
|
|
2366
|
-
(n[1] =
|
|
2380
|
+
(n[1] = O ^ (~U & Z)),
|
|
2367
2381
|
(n[2] = v ^ (~K & un)),
|
|
2368
2382
|
(n[3] = U ^ (~Z & cn)),
|
|
2369
2383
|
(n[4] = K ^ (~un & yn)),
|
|
2370
2384
|
(n[5] = Z ^ (~cn & xn)),
|
|
2371
2385
|
(n[6] = un ^ (~yn & E)),
|
|
2372
|
-
(n[7] = cn ^ (~xn &
|
|
2386
|
+
(n[7] = cn ^ (~xn & O)),
|
|
2373
2387
|
(n[8] = yn ^ (~E & v)),
|
|
2374
|
-
(n[9] = xn ^ (~
|
|
2388
|
+
(n[9] = xn ^ (~O & U)),
|
|
2375
2389
|
(n[10] = R ^ (~F & W)),
|
|
2376
2390
|
(n[11] = D ^ (~q & H)),
|
|
2377
2391
|
(n[12] = F ^ (~W & en)),
|
|
2378
2392
|
(n[13] = q ^ (~H & tn)),
|
|
2379
|
-
(n[14] = W ^ (~en &
|
|
2393
|
+
(n[14] = W ^ (~en & pn)),
|
|
2380
2394
|
(n[15] = H ^ (~tn & mn)),
|
|
2381
|
-
(n[16] = en ^ (~
|
|
2395
|
+
(n[16] = en ^ (~pn & R)),
|
|
2382
2396
|
(n[17] = tn ^ (~mn & D)),
|
|
2383
|
-
(n[18] =
|
|
2397
|
+
(n[18] = pn ^ (~R & F)),
|
|
2384
2398
|
(n[19] = mn ^ (~D & q)),
|
|
2385
|
-
(n[20] =
|
|
2399
|
+
(n[20] = M ^ (~L & Q)),
|
|
2386
2400
|
(n[21] = k ^ (~j & _)),
|
|
2387
2401
|
(n[22] = L ^ (~Q & sn)),
|
|
2388
2402
|
(n[23] = j ^ (~_ & fn)),
|
|
2389
2403
|
(n[24] = Q ^ (~sn & ln)),
|
|
2390
2404
|
(n[25] = _ ^ (~fn & an)),
|
|
2391
|
-
(n[26] = sn ^ (~ln &
|
|
2405
|
+
(n[26] = sn ^ (~ln & M)),
|
|
2392
2406
|
(n[27] = fn ^ (~an & k)),
|
|
2393
|
-
(n[28] = ln ^ (~
|
|
2407
|
+
(n[28] = ln ^ (~M & L)),
|
|
2394
2408
|
(n[29] = an ^ (~k & j)),
|
|
2395
|
-
(n[30] =
|
|
2396
|
-
(n[31] =
|
|
2409
|
+
(n[30] = I ^ (~B & V)),
|
|
2410
|
+
(n[31] = C ^ (~P & J)),
|
|
2397
2411
|
(n[32] = B ^ (~V & rn)),
|
|
2398
2412
|
(n[33] = P ^ (~J & on)),
|
|
2399
2413
|
(n[34] = V ^ (~rn & gn)),
|
|
2400
2414
|
(n[35] = J ^ (~on & wn)),
|
|
2401
|
-
(n[36] = rn ^ (~gn &
|
|
2402
|
-
(n[37] = on ^ (~wn &
|
|
2403
|
-
(n[38] = gn ^ (~
|
|
2404
|
-
(n[39] = wn ^ (~
|
|
2415
|
+
(n[36] = rn ^ (~gn & I)),
|
|
2416
|
+
(n[37] = on ^ (~wn & C)),
|
|
2417
|
+
(n[38] = gn ^ (~I & B)),
|
|
2418
|
+
(n[39] = wn ^ (~C & P)),
|
|
2405
2419
|
(n[40] = T ^ (~N & G)),
|
|
2406
2420
|
(n[41] = S ^ (~z & Y)),
|
|
2407
2421
|
(n[42] = N ^ (~G & X)),
|
|
2408
2422
|
(n[43] = z ^ (~Y & nn)),
|
|
2409
2423
|
(n[44] = G ^ (~X & hn)),
|
|
2410
|
-
(n[45] = Y ^ (~nn &
|
|
2424
|
+
(n[45] = Y ^ (~nn & dn)),
|
|
2411
2425
|
(n[46] = X ^ (~hn & T)),
|
|
2412
|
-
(n[47] = nn ^ (~
|
|
2426
|
+
(n[47] = nn ^ (~dn & S)),
|
|
2413
2427
|
(n[48] = hn ^ (~T & N)),
|
|
2414
|
-
(n[49] =
|
|
2428
|
+
(n[49] = dn ^ (~S & z)),
|
|
2415
2429
|
(n[0] ^= IOTA_CONSTANTS[e * 2]),
|
|
2416
2430
|
(n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
|
|
2417
2431
|
}
|
|
@@ -3391,6 +3405,7 @@ class AsyncQueue {
|
|
|
3391
3405
|
lastIndexOfBefore,
|
|
3392
3406
|
parseHtmlAttributes,
|
|
3393
3407
|
readNextWord,
|
|
3408
|
+
readWordsAfterAll,
|
|
3394
3409
|
resolveVariables,
|
|
3395
3410
|
resolveVariableWithDefaultSyntax,
|
|
3396
3411
|
resolveRemainingVariablesWithDefaults,
|
|
@@ -3400,6 +3415,7 @@ class AsyncQueue {
|
|
|
3400
3415
|
isValidObjectPathCharacter,
|
|
3401
3416
|
insert: insertString,
|
|
3402
3417
|
indexOfRegex,
|
|
3418
|
+
allIndexOf,
|
|
3403
3419
|
lineMatches,
|
|
3404
3420
|
linesMatchInOrder,
|
|
3405
3421
|
represent,
|