ts-enum-util
Advanced tools
Comparing version 0.0.9 to 0.0.10
{ | ||
"name": "ts-enum-util", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "TypeScript Enum Utilities", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -69,4 +69,12 @@ [![npm version](https://img.shields.io/npm/v/ts-enum-util.svg)](https://www.npmjs.com/package/ts-enum-util) | ||
## What is it? | ||
`ts-enum-util` provides utilities to improve the usefulness of enums. Examples include getting a list of an enum's keys, values, or key/value pairs, reverse lookup of keys by value, run-time validation that a specified value or key is valid for a given enum (with corresponding compile-time type guards), and more. All of these utilities are very specifically typed for each enum via generics and type inference. | ||
`ts-enum-util` provides utilities to improve the usefulness of enums. Examples include: | ||
- Get a list of an enum's keys, values, or key/value pairs. | ||
- Lookup values by key with run-time key validation and optional result defaulting. | ||
- Reverse lookup of keys by value (for string enums too!) with run-time value validation and optional result defaulting. | ||
- Run-time validation that a specified value or key is valid for a given enum, with compile-time type guards. | ||
- Treat an enum like an Array. | ||
- Treat an enum like a Map. | ||
All of these utilities are very specifically typed for each enum via generics and type inference. | ||
## Quick Start | ||
@@ -299,2 +307,3 @@ ### Installation | ||
* *ES6 Features*: The following ES6 features are used by `ts-enum-util`, so they must exist (either natively or via polyfill) in the run-time environment: `Array.from()`, `Map`, `Set`, `Symbol.iterator`. | ||
* For certain `Iterable` features of `WrappedEnum` to work, you must either compile with a target of `es6` or higher, or enable the `downlevelIteration` compiler option. | ||
@@ -470,3 +479,3 @@ ## General Concepts | ||
## Limitations | ||
Does not work with enums that are merged with a namespace containing values (variables, functions, etc.), or otherwise have any additional properties added to the enum's runtime object. | ||
- Does not work with enums that are merged with a namespace containing values (variables, functions, etc.), or otherwise have any additional properties added to the enum's runtime object. | ||
- Requires the `preserveConstEnums` TypeScript compiler option to work with `const enums`. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133831
479