Skip to content

Instantly share code, notes, and snippets.

@williscool
Created November 22, 2017 06:01
Show Gist options
  • Save williscool/39ad5473524fab34bbb4d43e7e9e8c11 to your computer and use it in GitHub Desktop.
Save williscool/39ad5473524fab34bbb4d43e7e9e8c11 to your computer and use it in GitHub Desktop.
filterEnum in typescript
/**
* 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