UNPKG

@ncoderz/superenum

Version:

Simple, typesafe enums in TypeScript, fully compatible with standard JavaScript

45 lines (23 loc) 903 B
[**@ncoderz/superenum**](../README.md) *** [@ncoderz/superenum](../globals.md) / Enum # Function: Enum() > **Enum**\<`K`, `V`, `T`\>(`enm`): [`Superenum`](../interfaces/Superenum.md)\<`K`, `V`, `T`\> Defined in: [superenum.ts:243](https://github.com/ncoderz/superenum/blob/08c1c2419d89a58d6deeaad343b246571a3c3674/src/superenum.ts#L243) Wraps an enum or enum-like object to provide methods for interacting with it. Uses a WeakMap and lazy instantiation to cache the enum's keys, values, and labels for fast performance while keeping memory footprint small. ## Type Parameters ### K `K` *extends* `string` ### V `V` *extends* `string` \| `number` ### T `T` *extends* `ObjectEnum`\<`K`, `V`\> ## Parameters ### enm `T` an enum or enum like object ## Returns [`Superenum`](../interfaces/Superenum.md)\<`K`, `V`, `T`\> a Superenum object that provides methods to interact with the enum