Skip to content

Instantly share code, notes, and snippets.

@NewEXE
Created July 6, 2022 12:42
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 NewEXE/f8b466f8d46d144e76e1c270d237ecd0 to your computer and use it in GitHub Desktop.
Save NewEXE/f8b466f8d46d144e76e1c270d237ecd0 to your computer and use it in GitHub Desktop.
Get enum key by value (Typescript)
export const getEnumKeyByValue = (enumerated, value: string) => {
return Object.keys(enumerated)[
Object.values(enumerated).indexOf(value as typeof enumerated)
];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment