Created
July 20, 2017 17:55
-
-
Save TheAlchemist64/55c7f55899de7f19118028ee55fcea77 to your computer and use it in GitHub Desktop.
An Enum type for ES6
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
export default class Enum{ | |
constructor(){ | |
let args = Array.prototype.slice.call(arguments); | |
let i = 0; | |
args.forEach((val)=>{ | |
this[val] = i++; | |
}); | |
Object.freeze(this); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment