typed-enum

0.1.1 • Public • Published

typed-enum

Enum Factory in Typed JavaScript.

Build Status

Example

var Sex = Enum('male', 'female')
 
//all expressions return true
Sex.MALE instanceof Sex && Sex.FEMALE instanceof Sex
Sex.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 version

npm install typed-enum

Bower

Bower version

bower install typed-enum

Import

CommonJS (Node.js), AMD (RequireJS), CMD (Sea.js)

var Enum = require('typed-enum')

Naked script

<script src='path_to/enum.min.js'></script>
<script>
var Enum = MY_MODULES['typed-enum'].exports
</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

Readme

Keywords

none

Package Sidebar

Install

npm i typed-enum

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • hax