Package Exports
- humanize-key
- humanize-key/dist/humanizeKey.js
- humanize-key/dist/humanizeKey.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (humanize-key) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Format string keys for display
Installation
npm install humanize-key
Usage
import humanizeKey from 'humanize-key'
// or
const { humanizeKey } = require('humanize-key')
const displayString = humanizeKey(key)const display = (obj) => {
forEach(obj, (value, key) => console.log(`${humanizeKey(key)}: ${value}`))
}display({
id: 12,
userName: 'bobby',
'first-name': 'Bob',
last_name: 'Roberts',
account_id: 321,
})ID: 12
User Name: bobby
First Name: Bob
Last Name: Roberts
Account ID: 321currently there are two exemptions to the default capitalization
id->IDrather thanIdids->IDsrather thanIds
other custom values can be set by use of makeHumanizeKey
Custom values
domains-specific acronyms
import { makeHumanizeKey } from 'humanize-key'
const humanizeKey = makeHumanizeKey({ acronyms: ['IRS', 'SSN'] })const obj = {
id: 12,
ssn_last_four: '1234',
'irs-account-number': '5678',
}ID: 12
SSN Last Four: 1234
IRS Account Number: 5678custom capitalization for terms of art
import { makeHumanizeKey } from 'humanize-key'
const humanizeKey = makeHumanizeKey({
acronyms: ['URL']
uniques: {
oauth: "OAuth",
uuids: "UUIDs",
}
})display({
oauth_url: 'http://localhost:3000/oauth/callback',
recent_uuids: [],
})OAuth URL: http://localhost:3000/oauth/callback
Recent UUIDs: []