EnumObject type
Any TypeScript enum, or a const object used as one.
ts
import type { EnumObject } from 'utils';Signature
ts
export type EnumObject = Readonly<Record<string, number | string>>;Tests
Line coverage: 0 %.
Source
src/enum/enum-object.ts (on GitHub)
Used by
getEnumEntries: Lists the members of an enum as[name, value]pairs, without the reverse mapping of numeric enums.getEnumKey: Finds the member name of an enum value, string enums included: a readable name for a log or a translation key.getEnumKeys: Lists the member names of an enum, without the reverse mapping of numeric enums.getEnumValues: Lists the values of an enum, without the names of the reverse mapping of numeric enums.isEnumValue: Checks whether a value is one of the values of an enum, in O(1): the values of each enum are read once.parseEnumValue: Reads an enum member from a text, such as a query parameter:'1'gives the member of value1.toEnumValue: Returns a value typed as an enum member: the value itself when it belongs to the enum, the fallback otherwise.
Source code
ts
/** Any TypeScript enum, or a `const` object used as one. */
export type EnumObject = Readonly<Record<string, number | string>>;Keywords: enum, object, enums, type