ANOTHER-ENUM
Another enum module, nothing more
Simple usage
Advanced usage
Methods listing
Import
import { Enum } from 'another-enum'
// Or
const Enum = require('another-enum').Enum
Basic instanciation
Enum.EnumName(NAME1, NAME2, ...)
Enum.EnumName({
NAME1: value1,
NAME2: value2,
...
})
See also: Enum Constructors
See also: Instanciation with base
See also: Custom methods
Examples
const Colors = Enum.Colors('RED', 'GREEN', 'BLUE')
const HexaColors = Enum.HexaColors(16, {
RED: 0xFF0000,
GREEN: 0x00FF00,
BLUE: 0x0000FF
})
// For more explanation, you should take a look at:
// - Enum constructors
// - Instanciation with base
// Some nice constructors
// Automatic incrementation
Enum.Values({
VALUE1: 2,
VALUE2: {}, // value: 3
VALUE3: 8,
VALUE4: {}, // value: 9
VALUE5: {} // value: 10
})
const obj = {
[Values.VALUE1]: 'value1',
[Values.VALUE2]: 'value2'
}
switch (color)
{
case Values.VALUE1:
// ...
break
case Values.VALUE2:
// ...
break
default:
// ...
}