{"id":16202139,"url":"https://github.com/michaeldzjap/rand-seed","last_synced_at":"2025-03-23T07:07:05.337Z","repository":{"id":55499721,"uuid":"162012630","full_name":"michaeldzjap/rand-seed","owner":"michaeldzjap","description":"A small seedable random number generator library written in TypeScript","archived":false,"fork":false,"pushed_at":"2024-09-24T04:26:58.000Z","size":1826,"stargazers_count":32,"open_issues_count":3,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T06:15:10.298Z","etag":null,"topics":["javascript","javascript-library","random","typescript","typescript-library"],"latest_commit_sha":null,"homepage":null,"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/michaeldzjap.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":"2018-12-16T15:07:00.000Z","updated_at":"2025-03-09T19:20:01.000Z","dependencies_parsed_at":"2024-01-21T10:24:55.521Z","dependency_job_id":"2e096fbf-4de6-4c1e-a5a4-dfaaa88034ff","html_url":"https://github.com/michaeldzjap/rand-seed","commit_stats":{"total_commits":136,"total_committers":1,"mean_commits":136.0,"dds":0.0,"last_synced_commit":"d7ddfa165b8a136a685b11599d17d549dbb4f101"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeldzjap%2Frand-seed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeldzjap%2Frand-seed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeldzjap%2Frand-seed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeldzjap%2Frand-seed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeldzjap","download_url":"https://codeload.github.com/michaeldzjap/rand-seed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245066676,"owners_count":20555427,"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":["javascript","javascript-library","random","typescript","typescript-library"],"created_at":"2024-10-10T09:45:41.922Z","updated_at":"2025-03-23T07:07:05.307Z","avatar_url":"https://github.com/michaeldzjap.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![NPM Version](https://img.shields.io/npm/v/rand-seed.svg?branch=master)\n![downloads](https://img.shields.io/npm/dt/rand-seed.svg)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/michaeldzjap/rand-seed/ci.yml?branch=master)\n![Libraries.io dependency status for GitHub repo](https://img.shields.io/librariesio/github/michaeldzjap/rand-seed)\n[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)\n[![codecov](https://codecov.io/gh/michaeldzjap/rand-seed/branch/master/graph/badge.svg)](https://codecov.io/gh/michaeldzjap/rand-seed)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=michaeldzjap_rand-seed\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=michaeldzjap_rand-seed)\n[![License](https://img.shields.io/npm/l/rand-seed.svg)](https://github.com/michaeldzjap/rand-seed/blob/master/LICENSE)\n\n# rand-seed\n\nA small seedable random number generator library written in TypeScript\n\nThe default `Math.random()` function doesn't allow for setting a seed. This library offers a number of different semi-random number generators which may be initialised with an arbitrary seed in string format, hence, making it possible to produce sequences of semi-random numbers that are always the same for a given seed. The implemented algorithms are detailed [here](https://stackoverflow.com/a/47593316/7024747) (note that I am not the author of that post, I merely used it for the implementation of this library).\n\n## Installation\n\nThis package is available through _npm_:\n\n```\nnpm install --save rand-seed\n```\n\n## Usage\n\nEither import directly\n\n```html\n\u003cscript src=\"path-to-rand-seed/rand-seed.js\"\u003e\u003c/script\u003e\n```\n\nor import in your own scripts using\n\n```javascript\nimport Rand, { PRNG } from 'rand-seed';\n```\n\nThen simply create a new instance with an (optional) seed:\n\n```javascript\nconst rand = new Rand('1234');\n\nrand.next(); // Generate a new random number\n```\n\nIf no seed is specified the call to `rand.next()` will simply be forwarded to `Math.random()`. In case of a supplied seed, the _sfc32_ algorithm will be used by default. Currently, three different algorithms are provided: _sfc32_, _mulberry32_ and _xoshiro128\\*\\*_. If you would like to use a different algorithm, create a new instance like so:\n\n```javascript\n// Create a new random number generator using the xoshiro128** algorithm\nconst rand = new Rand('1234', PRNG.xoshiro128ss);\n```\n\n## Example\n\nA simple example is included. This may be run with _node_: `node example/index.js`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeldzjap%2Frand-seed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeldzjap%2Frand-seed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeldzjap%2Frand-seed/lists"}