Package Exports
- seed-random
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (seed-random) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
seed-random
Generate random numbers with a seed, useful for reproducible tests
Installation
$ npm install seed-random
API
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 true
seed.resetGlobal();//reset to default Math.random
License
MIT