Last active
February 24, 2019 08:08
-
-
Save oriSomething/16a16d8ea12573307dc6 to your computer and use it in GitHub Desktop.
build enums with lodash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import _ from 'lodash'; | |
export function enumNumber(... params) { | |
return Object.freeze(_.mapValues(_.invert(params), Number)); | |
} | |
export function enumString(... params) { | |
return Object.freeze(_.mapKeys(params)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment