Installations
npm install camelcase-keys
Score
99
Supply Chain
99.5
Quality
76.9
Maintenance
100
Vulnerability
99.6
License
Developer
sindresorhus
Developer Guide
Module System
ESM
Min. Node Version
>=16
Typescript Support
Yes
Node Version
21.5.0
NPM Version
9.2.0
Statistics
691 Stars
95 Commits
95 Forks
9 Watching
1 Branches
23 Contributors
Updated on 04 Nov 2024
Bundle Size
6.28 kB
Minified
2.33 kB
Minified + Gzipped
Languages
TypeScript (63.32%)
JavaScript (36.68%)
Total Downloads
Cumulative downloads
Total Downloads
4,495,533,247
Last day
-2.3%
3,628,742
Compared to previous day
Last week
4.3%
19,670,050
Compared to previous week
Last month
23.8%
76,720,642
Compared to previous month
Last year
-9.4%
804,530,952
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
camelcase-keys
Convert object keys to camel case using
camelcase
Install
1npm install camelcase-keys
Usage
1import camelcaseKeys from 'camelcase-keys'; 2 3// Convert an object 4camelcaseKeys({'foo-bar': true}); 5//=> {fooBar: true} 6 7// Convert an array of objects 8camelcaseKeys([{'foo-bar': true}, {'bar-foo': false}]); 9//=> [{fooBar: true}, {barFoo: false}]
1import {parseArgs} from 'node:util'; 2import camelcaseKeys from 'camelcase-keys'; 3 4const commandLineArguments = parseArgs(); 5//=> {_: [], 'foo-bar': true} 6 7camelcaseKeys(commandLineArguments); 8//=> {_: [], fooBar: true}
API
camelcaseKeys(input, options?)
input
Type: Record<string, unknown> | ReadonlyArray<Record<string, unknown>>
A plain object or array of plain objects to camel-case.
options
Type: object
exclude
Type: Array<string | RegExp>
Default: []
Exclude keys from being camel-cased.
deep
Type: boolean
Default: false
Recurse nested objects and objects in arrays.
1import camelcaseKeys from 'camelcase-keys'; 2 3const object = { 4 'foo-bar': true, 5 nested: { 6 unicorn_rainbow: true 7 } 8}; 9 10camelcaseKeys(object, {deep: true}); 11//=> {fooBar: true, nested: {unicornRainbow: true}} 12 13camelcaseKeys(object, {deep: false}); 14//=> {fooBar: true, nested: {unicorn_rainbow: true}}
pascalCase
Type: boolean
Default: false
Uppercase the first character: bye-bye
→ ByeBye
1import camelcaseKeys from 'camelcase-keys'; 2 3camelcaseKeys({'foo-bar': true}, {pascalCase: true}); 4//=> {FooBar: true} 5 6camelcaseKeys({'foo-bar': true}, {pascalCase: false}); 7//=> {fooBar: true}
preserveConsecutiveUppercase
Type: boolean
Default: false
Preserve consecutive uppercase characters: foo-BAR
→ FooBAR
1import camelcaseKeys from 'camelcase-keys'; 2 3camelcaseKeys({'foo-BAR': true}, {preserveConsecutiveUppercase: true}); 4//=> {fooBAR: true} 5 6camelcaseKeys({'foo-BAR': true}, {preserveConsecutiveUppercase: false}); 7//=> {fooBar: true}
stopPaths
Type: string[]
Default: []
Exclude children at the given object paths in dot-notation from being camel-cased.
For example, with an object like {a: {b: '🦄'}}
, the object path to reach the unicorn is 'a.b'
.
1import camelcaseKeys from 'camelcase-keys'; 2 3const object = { 4 a_b: 1, 5 a_c: { 6 c_d: 1, 7 c_e: { 8 e_f: 1 9 } 10 } 11}; 12 13camelcaseKeys(object, { 14 deep: true, 15 stopPaths: [ 16 'a_c.c_e' 17 ] 18}), 19/* 20{ 21 aB: 1, 22 aC: { 23 cD: 1, 24 cE: { 25 e_f: 1 26 } 27 } 28} 29*/
Related
- decamelize-keys - The inverse of this package
- snakecase-keys
- kebabcase-keys
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: .github/security.md:1
- Info: Found linked content: .github/security.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: .github/security.md:1
- Info: Found text in security policy: .github/security.md:1
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
Found 12/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/camelcase-keys/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/camelcase-keys/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:22
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 12 are checked with a SAST tool
Score
4.4
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to camelcase-keys
@types/camelcase-keys-deep
TypeScript definitions for camelcase-keys-deep
camelcase-keys-recursive
Adaptation of camelcase-keys but recursive.
@rockyj/camelcase-keys
Largely forked from https://github.com/sindresorhus/camelcase-keys (Thank you!).
camelcase-keys-deep
Deeply convert the keys of an object to camelCase