Skip to content

Commit

Permalink
Require Node.js 16
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 9, 2023
1 parent e7dccc9 commit 3d497a1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
node-version:
- 18
- 16
- 14
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Convert a dash/dot/underscore/space separated string to camelCase or PascalCase:
Correctly handles Unicode strings.
@param input - String to convert to camel case.
@param input - The string to convert to camel case.
@example
```
Expand All @@ -72,7 +72,7 @@ camelCase('--foo.bar', {pascalCase: false});
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
//=> 'fooBAR'
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true});
//=> 'FooBAR'
camelCase('foo bar');
Expand Down
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutive
const preserveConsecutiveUppercase = (input, toLowerCase) => {
LEADING_CAPITAL.lastIndex = 0;

return input.replace(LEADING_CAPITAL, m1 => toLowerCase(m1));
return input.replaceAll(LEADING_CAPITAL, match => toLowerCase(match));
};

const postProcess = (input, toUpperCase) => {
SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
NUMBERS_AND_IDENTIFIER.lastIndex = 0;

return input.replace(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))
.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));
return input
.replaceAll(NUMBERS_AND_IDENTIFIER, (match, pattern, offset) => ['_', '-'].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match))
.replaceAll(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier));
};

export default function camelCase(input, options) {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"exports": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=14.16"
"node": ">=16"
},
"scripts": {
"test": "xo && ava && tsd"
Expand All @@ -40,8 +40,8 @@
"pascal-case"
],
"devDependencies": {
"ava": "^4.3.0",
"tsd": "^0.20.0",
"xo": "^0.54.2"
"ava": "^5.3.1",
"tsd": "^0.28.1",
"xo": "^0.55.1"
}
}
11 changes: 2 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ camelCase('--foo.bar', {pascalCase: false});
camelCase('Foo-BAR', {preserveConsecutiveUppercase: true});
//=> 'fooBAR'

camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true}));
camelCase('fooBAR', {pascalCase: true, preserveConsecutiveUppercase: true});
//=> 'FooBAR'

camelCase('foo bar');
Expand Down Expand Up @@ -70,7 +70,7 @@ camelCase('lorem-ipsum', {locale: 'en-US'});

Type: `string | string[]`

String to convert to camel case.
The string to convert to camel case.

#### options

Expand Down Expand Up @@ -127,16 +127,9 @@ camelCase('lorem-ipsum', {locale: false});
//=> 'loremIpsum'
```

## camelcase for enterprise

Available as part of the Tidelift Subscription.

The maintainers of camelcase and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-camelcase?utm_source=npm-camelcase&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

## Related

- [decamelize](https://github.com/sindresorhus/decamelize) - The inverse of this module
- [uppercamelcase](https://github.com/SamVerschueren/uppercamelcase) - Like this module, but to PascalCase instead of camelCase
- [titleize](https://github.com/sindresorhus/titleize) - Capitalize every word in string
- [humanize-string](https://github.com/sindresorhus/humanize-string) - Convert a camelized/dasherized/underscored string into a humanized one
- [camelcase-keys](https://github.com/sindresorhus/camelcase-keys) - Convert object keys to camel case

0 comments on commit 3d497a1

Please sign in to comment.