Created
February 23, 2021 06:35
-
-
Save ilhamgusti/2649250130a344e08ba22cc9bdc8346c 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
/** | |
* Helper to produce an array of enum values. | |
* @param enumeration Enumeration object. | |
*/ | |
export function enumToArray<T, G extends keyof T = keyof T>(enumeration: T): T[G][] { | |
const enumVals = Object.values(enumeration); | |
return enumVals.slice(enumVals.length / 2, enumVals.length) as T[G][]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment