diff options
Diffstat (limited to 'app/lib/enum.js')
| -rw-r--r-- | app/lib/enum.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/app/lib/enum.js b/app/lib/enum.js new file mode 100644 index 0000000000..bc8e4b54aa --- /dev/null +++ b/app/lib/enum.js @@ -0,0 +1,20 @@ +import assert from 'assert'; + +/** + * Creates enum object with keys provided as arguments + */ +export default function Enum() { + let object = {}; + + for(const key of arguments) { + Object.defineProperty(object, key, { + enumerable: true, + value: key, + writable: false + }); + } + + Object.freeze(object); + + return object; +}; |
