Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

  • randomElement<T>(arr: T[]): Promise<T>
  • Pick a random element from an array.

    Type parameters

    • T

    Parameters

    • arr: T[]

      The array to get the element from.

    Returns Promise<T>

    A promise resolving to a random element from the input array.

  • randomElementSync<T>(arr: T[]): T
  • Pick a random element from an array.

    Type parameters

    • T

    Parameters

    • arr: T[]

      The array to get the element from.

    Returns T

    A random element from the input array.

  • range(max: number, min?: number): Promise<number>
  • Generate a random value in a range (inclusive).

    Parameters

    • max: number

      The maximum value.

    • min: number = 0

      The minimum value.

    Returns Promise<number>

    A promise resolving to a random number.

  • rangeInt(max: number, min?: number): Promise<number>
  • Generate a random value in a range (inclusive) and round the result to the nearest whole number.

    Parameters

    • max: number

      The maximum value.

    • min: number = 0

      The minimum value.

    Returns Promise<number>

    A promise resolving to a random whole number.

  • rangeIntSync(max: number, min?: number): number
  • Generate a random value in a range (inclusive) and round the result to the nearest whole number.

    Parameters

    • max: number

      The maximum value.

    • min: number = 0

      The minimum value.

    Returns number

    A random whole number.

  • rangeSync(max: number, min?: number): number
  • Generate a random value in a range (inclusive).

    Parameters

    • max: number

      The maximum value.

    • min: number = 0

      The minimum value.

    Returns number

    A random number.

  • rbool(weight?: number): Promise<boolean>
  • Generate a random weighted boolean.

    Parameters

    • weight: number = 0.5

      The chance that the result will be true.

    Returns Promise<boolean>

    A promise resolving to a random boolean value.

  • rboolSync(weight?: number): boolean
  • Generate a random weighted boolean.

    Parameters

    • weight: number = 0.5

      The chance that the result will be true.

    Returns boolean

    A random boolean value.

  • srand(): Promise<number>
  • Generate a random value between 0.0 and 1.0 using a 64-bit crypto generated value.

    Returns Promise<number>

    A promise resolving to a random number.

  • srandSync(): number
  • Generate a random value between 0.0 and 1.0 using a 64-bit crypto generated value.

    Returns number

    A random number.

Generated using TypeDoc