enums-manager
Install
npm i -D enums-manager
Yet another enums implementation? Hey! I just want an enumerable list with a special type and an iterator.
Usage
import { EnumerableList, Enum } from 'enums-manager';
EnumerableList class
EnumerableList
extends Map
so all Map
method work according to the native implementation.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
// create a new listconst types = 'designer' 'programmer' 'webdeveloper';
Getting values
console; // Enum {2, key: "programmer", value: 2}
Since the value isn't an instance of Number
you have to be vary of the fact that a strict comparison ===
of a number will fail.
console; // trueconsole; // falseconsole; // true
Enum class
console; // programmerconsole; // 2// iterationtypes;