enum-nom-nommer
Create a numeric or mixed enumeration (enum) from a plain-old JavaScript object.
Table of Contents
1. Install
npm i enum-nom-nommer
2. Usage
Test enum-nom-nommer in your Web browser on RunKit
.
Create a numeric (indexed) enumeration:
const enumFactory = const levels = debug: 5 error: 0 http: 3 info: 2 silly: 6 verbose: 4 warn: 1 const logLevelsEnum = enumFactory/* =>{ 0: 'error', 1: 'warn', 2: 'info', 3: 'http', 4: 'verbose', 5: 'debug', 6: 'silly', debug: 5, error: 0, http: 3, info: 2, silly: 6, verbose: 4, warn: 1}*/
Create a mixed-type enum:
const validSignatureTypes = MATCH: "match" REGEX: "regex" match: 0 regex: 1;const validTypesEnum = enumFactory;/* =>{ '0': 'match', '1': 'regex', 'MATCH': 'match', 'match': 0, 'REGEX': 'regex', 'regex': 1}*/
3. Maintainers
4. Contributing
We gratefully accept Pull Requests.
Please review the CONTRIBUTING guidelines and join in.