key-enum

Simple Enum library in Javascript, Supporting Flux for enumerating Action-Types

key-enum

Simple Enum library in Javascript, Supporting Flux for enumerating Action-Types

Installation

$ npm install key-enum

Example 1

var keyEnum = require('key-enum')
var obj = keyEnum({
  a: null,
  b: null,
  d: 4, // default
  e: 0, // default
  f: null,
  g: null
})

console.log(obj) // '{a:1, b:2, d:4, e:0, f:3, g:5}'

Example 2

var keyEnum = require('key-enum')
var obj = keyEnum({
  a: null,
  b: null,
  c: {
    d: null,
    e: {
      f: null, g: null
    },
    h: {
      i: null, j: null
    }
  }
})

console.log(obj) // '{a:0,b:1,c:{d:2,e:{f:3,g:4},h:{i:5,j:6}}}'

MIT Licensed

Copyright (c) 2016 Edwin Guzman

HomePage

https://github.com/vudduu/key-enum#readme

Repository

git+https://github.com/vudduu/key-enum.git


公众号

欢迎 JavaScript 爱好者