{"id":21296971,"url":"https://github.com/s3xysteak/twistrand","last_synced_at":"2026-02-05T14:05:37.520Z","repository":{"id":260122409,"uuid":"880308990","full_name":"s3xysteak/twistrand","owner":"s3xysteak","description":"A PRNG (Pseudo Random Number Generator) library based on Mersenne Twister, written by typescript, supported both esm/cjs.","archived":false,"fork":false,"pushed_at":"2024-11-17T08:51:27.000Z","size":95,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-11T18:47:41.701Z","etag":null,"topics":["algorithm","mersenne-twister","random","seed","utils"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/s3xysteak.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}},"created_at":"2024-10-29T13:50:19.000Z","updated_at":"2024-11-17T08:51:31.000Z","dependencies_parsed_at":"2024-10-29T17:54:49.540Z","dependency_job_id":null,"html_url":"https://github.com/s3xysteak/twistrand","commit_stats":null,"previous_names":["s3xysteak/twistrand"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/s3xysteak/twistrand","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s3xysteak%2Ftwistrand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s3xysteak%2Ftwistrand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s3xysteak%2Ftwistrand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s3xysteak%2Ftwistrand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s3xysteak","download_url":"https://codeload.github.com/s3xysteak/twistrand/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s3xysteak%2Ftwistrand/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259884416,"owners_count":22926440,"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":["algorithm","mersenne-twister","random","seed","utils"],"created_at":"2024-11-21T14:31:24.336Z","updated_at":"2026-02-05T14:05:32.491Z","avatar_url":"https://github.com/s3xysteak.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌱 twistrand\n\n\u003e `twist` from Mersenne **Twist**er, `rand` means random.\n\n\u003cimg src=\"https://img.shields.io/badge/coverage-100%25-gold\" alt=\"Test coverage\" title=\"test coverage\" \u003e\n\nA PRNG (Pseudo Random Number Generator) library based on Mersenne Twister, written by typescript, supported both esm/cjs.\n\n## 🔧 Install\n\n```sh\npnpm i twistrand\n```\n\n## 📝 Usage\n\n### Basic\n\n```js\nimport rand from 'twistrand'\n\nconst mtDefault = rand(/* Use `Date.now()` in default */)\n\nconst mt1 = rand(12345)\nconst mt2 = rand(12345)\n\nmt1.random() === mt2.random() // true\nmt1.randomInt(0, 100) === mt2.randomInt(0, 100) // true\nmt1.randomFloat(0.0, 100.0) === mt2.randomFloat(0.0, 100.0) // true\n\nconst mt = rand(12345)\nconst v1 = mt.random()\nconst v2 = mt.random()\n\nv1 !== v2 // true\n```\n\n### Output\n\n```js\nconst mt = rand()\n```\n\n- `x = mt.random()`: `x ∈ [0, 1)`\n- `x = mt.randomFloat(0, 100)`: `x ∈ [0, 100)`\n- `x = mt.randomInt(0, 100)`: `x ∈ [0, 100]` `x ∈ Z`\n\n\u003e More usage please refer to [test](/test/).\n\n## 🛠️ test\n\n### bench\n| Name                        | Hz               | Min    | Max    | Mean   | P75    | P99    | P995   | P999   | RME     | Samples   |\n|-----------------------------|------------------|--------|--------|--------|--------|--------|--------|--------|---------|-----------|\n| vanilla Math.random()       | 24,067,422.00    | 0.0000 | 0.3725 | 0.0000 | 0.0001 | 0.0001 | 0.0002 | 0.0003 | ±0.62%  | 12,033,711|\n| new instance creation       | 196,243.61       | 0.0040 | 0.2943 | 0.0051 | 0.0045 | 0.0228 | 0.0571 | 0.0821 | ±0.78%  | 98,122    |\n| random() generation         | 25,231,394.95    | 0.0000 | 0.3242 | 0.0000 | 0.0001 | 0.0001 | 0.0001 | 0.0011 | ±0.46%  | 12,615,700|\n| randomInt() generation      | 24,670,312.00    | 0.0000 | 0.2475 | 0.0000 | 0.0001 | 0.0001 | 0.0001 | 0.0011 | ±0.47%  | 12,335,156|\n| randomFloat() generation    | 25,245,832.00    | 0.0000 | 1.3302 | 0.0000 | 0.0001 | 0.0001 | 0.0001 | 0.0011 | ±0.71%  | 12,622,916|\n\n### % Coverage report from v8\n| File                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |\n|----------------------|---------|----------|---------|---------|-------------------|\n| All files            |     100 |      100 |     100 |     100 |                   |\n| index.ts             |     100 |      100 |     100 |     100 |                   |\n| mersenne-twister.ts  |     100 |      100 |     100 |     100 |                   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs3xysteak%2Ftwistrand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs3xysteak%2Ftwistrand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs3xysteak%2Ftwistrand/lists"}