another-enum

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i another-enum

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

19.6 kB

Total Files

13

Last publish

Collaborators

  • magnaar