Created
April 19, 2019 19:45
-
-
Save DDzia/258c21b84cbecc9d3aefd482c34e721b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* Get all keys from enumeration. | |
*/ | |
public static keys(enumType: object) { | |
const members = Object.keys(enumType);<br /> let keys: string[]; | |
if (!EnumHelpers.isNumeral(enumType)) { | |
keys = members; | |
} else { | |
keys = []; | |
members.forEach(x => { | |
const parsedValue = parseInt(x, 10); | |
if (Number.isNaN(parsedValue)) { | |
keys.push(x); | |
} | |
}); | |
} | |
// key of enumeration can't be number | |
return keys.filter(x => Number.isNaN(parseInt(x, 10))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment