enum-nom-nommer

1.0.0 • Public • Published

enum-nom-nommer

The MIT License NPM version FOSSA Status Known Vulnerabilities
Dependency Status Development Dependency Status
MacOS and Ubuntu build statuses Windows build status Coverage percentage Codacy code quality

Create a numeric or mixed enumeration (enum) from a plain-old JavaScript object.

Table of Contents

1. Install

npm i enum-nom-nommer

Back to Table of contents [toc]

2. Usage

Test it out on RunKit.com Test enum-nom-nommer in your Web browser on RunKit Try enum-nom-nommer 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
}
*/

Back to Table of contents [toc]

3. Maintainers

Maintenance

@gregswindle

Back to Table of contents [toc]

4. Contributing

GitHub Contributors GitHub GitHub Greenkeeper badge

Gratitude We gratefully accept Pull Requests.

Please review the CONTRIBUTING guidelines and join in.

Back to Table of contents [toc]

5. License

MIT © Greg Swindle

Law View current and detailed legal NOTICE report.

FOSSA Status

Back to Table of contents [toc]

Package Sidebar

Install

npm i enum-nom-nommer

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

33.7 kB

Total Files

5

Last publish

Collaborators

  • gregswindle