hs-enum

0.1.2 • Public • Published

Headspring Enumeration

NPM version NPM downloads Build Status Coverage Status Dependency Status

How to Install

$ npm install hs-enum

Getting Started

import E from 'hs-enum'
const myEnum = new E([
    { key: 'HELLO_MESSAGE',
      value: 0,
      displayName: 'Hello JavaScripters!'
    }
}])
 
const val = myEnum.HELLO_MESSAGE.value // 0
const key = myEnum.findKeyFromValue(0) // 'HELLO_MESSAGE'
const name = myEnum.getDisplayNameFromValue(0) // 'Hello JavaScripters!'
const obj = myEnum.getFromValue(0) // {key: 'HELLO_MESSAGE', value: 0, displayName: 'Hello JavaScripters!'}
const val2 = myEnum.getValue('HELLO_MESSAGE') // 0
const displayName2 = myEnum.getDisplayName('HELLO_MESSAGE') // 'Hello JavaScripters!'
 
//Using an array of strings
const myOtherEnum = new E(['HELLO_JAVASCRIPTERS'])
 
//Start case conversion
const myFormattedDisplayName = myOtherEnum.HELLO_JAVASCRIPTERS.displayName // 'Hello Javascripters'
const indexValue = myOtherEnum.HELLO_JAVASCRIPTERS.value // 0 (index)

License

MIT © 2016

Package Sidebar

Install

npm i hs-enum

Weekly Downloads

0

Version

0.1.2

License

MIT

Last publish

Collaborators

  • cristian.berrios