cafe-utility 27.13.0 → 27.14.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.
Files changed (3) hide show
  1. package/index.d.ts +2 -3
  2. package/index.js +43 -42
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -51,7 +51,7 @@ declare function forever(callable: (() => Promise<void>) | (() => void), millis:
51
51
  declare function runAndSetInterval(callable: () => void, millis: number): () => void;
52
52
  declare function whereAmI(): 'browser' | 'node';
53
53
  declare function asMegabytes(number: number): number;
54
- declare function convertBytes(bytes: number): string;
54
+ declare function convertBytes(bytes: number, divisor?: number): string;
55
55
  declare function hexToRgb(hex: string): [number, number, number];
56
56
  declare function rgbToHex(rgb: [number, number, number]): string;
57
57
  declare function haversineDistanceToMeters(lat1: number, lon1: number, lat2: number, lon2: number): number;
@@ -1046,5 +1046,4 @@ export declare const Vector: {
1046
1046
  raycastCircle: typeof raycastCircle;
1047
1047
  getLineIntersectionPoint: typeof getLineIntersectionPoint;
1048
1048
  };
1049
- export { };
1050
-
1049
+ export {};
package/index.js CHANGED
@@ -254,20 +254,21 @@ function runAndSetInterval(n, e) {
254
254
  return () => clearInterval(t)
255
255
  }
256
256
  function whereAmI() {
257
- return Object.prototype.hasOwnProperty.call(globalThis, 'process') ? 'node' : 'browser'
257
+ const n = globalThis.process
258
+ return n ? (n.browser === !0 ? 'browser' : 'node') : 'browser'
258
259
  }
259
260
  function asMegabytes(n) {
260
261
  return n / 1024 / 1024
261
262
  }
262
- function convertBytes(n) {
263
- return n >= 1024 * 1024 * 1024 * 1024
264
- ? (n / 1024 / 1024 / 1024 / 1024).toFixed(3) + ' TB'
265
- : n >= 1024 * 1024 * 1024
266
- ? (n / 1024 / 1024 / 1024).toFixed(3) + ' GB'
267
- : n >= 1024 * 1024
268
- ? (n / 1024 / 1024).toFixed(3) + ' MB'
269
- : n >= 1024
270
- ? (n / 1024).toFixed(3) + ' KB'
263
+ function convertBytes(n, e = 1024) {
264
+ return n >= e * e * e * e
265
+ ? (n / e / e / e / e).toFixed(3) + ' TB'
266
+ : n >= e * e * e
267
+ ? (n / e / e / e).toFixed(3) + ' GB'
268
+ : n >= e * e
269
+ ? (n / e / e).toFixed(3) + ' MB'
270
+ : n >= e
271
+ ? (n / e).toFixed(3) + ' KB'
271
272
  : n + ' B'
272
273
  }
273
274
  function hexToRgb(n) {
@@ -2243,8 +2244,8 @@ function keccakPermutate(n) {
2243
2244
  a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
2244
2245
  h = (o << 1) | (i >>> 31),
2245
2246
  bn = (i << 1) | (o >>> 31),
2246
- d = l ^ h,
2247
- p = a ^ bn,
2247
+ p = l ^ h,
2248
+ d = a ^ bn,
2248
2249
  $n = (u << 1) | (s >>> 31),
2249
2250
  An = (s << 1) | (u >>> 31),
2250
2251
  m = t ^ $n,
@@ -2261,8 +2262,8 @@ function keccakPermutate(n) {
2261
2262
  Sn = (r << 1) | (t >>> 31),
2262
2263
  $ = c ^ Tn,
2263
2264
  A = f ^ Sn
2264
- ;(n[0] ^= d),
2265
- (n[1] ^= p),
2265
+ ;(n[0] ^= p),
2266
+ (n[1] ^= d),
2266
2267
  (n[2] ^= m),
2267
2268
  (n[3] ^= g),
2268
2269
  (n[4] ^= w),
@@ -2271,8 +2272,8 @@ function keccakPermutate(n) {
2271
2272
  (n[7] ^= b),
2272
2273
  (n[8] ^= $),
2273
2274
  (n[9] ^= A),
2274
- (n[10] ^= d),
2275
- (n[11] ^= p),
2275
+ (n[10] ^= p),
2276
+ (n[11] ^= d),
2276
2277
  (n[12] ^= m),
2277
2278
  (n[13] ^= g),
2278
2279
  (n[14] ^= w),
@@ -2281,8 +2282,8 @@ function keccakPermutate(n) {
2281
2282
  (n[17] ^= b),
2282
2283
  (n[18] ^= $),
2283
2284
  (n[19] ^= A),
2284
- (n[20] ^= d),
2285
- (n[21] ^= p),
2285
+ (n[20] ^= p),
2286
+ (n[21] ^= d),
2286
2287
  (n[22] ^= m),
2287
2288
  (n[23] ^= g),
2288
2289
  (n[24] ^= w),
@@ -2291,8 +2292,8 @@ function keccakPermutate(n) {
2291
2292
  (n[27] ^= b),
2292
2293
  (n[28] ^= $),
2293
2294
  (n[29] ^= A),
2294
- (n[30] ^= d),
2295
- (n[31] ^= p),
2295
+ (n[30] ^= p),
2296
+ (n[31] ^= d),
2296
2297
  (n[32] ^= m),
2297
2298
  (n[33] ^= g),
2298
2299
  (n[34] ^= w),
@@ -2301,8 +2302,8 @@ function keccakPermutate(n) {
2301
2302
  (n[37] ^= b),
2302
2303
  (n[38] ^= $),
2303
2304
  (n[39] ^= A),
2304
- (n[40] ^= d),
2305
- (n[41] ^= p),
2305
+ (n[40] ^= p),
2306
+ (n[41] ^= d),
2306
2307
  (n[42] ^= m),
2307
2308
  (n[43] ^= g),
2308
2309
  (n[44] ^= w),
@@ -2321,9 +2322,9 @@ function keccakPermutate(n) {
2321
2322
  D = (n[7] << 28) | (n[6] >>> 4),
2322
2323
  C = (n[8] << 27) | (n[9] >>> 5),
2323
2324
  I = (n[9] << 27) | (n[8] >>> 5),
2324
- v = (n[11] << 4) | (n[10] >>> 28),
2325
- B = (n[10] << 4) | (n[11] >>> 28),
2326
- P = (n[13] << 12) | (n[12] >>> 20),
2325
+ B = (n[11] << 4) | (n[10] >>> 28),
2326
+ P = (n[10] << 4) | (n[11] >>> 28),
2327
+ v = (n[13] << 12) | (n[12] >>> 20),
2327
2328
  U = (n[12] << 12) | (n[13] >>> 20),
2328
2329
  L = (n[14] << 6) | (n[15] >>> 26),
2329
2330
  j = (n[15] << 6) | (n[14] >>> 26),
@@ -2354,32 +2355,32 @@ function keccakPermutate(n) {
2354
2355
  ln = (n[40] << 18) | (n[41] >>> 14),
2355
2356
  an = (n[41] << 18) | (n[40] >>> 14),
2356
2357
  hn = (n[42] << 2) | (n[43] >>> 30),
2357
- dn = (n[43] << 2) | (n[42] >>> 30),
2358
- pn = (n[45] << 29) | (n[44] >>> 3),
2358
+ pn = (n[43] << 2) | (n[42] >>> 30),
2359
+ dn = (n[45] << 29) | (n[44] >>> 3),
2359
2360
  mn = (n[44] << 29) | (n[45] >>> 3),
2360
2361
  gn = (n[47] << 24) | (n[46] >>> 8),
2361
2362
  wn = (n[46] << 24) | (n[47] >>> 8),
2362
2363
  yn = (n[48] << 14) | (n[49] >>> 18),
2363
2364
  xn = (n[49] << 14) | (n[48] >>> 18)
2364
- ;(n[0] = E ^ (~P & K)),
2365
+ ;(n[0] = E ^ (~v & K)),
2365
2366
  (n[1] = M ^ (~U & Z)),
2366
- (n[2] = P ^ (~K & un)),
2367
+ (n[2] = v ^ (~K & un)),
2367
2368
  (n[3] = U ^ (~Z & cn)),
2368
2369
  (n[4] = K ^ (~un & yn)),
2369
2370
  (n[5] = Z ^ (~cn & xn)),
2370
2371
  (n[6] = un ^ (~yn & E)),
2371
2372
  (n[7] = cn ^ (~xn & M)),
2372
- (n[8] = yn ^ (~E & P)),
2373
+ (n[8] = yn ^ (~E & v)),
2373
2374
  (n[9] = xn ^ (~M & U)),
2374
2375
  (n[10] = R ^ (~F & W)),
2375
2376
  (n[11] = D ^ (~q & H)),
2376
2377
  (n[12] = F ^ (~W & en)),
2377
2378
  (n[13] = q ^ (~H & tn)),
2378
- (n[14] = W ^ (~en & pn)),
2379
+ (n[14] = W ^ (~en & dn)),
2379
2380
  (n[15] = H ^ (~tn & mn)),
2380
- (n[16] = en ^ (~pn & R)),
2381
+ (n[16] = en ^ (~dn & R)),
2381
2382
  (n[17] = tn ^ (~mn & D)),
2382
- (n[18] = pn ^ (~R & F)),
2383
+ (n[18] = dn ^ (~R & F)),
2383
2384
  (n[19] = mn ^ (~D & q)),
2384
2385
  (n[20] = O ^ (~L & Q)),
2385
2386
  (n[21] = k ^ (~j & _)),
@@ -2391,26 +2392,26 @@ function keccakPermutate(n) {
2391
2392
  (n[27] = fn ^ (~an & k)),
2392
2393
  (n[28] = ln ^ (~O & L)),
2393
2394
  (n[29] = an ^ (~k & j)),
2394
- (n[30] = C ^ (~v & V)),
2395
- (n[31] = I ^ (~B & J)),
2396
- (n[32] = v ^ (~V & rn)),
2397
- (n[33] = B ^ (~J & on)),
2395
+ (n[30] = C ^ (~B & V)),
2396
+ (n[31] = I ^ (~P & J)),
2397
+ (n[32] = B ^ (~V & rn)),
2398
+ (n[33] = P ^ (~J & on)),
2398
2399
  (n[34] = V ^ (~rn & gn)),
2399
2400
  (n[35] = J ^ (~on & wn)),
2400
2401
  (n[36] = rn ^ (~gn & C)),
2401
2402
  (n[37] = on ^ (~wn & I)),
2402
- (n[38] = gn ^ (~C & v)),
2403
- (n[39] = wn ^ (~I & B)),
2403
+ (n[38] = gn ^ (~C & B)),
2404
+ (n[39] = wn ^ (~I & P)),
2404
2405
  (n[40] = T ^ (~N & G)),
2405
2406
  (n[41] = S ^ (~z & Y)),
2406
2407
  (n[42] = N ^ (~G & X)),
2407
2408
  (n[43] = z ^ (~Y & nn)),
2408
2409
  (n[44] = G ^ (~X & hn)),
2409
- (n[45] = Y ^ (~nn & dn)),
2410
+ (n[45] = Y ^ (~nn & pn)),
2410
2411
  (n[46] = X ^ (~hn & T)),
2411
- (n[47] = nn ^ (~dn & S)),
2412
+ (n[47] = nn ^ (~pn & S)),
2412
2413
  (n[48] = hn ^ (~T & N)),
2413
- (n[49] = dn ^ (~S & z)),
2414
+ (n[49] = pn ^ (~S & z)),
2414
2415
  (n[0] ^= IOTA_CONSTANTS[e * 2]),
2415
2416
  (n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
2416
2417
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "27.13.0",
3
+ "version": "27.14.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {