Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@b613/utils

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@b613/utils - npm Package Compare versions

Comparing version 1.0.0-beta17 to 1.0.0-beta18

2

lib/string.d.ts
export function trimlines(str: string, separator?: string): string;
export function toKebabCase(str: string): string;
export function toKebabCase(str: string, escapedChars?: string[]): string;
export function unCamelCase(str: string, separator?: string): string;

@@ -27,19 +27,28 @@ "use strict";

exports.trimlines = trimlines;
function toKebabCase(str) {
// eslint-disable-next-line radar/cognitive-complexity
function toKebabCase(str, escapedChars = []) {
const tokens = [];
for (let index = 0; index < str.length; index++) {
const char = str.charAt(index);
const code = str.charCodeAt(index);
if (code >= CHAR_CODE_A && code <= CHAR_CODE_Z) {
if (index && tokens.at(-1) !== '-') {
tokens.push('-');
}
tokens.push(String.fromCharCode(code + 32));
// eslint-disable-next-line camelcase
}
else if ((code >= CHAR_CODE_a && code <= CHAR_CODE_z) || (code >= CHAR_CODE_0 && code <= CHAR_CODE_9)) {
if (escapedChars.includes(char)) {
tokens.push(char);
}
else {
tokens.push('-');
const code = str.charCodeAt(index);
if (code >= CHAR_CODE_A && code <= CHAR_CODE_Z) {
if (index) {
const previousToken = tokens[index - 1];
if (previousToken !== '-' && !escapedChars.includes(previousToken)) {
tokens.push('-');
}
}
tokens.push(String.fromCharCode(code + 32));
// eslint-disable-next-line camelcase
}
else if ((code >= CHAR_CODE_a && code <= CHAR_CODE_z) || (code >= CHAR_CODE_0 && code <= CHAR_CODE_9)) {
tokens.push(char);
}
else {
tokens.push('-');
}
}

@@ -46,0 +55,0 @@ }

@@ -5,3 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const color_1 = tslib_1.__importDefault(require("../color"));
const color_node_1 = tslib_1.__importDefault(require("../color/color.node"));
class Trace {

@@ -19,6 +19,6 @@ constructor(name) {

warn(msg, prefix = 'WARN') {
process.stderr.write(this.parse(color_1.default.yellow(prefix), msg));
process.stderr.write(this.parse(color_node_1.default.yellow(prefix), msg));
}
error(msg, prefix = 'ERROR') {
process.stderr.write(this.parse(color_1.default.red(prefix), msg));
process.stderr.write(this.parse(color_node_1.default.red(prefix), msg));
}

@@ -25,0 +25,0 @@ }

{
"name": "@b613/utils",
"version": "1.0.0-beta17",
"version": "1.0.0-beta18",
"description": "Set of utility methods for common operations",

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

"@types/express": "^4.17.13",
"@types/jest": "^27.4.0",
"@types/jest": "^28.1.2",
"@types/morgan": "^1.9.3",
"@types/node": "^17.0.30",
"@types/node": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^5.21.0",

@@ -60,5 +60,5 @@ "@typescript-eslint/parser": "^5.21.0",

"eslint-plugin-radar": "^0.2.1",
"jest": "^28.1.0",
"jest": "^28.1.1",
"nock": "^13.2.4",
"ts-jest": "28.0.3",
"ts-jest": "^28.0.5",
"typescript": "^4.6.4"

@@ -65,0 +65,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc