Skip to content

Instantly share code, notes, and snippets.

@adamcarr
Last active June 11, 2016 00:08
Show Gist options
  • Save adamcarr/4efa14919e36b5105d21a87a3e2310f3 to your computer and use it in GitHub Desktop.
Save adamcarr/4efa14919e36b5105d21a87a3e2310f3 to your computer and use it in GitHub Desktop.
enum Test {
one,
two,
three
}
interface EnumIterator<TEnum extends number> {
iterate(myEnum: TEnum, callback: (value: number, name: string) => void): void;
}
class EnumIterator<TEnum extends number> implements EnumIterator<TEnum> {
iterate(myEnum: TEnum, callback: (value: number, name: string) => void): void {
Object.keys(myEnum).filter(x => isNaN(parseInt(x))).forEach(val => callback(<any>val, myEnum[val]))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment