Type of value (union of strings or numbers).
Object mapping keys to values (mutations prevented with Object.freeze
).
Can be used for accessing values by keys using dot syntax.
Unlike with labeled enums, a key and its value will always be exactly the same.
const STATUSES = Enum(['pending', 'fulfilled', 'rejected']);
const Status = STATUSES.accessor;
const status = Status.pending; // status is 'pending'
Lists all values.
Array of values (safe to mutate).
Checks if value is contained in enum's set of values.
Value with unknown type.
Boolean (true
if valid enum value, otherwise false
).
Checks if value is contained in enum's set of values.
Value with unknown type.
Nothing if valid enum value, throws error if invalid.
RangeError
Generated using TypeDoc
Enum object created from a list of values.
A simple enum is more similar to a union than a built-in
enum
. Unlike a LabeledEnum, no keys are defined for accessing values.