GithubHelp home page GithubHelp logo

gregswindle / enum-nom-nommer Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 5.03 MB

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

License: MIT License

Shell 46.05% JavaScript 53.95%
enum enumerator enumeration enum-factory enumerable

enum-nom-nommer's Introduction

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]

enum-nom-nommer's People

Contributors

gregswindle avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

fossabot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.