Package Exports
- enum-nom-nommer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (enum-nom-nommer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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-nommer2. Usage
Test enum-nom-nommer in your Web browser on RunKit
.
Create a numeric (indexed) enumeration:
const { enumFactory } = require('enum-nom-nommer')
const levels = {
debug: 5,
error: 0,
http: 3
info: 2,
silly: 6,
verbose: 4,
warn: 1
}
const logLevelsEnum = enumFactory.create(levels)
/* =>
{
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.create(validSignatureTypes);
/* =>
{
'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.