PrngEngine
Defined in: src/engine/prng-engine.ts:42
The base class the seedable engines share.
It provides seeding, state save and restore, and the byte and float paths
built on nextUint32. Subclass it to add an algorithm of your own; a
subclass implements the state layout and one step of the generator.
Example
Section titled “Example”xoshiro128pp(42) instanceof PrngEngine; // truepcg32(42) instanceof PrngEngine; // true
// Not seedable, so not one of these.cryptoRandom instanceof PrngEngine; // falseExtended by
Section titled “Extended by”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new PrngEngine(
state):PrngEngine
Defined in: src/engine/prng-engine.ts:49
Parameters
Section titled “Parameters”Uint32Array
Returns
Section titled “Returns”PrngEngine
Properties
Section titled “Properties”algorithm
Section titled “algorithm”
abstractreadonlyalgorithm:string
Defined in: src/engine/prng-engine.ts:43
Identifies the algorithm in EngineState.
Implementation of
Section titled “Implementation of”seedable
Section titled “seedable”
readonlyseedable:true=true
Defined in: src/engine/prng-engine.ts:45
Whether the engine can be re-seeded. Math.random and the CSPRNG cannot.
Implementation of
Section titled “Implementation of”version
Section titled “version”
readonlyversion:number=1
Defined in: src/engine/prng-engine.ts:44
Methods
Section titled “Methods”clone()
Section titled “clone()”clone():
this
Defined in: src/engine/prng-engine.ts:111
Returns
Section titled “Returns”this
Implementation of
Section titled “Implementation of”fillBytes()
Section titled “fillBytes()”fillBytes(
out):void
Defined in: src/engine/prng-engine.ts:65
Parameters
Section titled “Parameters”Uint8Array
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”fillUint32()
Section titled “fillUint32()”fillUint32(
out):void
Defined in: src/engine/prng-engine.ts:61
Parameters
Section titled “Parameters”Uint32Array
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”getState()
Section titled “getState()”getState():
EngineState
Defined in: src/engine/prng-engine.ts:86
Returns
Section titled “Returns”Implementation of
Section titled “Implementation of”nextFloat64()
Section titled “nextFloat64()”nextFloat64():
number
Defined in: src/engine/prng-engine.ts:55
A uniform double in [0, 1) with 53 bits of precision.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”nextUint32()
Section titled “nextUint32()”
abstractnextUint32():number
Defined in: src/engine/prng-engine.ts:53
A uniform integer in [0, 2^32).
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”reseed()
Section titled “reseed()”reseed(
seed):void
Defined in: src/engine/prng-engine.ts:120
Restart from new seed material, in place.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”setState()
Section titled “setState()”setState(
state):void
Defined in: src/engine/prng-engine.ts:94
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”split()
Section titled “split()”split(
n):Engine[]
Defined in: src/engine/prng-engine.ts:129
Independent children. Engines with a jump polynomial override this for guaranteed non-overlapping streams.
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”Engine[]