
Security Fundamentals
Turtles, Clams, and Cyber Threat Actors: Shell Usage
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
lodash-humps
Advanced tools
Converting object keys to camelCase. Works on deeply nested objects/arrays. Handy for converting underscore keys to camelCase. Using lodash keeps the code small and light at around 10 lines.
$ npm i --save lodash-humps
Remove any hyphens, underscores, whitespace characters, and uppercases the first character that follows. Returns a new object. See _.camelCase()
https://lodash.com/docs#camelCase and https://en.wikipedia.org/wiki/CamelCase.
import humps from 'lodash-humps'
const object = { attr_one: 'foo', attr_two: 'bar', attr_three: { attr_one: 'foo' } }
humps(object) // { attrOne: 'foo', attrTwo: 'bar', attrThree: { attrOne: 'foo' } }
Arrays of objects are also converted:
const array = [{ attr_one: 'foo' }, { attr_one: 'bar' }]
humps(array) // [{ attrOne: 'foo' }, { attrOne: 'bar' }]
What if you want to convert it back?!? See test/createHumps.spec.js for an example. Open an issue if you want a proper export.
import createHumps from 'humps/lib/createHumps'
import { snakeCase } from 'lodash'
const snakes = createHumps(snakeCase)
const object = { attrOne: 'foo', attrTwo: 'bar', attrThree: { attrOne: 'foo' } }
snakes(object) // { attr_one: 'foo', attr_two: 'bar', attr_three: { attr_one: 'foo' } }
NOTE: Version 3.x will only work with objects created by the Object constructor. You may need to do something like const result = humps({ ...SomeOtherClass })
to get humps to process your stuff. Function properties are now kept and not converted to {}
. Some might say this is a bug and others might call it a feature. Full version bump so you can have your pick.
Internally switched from using _.isObject
to _.isPlainObject
before converting the keys and children objects.
[3.1.6]
2021-03-02
Update packages.
FAQs
Recursive camelCase of object keys and arrays of objects
The npm package lodash-humps receives a total of 3,359 weekly downloads. As such, lodash-humps popularity was classified as popular.
We found that lodash-humps 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 Fundamentals
The Socket Threat Research Team uncovers how threat actors weaponize shell techniques across npm, PyPI, and Go ecosystems to maintain persistence and exfiltrate data.
Security News
At VulnCon 2025, NIST scrapped its NVD consortium plans, admitted it can't keep up with CVEs, and outlined automation efforts amid a mounting backlog.
Product
We redesigned our GitHub PR comments to deliver clear, actionable security insights without adding noise to your workflow.