Heal the layer break around the Id<> type

This commit is contained in:
Tau
2019-11-06 17:29:07 -05:00
parent 3a71f5054c
commit 6a4ac795b2
24 changed files with 96 additions and 60 deletions
-14
View File
@@ -1,14 +0,0 @@
import { randomBytes } from "crypto";
export function generateId(): bigint {
const buf = randomBytes(8);
buf[0] &= 0x7f; // Force number to be non-negative
// Let's not depend on Node v12 for the sake of 3 LoC just yet.
const hi = buf.readUInt32BE(0);
const lo = buf.readUInt32BE(4);
return (BigInt(hi) << 32n) | BigInt(lo);
}