mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
20 lines
628 B
JavaScript
20 lines
628 B
JavaScript
import AleaRandomGenerator from './AleaRandomGenerator'
|
|
import createAleaGeneratorWithGeneratedSeed from './createAleaGenerator';
|
|
|
|
export default function createRandom(generator) {
|
|
// Create a non-cryptographically secure PRNG with a given seed (using
|
|
// the Alea algorithm)
|
|
generator.createWithSeeds = (...seeds) => {
|
|
if (seeds.length === 0) {
|
|
throw new Error('No seeds were provided');
|
|
}
|
|
return new AleaRandomGenerator({ seeds });
|
|
};
|
|
|
|
// Used like `Random`, but much faster and not cryptographically
|
|
// secure
|
|
generator.insecure = createAleaGeneratorWithGeneratedSeed();
|
|
|
|
return generator;
|
|
}
|