Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/forbeslindesay/seed-random
Generate random numbers with a seed, useful for reproducible tests
https://github.com/forbeslindesay/seed-random
Last synced: 11 days ago
JSON representation
Generate random numbers with a seed, useful for reproducible tests
- Host: GitHub
- URL: https://github.com/forbeslindesay/seed-random
- Owner: ForbesLindesay
- License: other
- Created: 2012-11-23T20:02:36.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T09:48:05.000Z (3 months ago)
- Last Synced: 2024-10-20T04:43:58.012Z (24 days ago)
- Language: JavaScript
- Homepage: http://davidbau.com/archives/2010/01/30/random_seeds_coded_hints_and_quintillions.html
- Size: 10.7 KB
- Stars: 39
- Watchers: 5
- Forks: 8
- Open Issues: 5
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# seed-random
Generate random numbers with a seed, useful for reproducible tests
[![build status](https://secure.travis-ci.org/ForbesLindesay/seed-random.png?branch=master)](http://travis-ci.org/ForbesLindesay/seed-random)
[![Dependency Status](https://img.shields.io/david/ForbesLindesay/seed-random.svg)](https://david-dm.org/ForbesLindesay/seed-random)
[![NPM version](https://img.shields.io/npm/v/seed-random.svg)](https://www.npmjs.com/package/seed-random)## Installation
$ npm install seed-random
## API
```javascript
var assert = require('assert');
var seed = require('../');var trueRandomA = seed();
var trueRandomB = seed();
assert(trueRandomA() != trueRandomB());var fakeRandomA = seed('foo');
var fakeRandomB = seed('foo');
assert(fakeRandomA() == fakeRandomB());var fakeRandomC = seed('foo', {entropy: true});
var fakeRandomD = seed('foo', {entropy: true});
assert(fakeRandomC() != fakeRandomD());seed('foo', {global: true});//over-ride global Math.random
var numA = Math.random();
seed('foo', {global: true});
var numB = Math.random();
assert(numA == numB);//always trueseed.resetGlobal();//reset to default Math.random
```## License
MIT