@oh-my-pi/pi-utils 11.8.0 → 11.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oh-my-pi/pi-utils",
3
- "version": "11.8.0",
3
+ "version": "11.8.2",
4
4
  "description": "Shared utilities for pi packages",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/ptree.ts CHANGED
@@ -349,7 +349,7 @@ export async function exec(cmd: string[], opts?: ExecOptions): Promise<ExecResul
349
349
  const stdin = typeof input === "string" ? Buffer.from(input) : input;
350
350
  const resolved: ChildSpawnOptions = stdin === undefined ? spawnOpts : { ...spawnOpts, stdin };
351
351
  using child = spawn(cmd, resolved);
352
- return child.wait({ stderr, allowAbort, allowNonZero });
352
+ return await child.wait({ stderr, allowAbort, allowNonZero });
353
353
  }
354
354
 
355
355
  // ── Signal combinators ───────────────────────────────────────────────────────
package/src/snowflake.ts CHANGED
@@ -39,10 +39,13 @@ namespace Snowflake {
39
39
  // Formats a sequence and timestamp into a snowflake hex string.
40
40
  //
41
41
  export function formatParts(dt: number, seq: number): Snowflake {
42
- // Keep everything in Number space; dt is < 2^53 for current epochs.
43
- const value = dt * 0x400000 + seq; // dt << 22
44
- const hi = Math.floor(value / 0x100000000);
45
- const lo = (value - hi * 0x100000000) >>> 0;
42
+ // Split dt into hi/lo to avoid exceeding Number.MAX_SAFE_INTEGER.
43
+ // dt is ~39 bits; dt<<22 would be ~61 bits, so we split at bit 10:
44
+ // lo32 = (dtLo << 22) | seq (10+22 = 32 bits, no overlap)
45
+ // hi32 = dtHi (~29 bits)
46
+ const dtLo = dt % 1024;
47
+ const hi = (dt - dtLo) / 1024; // dt >>> 10
48
+ const lo = ((dtLo << 22) | seq) >>> 0;
46
49
  const hi1 = (hi >>> 16) & 0xffff;
47
50
  const hi2 = hi & 0xffff;
48
51
  const lo1 = (lo >>> 16) & 0xffff;