Skip to content

selectRandomBand

Jason Godesky edited this page Jul 18, 2026 · 1 revision

selectRandomBand is essentially a method to construct and roll on a random table.

Interface

interface RandomTableBand<T> {
  range: number[]
  value: T
}

Parameters

bands: Array<RandomTableBand<T>>

The bands you’d like to select randomly amongst.

Returns

The value of one band, randomly selected based on the relative size of its range.

Examples

import { selectRandomBand } from '@revolutionarygamesco/common'

selectRandomBand<string>([
  { range: [1, 3], value: '50% chance of getting this' },
  { range: [4, 5], value: '1 in 3 chance of getting this' },
  { range: [6], value: '1 in 6 chance of getting this' }
])

Clone this wiki locally