enum2human
v0.1.5
Published
Convert java ENUM_STYLE strings to "Human readable" strings.
Downloads
2
Readme
enum2human
Simple Node.js/Javascript library to convert JAVA_STYLE enumerated codes to Human readable format. It just takes the string and:
- Lowercases all characters but first
- Replaces underscores with spaces
- Restores apostrophes before S
Needless to say this will mess with your data, so never use this library for anything other than display purposes.
Installation
npm install enum2human
Usage
var e2h = require("enum2human");
var title = e2h("HOLY_COW_DO_UPPERCASE_CHARACTERS_RULE");
enum2human also provides method to recursively humanize entire objects:
var humanObject = e2h.object(inhumanObject);
You can specify which fields to ignore in object conversion:
e2h.ignoreField("securityCode")
var humanObject = e2h.object(inhumanObject);
You can specify which fields to ignore in object conversion:
e2h.ignoreField("securityCode")
var humanObject = e2h.object(inhumanObject);
You can provide manual translation to some strings:
e2h.translate("HIGH_BA", "Bachelor's degree");
var humanObject = e2h.object(inhumanObject);
This will return object where all the strings with only uppercase characters, numbers and underscores are humanized, but rest of the content just copied.