diff --git a/package-lock.json b/package-lock.json index b8532ca..97789de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ulid", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ulid", - "version": "3.0.1", + "version": "3.0.2", "license": "MIT", "bin": { "ulid": "dist/cli.js" diff --git a/package.json b/package.json index b3a5523..94efd41 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ulid", - "version": "3.0.1", + "version": "3.0.2", "description": "A universally-unique, lexicographically-sortable, identifier generator", "type": "module", "exports": { @@ -41,6 +41,7 @@ "build:types": "tsc -p tsconfig.dec.json --emitDeclarationOnly && find ./dist -name '*.d.ts' -exec sh -c 'cp {} $(dirname {})/$(basename -s .d.ts {}).d.cts' \\;", "clean": "rm -rf ./dist", "format": "prettier --write \"{{source,test}/**/*.{js,ts},rollup.config.js,vitest.config.js}\"", + "prepublishOnly": "npm run build", "test": "npm run build && npm run test:specs && npm run test:format && npm run test:types", "test:format": "prettier --check \"{{source,test}/**/*.{js,ts},rollup.config.js,vitest.config.js}\"", "test:specs": "vitest", diff --git a/source/ulid.ts b/source/ulid.ts index 24ebb28..a270724 100644 --- a/source/ulid.ts +++ b/source/ulid.ts @@ -52,12 +52,12 @@ export function detectPRNG(root?: any): PRNG { return () => { const buffer = new Uint8Array(1); globalCrypto.getRandomValues(buffer); - return buffer[0] / 0xff; + return buffer[0] / 256; }; } else if (typeof globalCrypto?.randomBytes === "function") { - return () => globalCrypto.randomBytes(1).readUInt8() / 0xff; + return () => globalCrypto.randomBytes(1).readUInt8() / 256; } else if (crypto?.randomBytes) { - return () => crypto.randomBytes(1).readUInt8() / 0xff; + return () => crypto.randomBytes(1).readUInt8() / 256; } throw new ULIDError(ULIDErrorCode.PRNGDetectFailure, "Failed to find a reliable PRNG"); }