0.0.1 • Published 2 years ago
@nixjs23n6/ts-enumify v0.0.1
@nixjs23n6/ts-enumify
Generates a enum (like an object) with keys and values based on the elements of an array.
Install
npm install @nixjs23n6/ts-enumifypnpm add @nixjs23n6/ts-enumifyyarn add @nixjs23n6/ts-enumifybun add --dev huskyExample
import { Enumify } from '@nixjs23n6/ts-enumify'
const EnumKey = Enumify.generate(['ENUM1', 'ENUM2', 'ENUM3'] as const) // const EnumKey: Readonly<Enumify.ToObj<"ENUM1" | "ENUM2" | "ENUM3">>
type EnumType = keyof typeof EnumKey // type EnumType = "ENUM1" | "ENUM2" | "ENUM3"0.0.1
2 years ago