Last active
June 11, 2016 00:08
-
-
Save adamcarr/4efa14919e36b5105d21a87a3e2310f3 to your computer and use it in GitHub Desktop.
This file contains 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
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