enumy

1.0.1 • Public • Published

enumy

A tiny npm module for creating basic enumerables.

Usage

var enumy = require('enumy');
 
var Planets = enumy(
    'PLANET_MERCURY',
    'PLANET_VENUS',
    'PLANET_EARTH',
    'PLANET_MARS',
    'PLANET_JUPITER',
    'PLANET_SATURN',
    'PLANET_URANUS',
    'PLANET_NEPTUNE'
);
 
console.log(Planets.PLANET_MERCURY);
// #=> 'PLANET_MERCURY'

A common pattern is to expose an enum as a module. To do this, just tack on:

module.exports = Planets

to the above file, then you can require('./path/to/Planets.js') and use the enum wherever you'd like.

That's it!

Readme

Keywords

Package Sidebar

Install

npm i enumy

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • south