@adviser/cement - v0.0.0
    Preparing search index...

    Class RandomService

    Random number generator with deterministic modes for testing.

    Provides random number generation that can operate in different modes:

    • RANDOM: Uses Math.random() for real random values
    • CONST: Always returns a constant value (0.5 * max) for reproducible tests
    • STEP: Returns incrementing values for predictable test sequences
    // Production: real randomness
    const random = new RandomService(RandomMode.RANDOM);
    const value = random.Random0ToValue(100); // 0-100

    // Testing: constant value
    const constRandom = new RandomService(RandomMode.CONST);
    const value = constRandom.Random0ToValue(100); // Always 50

    // Testing: stepped sequence
    const stepRandom = new RandomService(RandomMode.STEP);
    const v1 = stepRandom.Random0ToValue(100); // 0.01
    const v2 = stepRandom.Random0ToValue(100); // 0.02
    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    _mode: string
    _step: number = 0

    Methods

    • Generates a random number between 0 and the specified value.

      Parameters

      • value: number

        Maximum value (exclusive upper bound)

      Returns number

      Random number in range [0, value)