{"id":22903212,"url":"https://github.com/philihp/pcg","last_synced_at":"2025-05-08T16:56:26.885Z","repository":{"id":142784455,"uuid":"598056887","full_name":"philihp/pcg","owner":"philihp","description":"A functional implementation of the PCG family random number generators, written in TypeScript.","archived":false,"fork":false,"pushed_at":"2025-05-05T18:28:10.000Z","size":224,"stargazers_count":4,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T16:56:21.158Z","etag":null,"topics":["functional-programming","random-generation"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pcg","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"kripod/pcg.js","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philihp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-06T09:58:57.000Z","updated_at":"2025-04-26T09:40:51.000Z","dependencies_parsed_at":"2023-05-01T18:05:46.379Z","dependency_job_id":"8373bd9a-8c8d-4e68-9724-cf5b6fd79097","html_url":"https://github.com/philihp/pcg","commit_stats":null,"previous_names":["philihp/fn-pcg"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philihp%2Fpcg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philihp%2Fpcg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philihp%2Fpcg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philihp%2Fpcg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philihp","download_url":"https://codeload.github.com/philihp/pcg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112074,"owners_count":21856070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["functional-programming","random-generation"],"created_at":"2024-12-14T02:34:56.697Z","updated_at":"2025-05-08T16:56:26.861Z","avatar_url":"https://github.com/philihp.png","language":"TypeScript","readme":"# pcg\n\n[![Version](https://img.shields.io/npm/v/pcg.svg)](https://www.npmjs.com/package/pcg)\n[![Tests](https://github.com/philihp/pcg/actions/workflows/tests.yml/badge.svg)](https://github.com/philihp/pcg/actions/workflows/tests.yml)\n[![Coverage](https://coveralls.io/repos/github/philihp/pcg/badge.svg?branch=main)](https://coveralls.io/github/philihp/pcg?branch=main)\n![Downloads](https://img.shields.io/npm/dt/pcg)\n![License](https://img.shields.io/npm/l/pcg)\n\nA functional implementation of the [PCG family random number generators](), written in JavaScript.\n\n[PCG family random number generators]: http://pcg-random.org\n\n## Getting started\n\nTo achieve frictionless reproducibility of random output results, immutable objects are used throughout the project.\n\nFirst, seed a PCG state. A stream ID specifies _which_ unique periodic series of entropy to use. The state specifies _where_ in that series we start.\n\n```\nimport { createPcg32 } from 'pcg'\n\nconst advancedOptions = {}\nconst initState = 42\nconst initStreamId = 54\nconst state0 = createPcg32(advancedOptions, initState, initStreamId)\n```\n\nAfter that, random outputs can be generated by calling appropriate functions as shown below:\n\n```js\nimport { nextState, prevState, randomInt, randomList } from 'pcg'\n\nconst randomUint32 = randomInt(0, 2 ** 32 - 1)\nconst [value, nextState] = randomUint32(state0)\n\nconst listLength = 3\nconst listItemRng = randomUint32\nconst [[v1, state1], [v2, state2], [v3, state3]] = randomList(listLength, listItemRng, state0)\n```\n\nIn this above example, `value === v1`, and `nextState === state1`\n\n## Thanks\n\n- [@kripod](https://github.com/kripod/), who wrote the original [`pcg.js`](https://github.com/kripod/pcg.js)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilihp%2Fpcg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilihp%2Fpcg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilihp%2Fpcg/lists"}