{"id":17398447,"url":"https://github.com/vweevers/pseudo-math-random","last_synced_at":"2026-01-20T07:01:55.538Z","repository":{"id":65477273,"uuid":"189714143","full_name":"vweevers/pseudo-math-random","owner":"vweevers","description":"Same algorithm as Math.random but with a custom seed.","archived":false,"fork":false,"pushed_at":"2020-05-25T04:08:11.000Z","size":9,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T04:39:05.484Z","etag":null,"topics":["math-random","nodejs","number-generator","prng","random"],"latest_commit_sha":null,"homepage":null,"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/vweevers.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":"2019-06-01T09:26:05.000Z","updated_at":"2022-03-14T04:35:09.000Z","dependencies_parsed_at":"2023-01-25T06:35:17.050Z","dependency_job_id":null,"html_url":"https://github.com/vweevers/pseudo-math-random","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/vweevers/pseudo-math-random","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpseudo-math-random","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpseudo-math-random/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpseudo-math-random/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpseudo-math-random/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vweevers","download_url":"https://codeload.github.com/vweevers/pseudo-math-random/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vweevers%2Fpseudo-math-random/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28597985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T02:08:49.799Z","status":"ssl_error","status_checked_at":"2026-01-20T02:08:44.148Z","response_time":117,"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":["math-random","nodejs","number-generator","prng","random"],"created_at":"2024-10-16T14:56:35.555Z","updated_at":"2026-01-20T07:01:55.522Z","avatar_url":"https://github.com/vweevers.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pseudo-math-random\n\n\u003e **Same [algorithm](https://v8.dev/blog/math-random) as [Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) but with a custom seed.**  \n\u003e Useful for reproducible tests and benchmarks. Same API as [`math-random-seed`](https://github.com/mafintosh/math-random-seed) which uses [`crypto`](https://nodejs.org/api/crypto.html) (secure) while this uses [xorshift128+](https://github.com/AndreasMadsen/xorshift) (60x faster).\n\n[![npm status](http://img.shields.io/npm/v/pseudo-math-random.svg)](https://www.npmjs.org/package/pseudo-math-random)\n[![node](https://img.shields.io/node/v/pseudo-math-random.svg)](https://www.npmjs.org/package/pseudo-math-random)\n[![Travis build status](https://img.shields.io/travis/vweevers/pseudo-math-random.svg?label=travis)](http://travis-ci.org/vweevers/pseudo-math-random)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Usage\n\n```js\nconst pmr = require('pseudo-math-random')\nconst random = pmr('a seed')\n\nconsole.log(random()) // Always 0.32911525012180043\nconsole.log(random()) // Always 0.5563213847156248\n```\n\n## API\n\n### `random = pmr([seed])`\n\nCreate a new random number generator. The `seed` argument must be a string or [Buffer](https://nodejs.org/api/buffer.html). It is hashed once to counter short or zero-filled seeds. If no seed is provided one will be generated.\n\n### `num = random()`\n\nGet a floating-point, pseudo-random number between 0 (inclusive) and 1 (exclusive). Does _not_ provide cryptographically secure random numbers.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install pseudo-math-random\n```\n\n## Benchmark\n\n```\n$ node benchmark.js\nnode v10.14.1\npseudo-math-random x 23,050,253 ops/sec ±0.24% (94 runs sampled)\nmath-random-seed x 377,674 ops/sec ±1.50% (86 runs sampled)\nFastest is pseudo-math-random\n```\n\n_NB. Speed isn't everything. Decide for yourself which properties you need._\n\n## License\n\n[MIT](LICENSE.md) © 2019-present Vincent Weevers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fpseudo-math-random","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvweevers%2Fpseudo-math-random","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvweevers%2Fpseudo-math-random/lists"}