cafe-utility 27.17.0 → 27.18.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 +38 -21
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -273,6 +273,8 @@ declare function breakLine(string: string): {
|
|
|
273
273
|
declare function measureTextWidth(string: string, characterWidths?: Record<string, number>): number;
|
|
274
274
|
declare function toLines(string: string, maxWidth: number, characterWidths?: Record<string, number>): string[];
|
|
275
275
|
declare function levenshteinDistance(a: string, b: string): number;
|
|
276
|
+
declare function findCommonPrefix(strings: string[]): string;
|
|
277
|
+
declare function findCommonDirectory(paths: string[]): string;
|
|
276
278
|
declare function containsWord(string: string, word: string): boolean;
|
|
277
279
|
declare function containsWords(string: string, words: string[], mode: 'any' | 'all'): boolean;
|
|
278
280
|
declare function parseHtmlAttributes(string: string): Record<string, string>;
|
|
@@ -1033,6 +1035,8 @@ export declare const Strings: {
|
|
|
1033
1035
|
measureTextWidth: typeof measureTextWidth;
|
|
1034
1036
|
toLines: typeof toLines;
|
|
1035
1037
|
levenshteinDistance: typeof levenshteinDistance;
|
|
1038
|
+
findCommonPrefix: typeof findCommonPrefix;
|
|
1039
|
+
findCommonDirectory: typeof findCommonDirectory;
|
|
1036
1040
|
};
|
|
1037
1041
|
export declare const Assertions: {
|
|
1038
1042
|
asEqual: typeof asEqual;
|
package/index.js
CHANGED
|
@@ -1232,6 +1232,21 @@ function levenshteinDistance(n, e) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
return t[n.length][e.length]
|
|
1234
1234
|
}
|
|
1235
|
+
function findCommonPrefix(n) {
|
|
1236
|
+
const e = n.reduce((r, o) => (r.length < o.length ? r : o))
|
|
1237
|
+
let t = ''
|
|
1238
|
+
for (let r = 0; r < e.length; r++) {
|
|
1239
|
+
const o = e[r]
|
|
1240
|
+
if (n.every(i => i[r] === o)) t += o
|
|
1241
|
+
else break
|
|
1242
|
+
}
|
|
1243
|
+
return t
|
|
1244
|
+
}
|
|
1245
|
+
function findCommonDirectory(n) {
|
|
1246
|
+
const e = findCommonPrefix(n),
|
|
1247
|
+
t = e.lastIndexOf('/')
|
|
1248
|
+
return t === -1 ? '' : e.slice(0, t + 1)
|
|
1249
|
+
}
|
|
1235
1250
|
function containsWord(n, e) {
|
|
1236
1251
|
return new RegExp(`\\b${e}\\b`).test(n)
|
|
1237
1252
|
}
|
|
@@ -2266,12 +2281,12 @@ function keccakPermutate(n) {
|
|
|
2266
2281
|
m = t ^ $n,
|
|
2267
2282
|
g = r ^ An,
|
|
2268
2283
|
En = (c << 1) | (f >>> 31),
|
|
2269
|
-
|
|
2284
|
+
On = (f << 1) | (c >>> 31),
|
|
2270
2285
|
w = o ^ En,
|
|
2271
|
-
y = i ^
|
|
2272
|
-
|
|
2286
|
+
y = i ^ On,
|
|
2287
|
+
Mn = (l << 1) | (a >>> 31),
|
|
2273
2288
|
kn = (a << 1) | (l >>> 31),
|
|
2274
|
-
x = u ^
|
|
2289
|
+
x = u ^ Mn,
|
|
2275
2290
|
b = s ^ kn,
|
|
2276
2291
|
Tn = (t << 1) | (r >>> 31),
|
|
2277
2292
|
Sn = (r << 1) | (t >>> 31),
|
|
@@ -2328,14 +2343,14 @@ function keccakPermutate(n) {
|
|
|
2328
2343
|
(n[48] ^= $),
|
|
2329
2344
|
(n[49] ^= A)
|
|
2330
2345
|
const E = n[0],
|
|
2331
|
-
|
|
2332
|
-
|
|
2346
|
+
O = n[1],
|
|
2347
|
+
M = (n[2] << 1) | (n[3] >>> 31),
|
|
2333
2348
|
k = (n[3] << 1) | (n[2] >>> 31),
|
|
2334
2349
|
T = (n[5] << 30) | (n[4] >>> 2),
|
|
2335
2350
|
S = (n[4] << 30) | (n[5] >>> 2),
|
|
2336
2351
|
R = (n[6] << 28) | (n[7] >>> 4),
|
|
2337
|
-
|
|
2338
|
-
|
|
2352
|
+
I = (n[7] << 28) | (n[6] >>> 4),
|
|
2353
|
+
D = (n[8] << 27) | (n[9] >>> 5),
|
|
2339
2354
|
C = (n[9] << 27) | (n[8] >>> 5),
|
|
2340
2355
|
B = (n[11] << 4) | (n[10] >>> 28),
|
|
2341
2356
|
P = (n[10] << 4) | (n[11] >>> 28),
|
|
@@ -2378,44 +2393,44 @@ function keccakPermutate(n) {
|
|
|
2378
2393
|
yn = (n[48] << 14) | (n[49] >>> 18),
|
|
2379
2394
|
xn = (n[49] << 14) | (n[48] >>> 18)
|
|
2380
2395
|
;(n[0] = E ^ (~v & K)),
|
|
2381
|
-
(n[1] =
|
|
2396
|
+
(n[1] = O ^ (~U & Z)),
|
|
2382
2397
|
(n[2] = v ^ (~K & un)),
|
|
2383
2398
|
(n[3] = U ^ (~Z & cn)),
|
|
2384
2399
|
(n[4] = K ^ (~un & yn)),
|
|
2385
2400
|
(n[5] = Z ^ (~cn & xn)),
|
|
2386
2401
|
(n[6] = un ^ (~yn & E)),
|
|
2387
|
-
(n[7] = cn ^ (~xn &
|
|
2402
|
+
(n[7] = cn ^ (~xn & O)),
|
|
2388
2403
|
(n[8] = yn ^ (~E & v)),
|
|
2389
|
-
(n[9] = xn ^ (~
|
|
2404
|
+
(n[9] = xn ^ (~O & U)),
|
|
2390
2405
|
(n[10] = R ^ (~z & q)),
|
|
2391
|
-
(n[11] =
|
|
2406
|
+
(n[11] = I ^ (~W & H)),
|
|
2392
2407
|
(n[12] = z ^ (~q & en)),
|
|
2393
2408
|
(n[13] = W ^ (~H & tn)),
|
|
2394
2409
|
(n[14] = q ^ (~en & pn)),
|
|
2395
2410
|
(n[15] = H ^ (~tn & mn)),
|
|
2396
2411
|
(n[16] = en ^ (~pn & R)),
|
|
2397
|
-
(n[17] = tn ^ (~mn &
|
|
2412
|
+
(n[17] = tn ^ (~mn & I)),
|
|
2398
2413
|
(n[18] = pn ^ (~R & z)),
|
|
2399
|
-
(n[19] = mn ^ (~
|
|
2400
|
-
(n[20] =
|
|
2414
|
+
(n[19] = mn ^ (~I & W)),
|
|
2415
|
+
(n[20] = M ^ (~L & Q)),
|
|
2401
2416
|
(n[21] = k ^ (~N & G)),
|
|
2402
2417
|
(n[22] = L ^ (~Q & sn)),
|
|
2403
2418
|
(n[23] = N ^ (~G & fn)),
|
|
2404
2419
|
(n[24] = Q ^ (~sn & ln)),
|
|
2405
2420
|
(n[25] = G ^ (~fn & an)),
|
|
2406
|
-
(n[26] = sn ^ (~ln &
|
|
2421
|
+
(n[26] = sn ^ (~ln & M)),
|
|
2407
2422
|
(n[27] = fn ^ (~an & k)),
|
|
2408
|
-
(n[28] = ln ^ (~
|
|
2423
|
+
(n[28] = ln ^ (~M & L)),
|
|
2409
2424
|
(n[29] = an ^ (~k & N)),
|
|
2410
|
-
(n[30] =
|
|
2425
|
+
(n[30] = D ^ (~B & V)),
|
|
2411
2426
|
(n[31] = C ^ (~P & J)),
|
|
2412
2427
|
(n[32] = B ^ (~V & rn)),
|
|
2413
2428
|
(n[33] = P ^ (~J & on)),
|
|
2414
2429
|
(n[34] = V ^ (~rn & gn)),
|
|
2415
2430
|
(n[35] = J ^ (~on & wn)),
|
|
2416
|
-
(n[36] = rn ^ (~gn &
|
|
2431
|
+
(n[36] = rn ^ (~gn & D)),
|
|
2417
2432
|
(n[37] = on ^ (~wn & C)),
|
|
2418
|
-
(n[38] = gn ^ (~
|
|
2433
|
+
(n[38] = gn ^ (~D & B)),
|
|
2419
2434
|
(n[39] = wn ^ (~C & P)),
|
|
2420
2435
|
(n[40] = T ^ (~j & Y)),
|
|
2421
2436
|
(n[41] = S ^ (~F & _)),
|
|
@@ -3469,7 +3484,9 @@ class TrieRouter {
|
|
|
3469
3484
|
breakLine,
|
|
3470
3485
|
measureTextWidth,
|
|
3471
3486
|
toLines,
|
|
3472
|
-
levenshteinDistance
|
|
3487
|
+
levenshteinDistance,
|
|
3488
|
+
findCommonPrefix,
|
|
3489
|
+
findCommonDirectory
|
|
3473
3490
|
}),
|
|
3474
3491
|
(exports.Assertions = { asEqual, asTrue, asTruthy, asFalse, asFalsy, asEither }),
|
|
3475
3492
|
(exports.Cache = { get: getCached, invalidate: invalidateCache }),
|