easy-enum-js
A javascript enumeration class for nodejs.
Usage
The module exports a class Enum. Instantiation is easy:
let Enum = ;const SampleEnum = 'red' 'green' 'blue';
Values can be accessed by standard dot notation.
console;// output: 1
Or by the included function getVal(key).
A number of functions are included:
toString()
const SampleEnum = 'red' 'green' 'blue';SampleEnum;// output: "{ "blue": 0; "green": 1; "red": 2 }"
toObject()
const SampleEnum = 'red' 'green' 'blue';SampleEnum;// output: { "blue": 0, "green": 1, "red": 2 }
getVal(key)
const SampleEnum = 'red' 'green' 'blue';SampleEnum;// output: 2