Releases: UselessPickles/ts-enum-util
Removed peer dependency on TypeScript
The peer dependency on TypeScript was more trouble than it was worth. See #16
Non-positive-integer enum value bug fixes
This is a bug fix for numeric enums whose values are not all positive integers.
The code that gets all of the keys of an enum (ignoring the reverse lookup keys that typescript automatically adds) incorrectly assumed that all numeric enum values (and therefore the reverse lookup keys) would be limited valid array index values (basically, non-negative integers within the range of a signed 32-bit value).
This was a bad assumption. Numeric enums can contain any numeric values, including floating point and negative values. The end result was widespread bugs if you had a numeric enum values that was negative or not an integer.
New Value Visitor/Mapper Functionality
Huge New Feature!
The functionality of ts-string-visitor
(npm, github) has been merged into ts-enum-util
and improved to also support numeric literal/enum values. See the README for a link to full documentation of Value Visitor/Mapper functionality, and also a Migration Guide if you previously used ts-string-visitor
.
This unfortunately brought with it a breaking change: TypeScript 2.9 is now the minimum supported version.
Other New Features
- (possibly breaking) The iteration/sort order of enum entries/values/keys is no longer based on sorted key order. The original defined order of the enum is now retained (guaranteed in ES6 environments due to language spec, all but guaranteed in non-ES6 environments due to de-facto standards of nearly all implementations). This is more likely to give desired results if you use
$enum().map()
to create options for a dropdown UI component, for example. - New
$enum().indexOfValue()
to get the index of an enum entry based on a value. Can be useful for implementing sort comparators for grids, etc. - New
$enum().indexOfKey()
to get the index of an enum entry based on a key. Can be useful for implementing sort comparators for grids, etc.
@@toStringTag Implementation
The @@toStringTag symbol is now implemented on EnumWrapper
@@toStringTag Implementation
The @@toStringTag symbol is now implemented on EnumWrapper
Fix published NPM package
The publish NPM package for version 3.0.5 was missing files. This version is simply a re-build and re-publish of 3.0.5 to fix the NPM package.
Minor Type Definitions Fix
The convenience types NumberEnumWrapper
, StringEnumWrapper
and MixedEnumWrapper
were incorrectly defined by using type any
instead of type T
.
This had no impact on typical usage of ts-enum-util
.
Minor Type Definitions Fix
The convenience types NumberEnumWrapper
, StringEnumWrapper
and MixedEnumWrapper
were incorrectly defined by using type any
instead of type T
.
This had no impact on typical usage of ts-enum-util
.
Minor Code Simplification
Removed an unnecessary conditional in iterator code.
Minor Code Simplification
Removed an unnecessary conditional in iterator code.