Skip to content

Instantly share code, notes, and snippets.

@ilhamgusti
Created February 23, 2021 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilhamgusti/2649250130a344e08ba22cc9bdc8346c to your computer and use it in GitHub Desktop.
Save ilhamgusti/2649250130a344e08ba22cc9bdc8346c to your computer and use it in GitHub Desktop.
/**
* 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