Created
December 8, 2019 08:05
-
-
Save DimaCrafter/b0241341cbb918670d0e00bc75093f2f to your computer and use it in GitHub Desktop.
[JS] Vanilla enum generator
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
module.exports = function Enum (keys) { | |
let result = {}; | |
keys.forEach((key, i) => { | |
result[key] = i; | |
result[i] = key; | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment