From 99e763029355c1cc6c6b98e1c1bf413a9ac9c817 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 25 May 2026 01:49:32 -0700 Subject: [PATCH] Simplify bigint RNG since it is never called with arguments. --- src/utils/bigint.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/utils/bigint.ts b/src/utils/bigint.ts index 8d12f49..85b26ac 100644 --- a/src/utils/bigint.ts +++ b/src/utils/bigint.ts @@ -19,12 +19,9 @@ export function bigintByteLength (int: bigint): number { return byteLength } -export function bigintRandom (max: bigint = 0xFFFFFFFFFFFFFFFFn): bigint { - if (typeof max !== 'bigint' || max < 1n) { - throw new TypeError('Invalid max value') - } - const randomUint8Array = new Uint8Array(bigintByteLength(max)) - const mask = (1n << bigintBitLength(max)) - 1n +export function bigintRandom (): bigint { + const mask = 0xFFFFFFFFFFFFFFFFn + const randomUint8Array = new Uint8Array(8) let output = 0n do { output = 0n @@ -35,7 +32,7 @@ export function bigintRandom (max: bigint = 0xFFFFFFFFFFFFFFFFn): bigint { output += BigInt(randomUint8Array[i]) } output &= mask - } while (output > max) + } while (output > mask) return output } -- 2.52.0