Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 630 Bytes

README.md

File metadata and controls

17 lines (13 loc) · 630 Bytes

Javascript Enum

An enum data type that is based on the javascript symbol primitive type. Using symbol values ensures type safety of the enum as each symbol value is guaranteed by javascript to be unique.

Example:

const color = new Enum('RED', 'BLUE')

color.RED.toString() // 'Symbol(RED)'
color.getName(color.RED) // 'RED'
color.size // 2
color.values() // Symbol(RED), Symbol(BLUE)
color.toString() // 'RED,BLUE'
color.valueOf('RED') // Symbol(RED)

Plunker demo