Skip to content

hax/typed-enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

typed-enum

Greenkeeper badge

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

About

Enum factory in typed JavaScript

Resources

Stars

Watchers

Forks

Packages

No packages published