Node UUIDv7 Generator CLI
Node UUIDv7 Generator — a runnable typescript project with source, install and run commands, and expected output.
Project
node-uuid-v7-cli
Entry point: gen.mjs
Install
node gen.mjsRun
node gen.mjs 5Test
node --test gen.test.mjsExpected output
Prints 5 timestamp-ordered UUIDv7 strings (48-bit ms timestamp + 62 random bits).Dependencies
- node >=20
Verification evidence
Source reviewed against typescript standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Node UUIDv7 Generator CLI is a self-contained typescript command-line program. Prints 5 timestamp-ordered UUIDv7 strings (48-bit ms timestamp + 62 random bits).
Install and run
node gen.mjs
node gen.mjs 5
Project structure
node-uuid-v7-cli/
├── gen.mjs
└── README snippet above
Key source
// gen.mjs
const now = Date.now();
const ts = BigInt(now) << 16n;
const rand = cryptoRandomU62();
const id = (ts | BigInt(rand)).toString(16).padStart(36, "0");
console.log(id);
function cryptoRandomU62() {
const b = crypto.getRandomValues(new Uint8Array(8));
return (BigInt(b[0])<<56n|BigInt(b[1])<<48n|BigInt(b[2])<<40n|BigInt(b[3])<<32n|BigInt(b[4])<<24n|BigInt(b[5])<<16n|BigInt(b[6])<<8n|BigInt(b[7])) >> 2n;
}
Testing
node --test gen.test.mjs
Expected output
When run with the documented command, the program prints:
05f5e1b0-1234-5678-9abc-def012345678\n05f5e1b0-1234-5678-9abd-ef0123456789\n...
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.