Type Parameters

Hierarchy

  • Random

Constructors

Properties

generator: G

Methods

  • Returns Random<G>

  • Generates a random boolean

    Returns boolean

  • Returns whether a chance passes, given a decimal number.

    Example: chance(0.1) is a 1/10 chance, chance(0.8) is a 4/5 chance

    Parameters

    • decimal: number

    Returns boolean

  • Chooses a random entry in an array and returns it

    Type Parameters

    • A extends any[]

    Parameters

    • Rest ...from: A

    Returns A[number]

  • Type Parameters

    • T

    Parameters

    • Optional requiresSynchronization: boolean
    • Optional initialState: T

    Returns Random<G>

  • Generates a random number between 0 (inclusive) and 1 (exclusive)

    Returns number

  • Generates a random number between 0 (inclusive) and max (exclusive)

    Parameters

    • max: number

    Returns number

  • Generates a random number between min (inclusive) and max (exclusive)

    Parameters

    • min: number
    • max: number

    Returns number

  • Generates a random number from the given range.

    Parameters

    Returns number

  • Type Parameters

    • T

    Parameters

    • array: T[]

    Returns T

  • Generates a random integer between 0 (inclusive) and max (exclusive)

    Parameters

    • max: number

    Returns number

  • Generates a random integer between min (inclusive) and max (exclusive)

    Parameters

    • min: number
    • max: number

    Returns number

  • Generates a random integer from the given range.

    Parameters

    Returns number

  • Generates a random integer between min and max (inclusive)

    Parameters

    • min: number
    • max: number

    Returns number

  • Parameters

    Returns number

  • Generates a rounded number between a range of numbers using exponential interpolation with optional weight. Note: Thanks ChatGPT!

    Returns

    number between provided min/max, rounded.

    Parameters

    • min: number

      Minimum number of range.

    • max: number

      Maximum number of range.

    • steepness: number = 5

      Steepness of the curve.

    Returns number

  • Get a percentage for something Returns a number between 1 and 100 (inclusive)

    Parameters

    • minChance: number = 0
    • chanceOutOf: number = 100
    • ceil: boolean = true

    Returns number

  • Returns a new array containing random choices from a given array.

    Type Parameters

    • T = any

    Parameters

    • arr: T[]

      The array to return items from

    • count: number

      The number of items to return in the array

      Note: Be careful. This method can be very slow if used on a big array with a high count.

    Returns T[]

  • Returns a new shuffled array

    Type Parameters

    • T

    Parameters

    • array: readonly T[]

    Returns T[]

  • Modifies an array and shuffles it

    Type Parameters

    • T

    Parameters

    • array: T[]

    Returns T[]

  • Returns a random T from the given choices, where each choice is weighted by a number. Higher numbers = higher chance.

    Type Parameters

    • T

    Parameters

    Returns T

  • Type Parameters

    • T

    Parameters

    • generator: G
    • execute: (() => T)
        • (): T
        • Returns T

    Returns T

Generated using TypeDoc