Created
November 22, 2017 06:01
-
-
Save williscool/39ad5473524fab34bbb4d43e7e9e8c11 to your computer and use it in GitHub Desktop.
filterEnum in typescript
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
/** | |
* Filters am emum to only return the keys represented in it | |
* | |
* How is this not built into the language? | |
* https://stackoverflow.com/a/21294925/511710 | |
* https://noahbass.com/posts/typescript-enum-iteration | |
* | |
* @param {{}} e | |
* @returns | |
*/ | |
function filterEnum(e: {}) { | |
return Object.keys(e).filter(v => isNaN(Number(v))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment