Socket
Socket
Sign inDemoInstall

scule

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.1 to 0.3.0

45

dist/index.js

@@ -11,26 +11,37 @@ 'use strict';

const parts = [];
if (!str || typeof str !== "string") {
return parts;
}
let buff = "";
let previusUpper = isUppercase(str[0]);
let previousSplitter = splitters.includes(str[0]);
let previusUpper = null;
let previousSplitter = null;
for (const char of str.split("")) {
const isSplitter = splitters.includes(char);
if (isSplitter) {
if (isSplitter === true) {
parts.push(buff);
buff = "";
previusUpper = false;
previousSplitter = true;
} else if (!previousSplitter && !previusUpper && isUppercase(char)) {
parts.push(buff);
buff = char;
previusUpper = true;
previousSplitter = false;
} else {
buff += char;
previusUpper = isUppercase(char);
previousSplitter = isSplitter;
previusUpper = null;
continue;
}
const isUpper = isUppercase(char);
if (previousSplitter === false) {
if (previusUpper === false && isUpper === true) {
parts.push(buff);
buff = char;
previusUpper = isUpper;
continue;
}
if (previusUpper === true && isUpper === false && buff.length > 1) {
const lastChar = buff[buff.length - 1];
parts.push(buff.substr(0, buff.length - 1));
buff = lastChar + char;
previusUpper = isUpper;
continue;
}
}
buff += char;
previusUpper = isUpper;
previousSplitter = isSplitter;
}
if (buff) {
parts.push(buff);
}
parts.push(buff);
return parts;

@@ -37,0 +48,0 @@ }

{
"name": "scule",
"version": "0.2.1",
"version": "0.3.0",
"description": "",

@@ -5,0 +5,0 @@ "repository": "nuxt-contrib/scule",

@@ -70,3 +70,3 @@ # 🧵 Scule

- Splits string by the splitters provided (default: `['-', '_', '/', '.]`)
- Splits when case changes from lower to upper (only rising edges)
- Splits when case changes from lower to upper or upper to lower
- Case is preserved in returned value

@@ -73,0 +73,0 @@ - Is an irreversible function since splitters are omitted

Sorry, the diff of this file is not supported yet

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