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.
makeEnum is a convenience wrapper for makeStringUnionGuard and selectRandomElement that makes it easy for us to instantiate the pattern of string union “enums” that we favor.
values: readonly string[]
The array of values to enumerate. This must be declared as const!
as const
An object with two methods: guard and randomizer.
guard
randomizer
guard: (candidate: unknown) => candidate is T
A type guard for the type being defined.
randomizer: () => T
A method that returns a randomly-selected option.
import { makeEnum } from '@revolutionarygamesco/common' const options = ['a', 'b', 'c'] as const export type TestOption = typeof options[number] export const { guard: isTestOption, randomizer: selectRandomTestOption } = makeEnum(options)