@nixjs23n6/ts-enumify
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

@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 --dev husky

Example

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"

Package Sidebar

Install

npm i @nixjs23n6/ts-enumify

Weekly Downloads

2

Version

0.0.1

License

MIT

Unpacked Size

5.98 kB

Total Files

7

Last publish

Collaborators

  • nixjs23n6