0.0.2 • Published 6 months ago
humanize-key v0.0.2
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: 321
currently there are two exemptions to the default capitalization
id
->ID
rather thanId
ids
->IDs
rather 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: 5678
custom 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: []
0.0.2
6 months ago
0.3.0
1 year ago
0.2.5
1 year ago
0.0.20
2 years ago
0.0.21
2 years ago
0.0.10
2 years ago
0.0.11
2 years ago
0.0.13
2 years ago
0.0.14
2 years ago
0.0.9
2 years ago
0.0.17
2 years ago
0.0.18
2 years ago
0.0.19
2 years ago
0.0.2-development
2 years ago
0.0.1-development
2 years ago
0.0.0-development
2 years ago