We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
stockArray stocks an array with a number of values.
Tip
A common use pattern is to use stockArray to “put things in the hat” and selectRandomElement to “pull one out of the hat.”
stockArray
selectRandomElement
stock: Array<{ n: number, item: T }>
An array of objects. For each object, n sets the number of times that item should be added to the array.
n
item
A new array created according to the directions from stock.
stock
import { stockArray } from '@revolutionarygamesco/common' const stock: Array<{ n: number, item: boolean }> = [ { n: 2, item: false }, { n: 1, item: true } ] stockArray<boolean>(stock) // [false, false, true]