another-enum

Another enum module, nothing more

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
Minified + gzip package size for another-enum in KB

Readme

ANOTHER-ENUM changelog

Another enum module, nothing more


npm install

docs build tests coverage audit dependencies


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:
        // ...
}

version npm install

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.