
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
format-object-keys
Advanced tools
Format keys in an object to be camelCase, PascalCase, or a custom format.
yarn add format-object-keys
// import function
const formatObjectKeys = require('format-object-keys')
// provide a data structure whose
// keys you want formatted
const dataStructure = {
FIRST_NAME: 'Kunal',
LAST_NAME: 'Mandalia',
LOCATION: 'London',
JOB_HISTORY: [
{
DATE_FROM: 'April 2016',
DATE_TO: 'Present',
TITLE: 'Js developer'
}
]
}
// define a function to format keys
// here we'll camelCase key given
// key has the structure <FIRSTWORD>_<SECONDWORD>...
const formatter = key => {
if (typeof key === 'string') {
return key.toLowerCase()
.split('_')
.map((word, i) => i > 0
? word[0].toUpperCase() + word.substr(1)
: word
)
.join('')
}
return key
}
const result = formatObjectKeys(dataStructure, formatter)
console.log(result)
// {
// firstName: 'Kunal',
// lastName: 'Mandalia',
// location: 'London',
// jobHistory: [
// {
// dateFrom: 'April 2016',
// dateTo: 'Present',
// title: 'Js developer'
// }
// ]
// }
No support for circular references yet. PRs welcome to support this feature.
MIT
FAQs
format javascript object keys e.g. to camelCase
We found that format-object-keys demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.