enum-cpp
v1.2.2
Published
use enum like cpp
Downloads
3
Maintainers
Readme
const Enum = require('enum-cpp')
// select
let a_enum = new Enum({
Monday: 1,
Tuesday: 2,
Wednesday: 3,
Thursday: 4,
Friday: 5,
Saturday: 6,
Sunday: 7
})
console.log(a_enum.Friday) // => 5
console.log(a_enum.get(7)) // => Sunday
// options
let b_enum = new Enum({
RED: 1 << 0,
BLUE: 1 << 1,
GREEN: 1 << 2,
ALPHA: 1 << 3
})
console.log(b_enum.BLUE) // => 2
console.log(b_enum.RED | b_enum.ALPHA) // => 9
console.log(b_enum.mget(9)) // [ 'RED', 'ALPHA' ]