typed-enum
Enum Factory in Typed JavaScript.
Example
var Sex = Enum('male', 'female') //all expressions return trueSex.MALE instanceof Sex && Sex.FEMALE instanceof SexSex.MALE.value === 'male' && Sex.FEMALE.value === 'female'Sex.MALE == 'male' && Sex.FEMALE == 'female'JSON.stringify(Sex.MALE) === '"male"' && JSON.stringify(Sex.FEMALE) === '"female"'Sex.has('male') && Sex.has('female') && !Sex.has('foo')Sex('male') === Sex.MALE && Sex('female') === Sex.FEMALE
Install
Download Latest
Download the compressed, production file
Download the uncompressed, development file and the source map file
NPM
npm install typed-enum
Bower
bower install typed-enum
Import
CommonJS (Node.js), AMD (RequireJS), CMD (Sea.js)
var Enum = require('typed-enum')
Naked script
Development
Issues
https://github.com/hax/typed-enum/issues
Build
npm run build
Test in Node.js
npm test
Test in browsers
open test/index.html