{"_id":"@buff-beacon-project/rand-utils","name":"@buff-beacon-project/rand-utils","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@buff-beacon-project/rand-utils","version":"1.0.0","description":"Tools for consuming public randomness sources","repository":{"type":"git","url":"git+https://github.com/buff-beacon-project/rand-utils.git"},"keywords":[],"author":{"name":"Jasper Palfree"},"license":"MIT","bugs":{"url":"https://github.com/buff-beacon-project/rand-utils/issues"},"type":"module","exports":{".":{"default":"./dist/index.js","browser":"./dist/index.js","require":"./dist/index.cjs","import":"./dist/index.js","node":"./dist/index.js","bun":"./src/index.ts","types":"./src/index.d.ts"}},"module":"src/index.js","main":"src/index.js","engines":{"node":">=12"},"browserslist":["last 1 version","> 1%"],"homepage":"https://random.colorado.edu","scripts":{"build":"tsup","dev":"tsup --watch","docs":"typedoc src","prepublishOnly":"bun run build && bun run docs","release":"bunx bumpp --no-push"},"dependencies":{"bit-buffer":"^0.2.5"},"devDependencies":{"bun-types":"latest","tsup":"^8.3.0","typedoc":"^0.26.10","typedoc-plugin-markdown":"^4.2.9","typescript":"^5.4.2"},"_id":"@buff-beacon-project/rand-utils@1.0.0","gitHead":"513262d1ea7e1e9191092f47cb72185f50754e7b","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-JlaheGO15tWVW2wmEXz0N5ORg5P/uEsI2f5rkRl5Z9OiEEL9QvzkD0hjbdCBZJ/KrXeG3ke5oS3ZosHmArkrnQ==","shasum":"99e71082af773680143b2cd0985eb1c16aff7cba","tarball":"https://registry.npmjs.org/@buff-beacon-project/rand-utils/-/rand-utils-1.0.0.tgz","fileCount":14,"unpackedSize":27018,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@buff-beacon-project%2frand-utils@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDpYoElNs1BanQyjUTWGRyrYlMdmCWoYdZomTsL4nZrqgIhALUE7SFHsKqvV9H8MFtDMrqfb7axo/BOrVNfI3mH7FQE"}]},"_npmUser":{"name":"wellcaffeinated","email":"well.caffeinated@gmail.com"},"directories":{},"maintainers":[{"name":"wellcaffeinated","email":"well.caffeinated@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rand-utils_1.0.0_1730416477569_0.8593175487631179"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-31T23:14:37.486Z","1.0.0":"2024-10-31T23:14:37.809Z","modified":"2024-10-31T23:14:38.309Z"},"maintainers":[{"name":"wellcaffeinated","email":"well.caffeinated@gmail.com"}],"description":"Tools for consuming public randomness sources","homepage":"https://random.colorado.edu","keywords":[],"repository":{"type":"git","url":"git+https://github.com/buff-beacon-project/rand-utils.git"},"author":{"name":"Jasper Palfree"},"bugs":{"url":"https://github.com/buff-beacon-project/rand-utils/issues"},"license":"MIT","readme":"# rand-utils\n\nA set of utilities to make it easier to use random bit buffers.\n\nMade for the [CURBy Project](https://random.colorado.edu)\n\n## Installation\n\n```sh\nnpm install @buff-beacon-project/rand-utils\n```\n\n## Example\n\n```js\nimport { BitReader } from '@buff-beacon-project/rand-utils'\nimport { randomBytes } from 'crypto'\n\nconst rand = randomBytes(64)\nconst reader = BitReader.from(rand)\n// random directions\nconst directions = ['up', 'down', 'left', 'right']\nconst randomDirections = reader.unfold((stream) =>\n  directions[stream.readBits(2, false)]\n)\nconst list = Array.from(randomDirections)\n// shuffled array\nconst arr = [0, 1, 2, 3, 4, 5, 6, 7]\nconst shuffled = reader.shuffled(arr)\n```\n\n## Documentation\n\nFound in the [docs/](./docs) folder.\n","readmeFilename":"README.md"}