Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

es6-enum

Version js-standard-style npm download Circle CI

Installation

npm install es6-enum

Usage

import Enum from "es6-enum"

const ORIENTATION = Enum("NORTH", "SOUTH", "WEST", "EAST")
const ORIEN = Enum("NORTH", "SOUTH", "WEST", "EAST")

typeof ORIENTATION.NORTH                      // "symbol"

ORIENTATION.NORTH === ORIENTATION.NORTH       // true
ORIENTATION.NORTH === ORIEN.NORTH             // false

export ORIENTATION

In practice

I like use this package to define constant in Redux

constant.js
  const APPLICATION = Enum('USER')

action.js
  dispatch({
    type: APPLICATION.USER,
    data
  })

reducer.js
  [APPLICATION.USER]: (state, action) => {
    ...
  }

License

MIT

About

Enum type in JS, make use of es6

Resources

License

Packages

No packages published