diff --git a/package.json b/package.json index 5d482d63..4b0e241e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "@commitlint/config-conventional": "19.2.2", "@eslint/js": "9.5.0", "@types/eslint__js": "8.42.3", - "@types/random-seed": "0.3.5", "@wdio/browserstack-service": "8.39.0", "@wdio/cli": "8.39.0", "@wdio/jasmine-framework": "8.39.0", @@ -73,7 +72,6 @@ "npm-run-all": "4.1.5", "optional-dev-dependency": "2.0.1", "prettier": "3.3.2", - "random-seed": "0.3.0", "runmd": "1.3.9", "standard-version": "9.5.0", "typescript": "5.4.5", diff --git a/src/test/parse.test.ts b/src/test/parse.test.ts index 2039452b..1c5c35b4 100644 --- a/src/test/parse.test.ts +++ b/src/test/parse.test.ts @@ -1,20 +1,29 @@ import * as assert from 'assert'; import test, { describe } from 'node:test'; -// @ts-expect-error random-seed is an old CJS module. we should update an ESM seeded -// RNG at some point, but keeping this for now to ensure the TS port works with -// the legacy tests here. -import gen from 'random-seed'; import parse from '../parse.js'; import stringify from '../stringify.js'; import uuidv4 from '../v4.js'; -// Use deterministic PRNG for reproducible tests -const rand = gen.create('He who wonders discovers that this in itself is wonder.'); +// Deterministic PRNG for reproducible tests +// See https://stackoverflow.com/a/47593316/109538 +function splitmix32(a: number) { + return function () { + a |= 0; + a = (a + 0x9e3779b9) | 0; + let t = a ^ (a >>> 16); + t = Math.imul(t, 0x21f0aaad); + t = t ^ (t >>> 15); + t = Math.imul(t, 0x735a2d97); + return ((t = t ^ (t >>> 15)) >>> 0) / 4294967296; + }; +} +const rand = splitmix32(0x12345678); function rng(bytes = new Uint8Array(16)) { for (let i = 0; i < 16; i++) { - bytes[i] = rand(256); + bytes[i] = rand() * 256; } + return bytes; } diff --git a/tsconfig.esm.json b/tsconfig.esm.json index c1da86c5..718d5701 100644 --- a/tsconfig.esm.json +++ b/tsconfig.esm.json @@ -1,8 +1,8 @@ { "extends": "./tsconfig.base.json", "compilerOptions": { - "module": "ESNext", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "outDir": "./dist/esm" } }