Last active
April 22, 2020 17:46
-
-
Save mtford90/0cde392e7b71c6fe363ca48b126bc849 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum MyEnum { | |
/* ... */ | |
} | |
function stringToEnum(str: string): MyEnum | undefined { | |
return new Map(Object.entries(MyEnum)).get(str) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Probably a good idea to memoise the
Map
also.