{"id":41340390,"url":"https://github.com/alisey/pcg32","last_synced_at":"2026-01-23T06:48:43.142Z","repository":{"id":57096592,"uuid":"434508308","full_name":"alisey/pcg32","owner":"alisey","description":"PCG-32 random number generator implemented in WebAssembly","archived":false,"fork":false,"pushed_at":"2021-12-08T19:21:45.000Z","size":104,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-02T18:39:22.888Z","etag":null,"topics":["pcg","prng","pseudo-random","random"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alisey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-03T07:42:53.000Z","updated_at":"2024-10-06T08:08:47.000Z","dependencies_parsed_at":"2022-08-20T16:51:13.132Z","dependency_job_id":null,"html_url":"https://github.com/alisey/pcg32","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alisey/pcg32","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisey%2Fpcg32","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisey%2Fpcg32/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisey%2Fpcg32/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisey%2Fpcg32/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisey","download_url":"https://codeload.github.com/alisey/pcg32/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisey%2Fpcg32/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28682263,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pcg","prng","pseudo-random","random"],"created_at":"2026-01-23T06:48:42.896Z","updated_at":"2026-01-23T06:48:43.131Z","avatar_url":"https://github.com/alisey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PCG-32: A Seedable 32-bit PRNG\n\nA WebAssembly port of the PCG Random Number Generator, [Minimal C Edition](https://github.com/imneme/pcg-c-basic).\n\n## Usage\n\n```js\nimport * as pcg from '@alisey/pcg32';\n\npcg.setState(0x0123456789ABCDEFn);\n\nconsole.log(pcg.randomInt(10)); // ⇒ 5\nconsole.log(pcg.random());      // ⇒ 0.3697000732146962\n```\n\n## API\n\n##### `randomInt(bound: number): number`\n\nReturns a uniformly distributed 32-bit unsigned random integer in the range\n[0, bound), where `bound` is a number from 1 to 2³².\n\n##### `random(): number`\n\nReturns a uniformly distributed  floating point number in the range [0, 1) that\nhas been rounded down to the nearest multiple of 2⁻⁵³.\n\n##### `setState(state: bigint): void`\n\nUpdates the internal state of the generator. The generator has 2⁶⁴ possible\ninternal states, and iterates through all of them. `state` is a 64-bit unsigned\nBigInt.\n\n##### `getState(): bigint`\n\nReturns a 64-bit unsigned BigInt representing the internal state of the\ngenerator.\n\n##### `seed(value?: bigint): void`\n\nSeeds the generator with a 64-bit BigInt. If the value is not provided, uses\na value based on `Math.random()`.\n\n## Performance\n\nAs of 2021, in V8 `pcg.randomInt()` is as fast as\n`Math.floor(Math.random() * n)`, but doesn't introduce bias. `pcg.random()` is\n2 times slower than `Math.random()`.\n\nIn SpiderMonkey and JavaScriptCore both functions are 10 times slower than\nnative equivalents.\n\n## Working With This Repo\n\n1. `npm install`\n2. `npm run build`\n3. `npm run test`\n4. `npm run demo`\n5. `npm run perf`\n\n## Links\n* [PCG: A Family of Better Random Number Generators](https://www.pcg-random.org)\n* [PCG: Using the Minimal C Implementation](https://www.pcg-random.org/using-pcg-c-basic.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisey%2Fpcg32","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisey%2Fpcg32","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisey%2Fpcg32/lists"}