Created
May 9, 2017 12:52
-
-
Save honzabrecka/ccf3d21a8a52a1b2d4063277fb1fada1 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
| enum Flags { | |
| A = 1, | |
| B = 2, | |
| C = 4 | |
| } | |
| // number means uint | |
| const allowed = (flags: number, flag: Flags): boolean => (flags & flag) === flag | |
| const allowedFlags = Flags.B | Flags.C | |
| console.log(allowed(allowedFlags, Flags.A))// -> false | |
| console.log(allowed(allowedFlags, Flags.B))// -> true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment