Skip to content

Repository files navigation

@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-enumify
pnpm add @nixjs23n6/ts-enumify
yarn add @nixjs23n6/ts-enumify
bun add -@nixjs23n6/ts-enumify

Example

import{Enumify}from'@nixjs23n6/ts-enumify'constEnumKey=Enumify.generate(['ENUM1','ENUM2','ENUM3']asconst)// const EnumKey: Readonly<Enumify.ToObj<"ENUM1" | "ENUM2" | "ENUM3">>typeEnumType=keyoftypeofEnumKey// type EnumType = "ENUM1" | "ENUM2" | "ENUM3"

About

Generates a enum (like an object) with keys and values based on the elements of an array.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Used by

Contributors

Languages