simd-prng - v0.2.3
    Preparing search index...

    Interface Prng

    A pseudo-random generator.

    Each generator consumes a certain amount of resources from an underlying WebAssembly instance. In order to have a small code size footprint, we make some tradeoffs with regards to memory consumption:

    • Creating many Prng instances can exhaust the available space. The precise amount is left unspecified, but is in the order of 100s of instances.
    • A discarded instance eventually frees its resources, but in a scenario of where lots of instances are being created and quickly discarded, it is better to explicitly call destroy().
    interface Prng {
        seed: number | Uint32Array<ArrayBufferLike>;
        destroy(): void;
        random(): number;
        randomInt(): number;
    }
    Index

    Properties

    Methods

    Properties

    seed: number | Uint32Array<ArrayBufferLike>

    The initial seed for this generator.

    Methods

    • Destroys the generator and releases its resources. After calling this, the generator cannot be used and trying to generate more random data will throw.

      A generator releases its resources automatically when garbage-collected. This method is only useful if you want to guarantee prompt destruction if e.g. you are creating and discarding lots of generators.

      Returns void

    • Generates a random floating-point number in the [0, 1) range, a la Math.random().

      Returns number

    • Generates a random 32-bit unsigned integer.

      Returns number