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.