@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 +1 -1
- package/src/ptree.ts +1 -1
- package/src/snowflake.ts +7 -4
package/package.json
CHANGED
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
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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;
|