diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d50ada6..6a82b18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,7 +12,6 @@ jobs: node-version: - 18 - 16 - - 14 steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 diff --git a/index.d.ts b/index.d.ts index 9d519ec..5dd440c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 ``` @@ -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'); diff --git a/index.js b/index.js index 2be1bd1..e40f157 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/package.json b/package.json index 094ee13..2eb8e39 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "exports": "./index.js", "types": "./index.d.ts", "engines": { - "node": ">=14.16" + "node": ">=16" }, "scripts": { "test": "xo && ava && tsd" @@ -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" } } diff --git a/readme.md b/readme.md index ef8ef97..c634da2 100644 --- a/readme.md +++ b/readme.md @@ -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'); @@ -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 @@ -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