Created
September 30, 2016 14:28
-
-
Save karlkori/66b780fb767713999218e7c0112631ad to your computer and use it in GitHub Desktop.
two directions constant
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
| const Role = new Proxy({ | |
| ADMIN: 1, | |
| USER: 2, | |
| GUEST: 3 | |
| }, { | |
| get(target, key) { | |
| return isNaN(key) ? target[key] : _.findKey(target, val => val == key); | |
| } | |
| }); | |
| console.info(Role.ADMIN); | |
| console.info(Role[1]); | |
| console.info(Role[2]); | |
| console.info(Role[3]); | |
| console.info(Role[4]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment