Socket
Socket
Sign inDemoInstall

camelcase

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.0.0 to 7.0.1

8

index.js

@@ -11,9 +11,11 @@ const UPPERCASE = /[\p{Lu}]/u;

const preserveCamelCase = (string, toLowerCase, toUpperCase) => {
const preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUppercase) => {
let isLastCharLower = false;
let isLastCharUpper = false;
let isLastLastCharUpper = false;
let isLastLastCharPreserved = false;
for (let index = 0; index < string.length; index++) {
const character = string[index];
isLastLastCharPreserved = index > 2 ? string[index - 3] === '-' : true;

@@ -26,3 +28,3 @@ if (isLastCharLower && UPPERCASE.test(character)) {

index++;
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character)) {
} else if (isLastCharUpper && isLastLastCharUpper && LOWERCASE.test(character) && (!isLastLastCharPreserved || preserveConsecutiveUppercase)) {
string = string.slice(0, index - 1) + '-' + string.slice(index - 1);

@@ -98,3 +100,3 @@ isLastLastCharUpper = isLastCharUpper;

if (hasUpperCase) {
input = preserveCamelCase(input, toLowerCase, toUpperCase);
input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
}

@@ -101,0 +103,0 @@

{
"name": "camelcase",
"version": "7.0.0",
"version": "7.0.1",
"description": "Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: `foo-bar` → `fooBar`",

@@ -5,0 +5,0 @@ "license": "MIT",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc