cafe-utility 27.12.1 → 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.
Files changed (3) hide show
  1. package/index.d.ts +4 -1
  2. package/index.js +13 -10
  3. 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++) {
@@ -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
- H = (n[20] << 3) | (n[21] >>> 29),
2332
- W = (n[21] << 3) | (n[20] >>> 29),
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 & H)),
2372
- (n[11] = D ^ (~q & W)),
2373
- (n[12] = F ^ (~H & en)),
2374
- (n[13] = q ^ (~W & tn)),
2375
- (n[14] = H ^ (~en & pn)),
2376
- (n[15] = W ^ (~tn & mn)),
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)),
@@ -3172,7 +3175,7 @@ class AsyncQueue {
3172
3175
  multicall,
3173
3176
  maxBy
3174
3177
  }),
3175
- (exports.System = { sleepMillis, forever, scheduleMany, waitFor, expandError, runAndSetInterval }),
3178
+ (exports.System = { sleepMillis, forever, scheduleMany, waitFor, expandError, runAndSetInterval, whereAmI }),
3176
3179
  (exports.Numbers = {
3177
3180
  make: makeNumber,
3178
3181
  sum,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "27.12.1",
3
+ "version": "27.13.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {