Get each and every item in array, randomly.
This package is ESM only.
$ npm install @dtjv/randomize-array
import { randomizeArray } from '@dtjv/randomize-array'
const getCharacter = randomizeArray(['🍩', '☕️', '🤓'])
getCharacter() //-> '☕️'
getCharacter() //-> '🤓'
getCharacter() //-> '🍩'
getCharacter() //-> undefined
import { randomizeArray } from '@dtjv/randomize-array'
Returns a function, where each invocation returns a unique random value from
array
until all values are returned. Subsequent calls return undefined
(unless the reset option is set to true
, or
restart is called).
Type: unknown[]
Default: []
Array of values to randomly access.
Type: Object
Type: boolean
Default: false
Makes all values of array
available for random selection once all values have
been retrieved.
import { restart } from '@dtjv/randomize-array'
Makes all values of array
available for random selection.