{"_id":"@4bitlabs/pcg-xsh-rr","name":"@4bitlabs/pcg-xsh-rr","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@4bitlabs/pcg-xsh-rr","version":"1.0.0","description":"A simple seedable pseudo-random-number generator, PCG-XSH-RR,  for typescript.","license":"ISC","author":{"name":"J. Holmes","email":"j@holmes.codes"},"type":"module","exports":"./dist/index.js","scripts":{"build":"tsdown","format:fix":"biome check --write","lint":"biome check","test":"vitest run","test:dev":"vitest dev"},"devDependencies":{"@biomejs/biome":"^2.5.5","@vitest/coverage-v8":"^4.1.10","tsdown":"^0.22.14","typescript":"^6.0.3","vitest":"^4.1.10"},"allowScripts":{"fsevents@2.3.3":true},"gitHead":"f27eb2a5e4429c9b4c466e8b9e08c900d40930df","_id":"@4bitlabs/pcg-xsh-rr@1.0.0","_nodeVersion":"22.23.1","_npmVersion":"12.0.1","dist":{"integrity":"sha512-vWyU4PTGiQg2MK00DmwVhHs1pEhHRYyfIONfQr7cBcPCWmd7/KIBzCvzVJzdSenpTEwwg3eV1YxM7583Rj0pjA==","shasum":"e54ec51070951589981d7a76a7c47e009640e4ee","tarball":"https://registry.npmjs.org/@4bitlabs/pcg-xsh-rr/-/pcg-xsh-rr-1.0.0.tgz","fileCount":21,"unpackedSize":17013,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBIVH6DC7cfwk8eZXNygje4ogtsW8xEjczUv+Kz9ivElAiB0v24RtGZoe5KWNSuDBop0ybhPtN1MiRwR4IdpBYfztQ=="}]},"_npmUser":{"name":"32bitkid","email":"32bitkid@gmail.com"},"directories":{},"maintainers":[{"name":"32bitkid","email":"32bitkid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pcg-xsh-rr_1.0.0_1785172752975_0.5165171745978949"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-27T17:19:12.788Z","1.0.0":"2026-07-27T17:19:13.124Z","modified":"2026-07-27T17:19:13.382Z"},"maintainers":[{"name":"32bitkid","email":"32bitkid@gmail.com"}],"description":"A simple seedable pseudo-random-number generator, PCG-XSH-RR,  for typescript.","author":{"name":"J. Holmes","email":"j@holmes.codes"},"license":"ISC","readme":"# @4bitlabs/pcg-xsh-rr\n\nA TypeScript `bigint` implementation of [PCG-XSH-RR](https://en.wikipedia.org/wiki/Permuted_congruential_generator#Example_code).\n\n> [!WARNING]\n> You probably do _not_ want to use this library. Prefer a \n> more rigorous library like [pure-rand](https://github.com/dubzzz/pure-rand)\n> for all your pseduo-random-number generation needs. This package is for my \n> own _edification_ and _learning purposes_.\n\n\n## Example\n\n```ts\nimport { createPcg32 } from '@4bitlabs/pcg-xsh-rr';\n\nconst SEED = Date.now(); \nconst rng = createPcg32(SEED);\n\nrng.next(); // returns a number between 0x0000_0000 and 0xFFFF_FFFF\n```\n\nDistribution helpers:\n\n```ts\nimport { \n  createPcg32, \n  float64, \n  float32, \n  intRange, \n  pickFrom,\n} from '@4bitlabs/pcg-xsh-rr';\n\nconst SEED = Date.now(); \nconst rng = createPcg32(SEED);\n\nconsole.log(float64(rng)); // a number in the range of [0,1). 53-bits of entropy\nconsole.log(float32(rng)); // a number in the range of [0,1). 23-bits of entropy\nconsole.log(intRange(rng, 1, 6)); // an integer in the range of [1, 6]\nconsole.log(pickFrom(rng, ['apple', 'banana', 'carrot'])); // one of 'apple' | 'banana' | 'carrot'\n```\n\n## Other Random Provider wrappers\n\n```ts\nimport { mathRand, cryptoRand, intRange } from \"./builtin\";\n\nintRange(mathRand, 1, 6); // use Math.random() for a die roll\npickFrom(cryptoRand, ['apple', 'banana', 'carrot']); // use crypto-secure random source\n```\n\n> [!NOTE]\n> Again, you probably dont want to be doing _either_ of these things.\n> But again, if you are experimenting and learning about random-number \n> generators, knock yourself out!\n\n## Caveats\n\n> [!WARNING]\n> This library uses `bigint` for the internal state of the pRNG. This\n> makes it rather slow, and could be optimized by implementing `uint64`\n> math ontop of `int32` safe JavaScript operations. But, that would \n> a) be sustantially more complex and unreadable b) there are other \n> libraries, see above, that do that already and better. So, just use \n> those. Thanks!\n\n","readmeFilename":"README.md","_rev":"1-6279c79dd377576f73d20d985c150129"}