Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar
Installations
npm install camelcase
Score
99.5
Supply Chain
99.5
Quality
76
Maintenance
100
Vulnerability
100
License
Developer
sindresorhus
Developer Guide
Module System
ESM
Min. Node Version
>=16
Typescript Support
Yes
Node Version
16.20.0
NPM Version
9.2.0
Statistics
683 Stars
100 Commits
94 Forks
14 Watching
1 Branches
28 Contributors
Updated on 21 Nov 2024
Bundle Size
1.52 kB
Minified
801.00 B
Minified + Gzipped
Languages
JavaScript (96.5%)
TypeScript (3.5%)
Total Downloads
Cumulative downloads
Total Downloads
19,353,154,403
Last day
-8.4%
16,827,277
Compared to previous day
Last week
0.7%
98,973,713
Compared to previous week
Last month
14%
407,136,942
Compared to previous month
Last year
3.1%
4,203,415,333
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
camelcase
Convert a dash/dot/underscore/space separated string to camelCase or PascalCase:
foo-bar
→fooBar
Correctly handles Unicode strings.
If you use this on untrusted user input, don't forget to limit the length to something reasonable.
Install
1npm install camelcase
Usage
1import camelCase from 'camelcase'; 2 3camelCase('foo-bar'); 4//=> 'fooBar' 5 6camelCase('foo_bar'); 7//=> 'fooBar' 8 9camelCase('Foo-Bar'); 10//=> 'fooBar' 11 12camelCase('розовый_пушистый_единорог'); 13//=> 'розовыйПушистыйЕдинорог' 14 15camelCase('foo bar'); 16//=> 'fooBar' 17 18console.log(process.argv[3]); 19//=> '--foo-bar' 20camelCase(process.argv[3]); 21//=> 'fooBar' 22 23camelCase(['foo', 'bar']); 24//=> 'fooBar' 25 26camelCase(['__foo__', '--bar']); 27//=> 'fooBar'
API
camelCase(input, options?)
input
Type: string | string[]
The string to convert to camel case.
options
Type: object
pascalCase
Type: boolean
Default: false
Uppercase the first character: foo-bar
→ FooBar
1import camelCase from 'camelcase';
2
3camelCase('foo-bar', {pascalCase: true});
4//=> 'FooBar'
5
6camelCase('foo-bar', {pascalCase: false});
7//=> 'fooBar'
preserveConsecutiveUppercase
Type: boolean
Default: false
Preserve consecutive uppercase characters: foo-BAR
→ FooBAR
1import camelCase from 'camelcase'; 2 3camelCase('foo-BAR', {preserveConsecutiveUppercase: true}); 4//=> 'fooBAR' 5 6camelCase('foo-BAR', {preserveConsecutiveUppercase: false}); 7//=> 'fooBar'
locale
Type: false | string | string[]
Default: The host environment’s current locale.
The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.
1import camelCase from 'camelcase'; 2 3camelCase('lorem-ipsum', {locale: 'en-US'}); 4//=> 'loremIpsum' 5 6camelCase('lorem-ipsum', {locale: 'tr-TR'}); 7//=> 'loremİpsum' 8 9camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']}); 10//=> 'loremIpsum' 11 12camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']}); 13//=> 'loremİpsum'
Setting locale: false
ignores the platform locale and uses the Unicode Default Case Conversion algorithm:
1import camelCase from 'camelcase'; 2 3// On a platform with `tr-TR`. 4 5camelCase('lorem-ipsum'); 6//=> 'loremİpsum' 7 8camelCase('lorem-ipsum', {locale: false}); 9//=> 'loremIpsum'
Related
- decamelize - The inverse of this module
- titleize - Capitalize every word in string
- humanize-string - Convert a camelized/dasherized/underscored string into a humanized one
- camelcase-keys - Convert object keys to camel case
No vulnerabilities found.
Reason
no binaries found in the repo
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
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 14/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 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:16: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/camelcase/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/sindresorhus/camelcase/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:21
- 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 14 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
lodash.camelcase
The lodash method `_.camelCase` exported as a module.
pascalcase
Convert a string to pascal case (upper camelcase).
@types/camelcase-css
TypeScript definitions for camelcase-css
change-case
Transform a string between `camelCase`, `PascalCase`, `Capital Case`, `snake_case`, `kebab-case`, `CONSTANT_CASE` and others