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

string-ts

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-ts - npm Package Compare versions

Comparing version 1.3.3 to 2.0.0

27

dist/index.d.ts

@@ -345,3 +345,3 @@ /**

*/
type Reverse<T extends string> = T extends `${infer Head}${infer Tail}` ? `${Reverse<Tail>}${Head}` : T;
type Reverse<T extends string, _acc extends string = ''> = T extends `${infer Head}${infer Tail}` ? Reverse<Tail, `${Head}${_acc}`> : _acc extends '' ? T : _acc;
/**

@@ -353,3 +353,3 @@ * A strongly-typed function to reverse a string.

*/
declare function reverse<T extends string>(str: T): Reverse<T>;
declare function reverse<T extends string>(str: T): Reverse<T, "">;

@@ -401,7 +401,14 @@ /**

type Apostrophe = "'";
/**
* Checks if the given character is an apostrophe
*/
type IsApostrophe<T extends string> = IsStringLiteral<T> extends true ? T extends Apostrophe ? true : false : boolean;
type RemoveApostrophe<T extends string> = ReplaceAll<T, "'", ''>;
/**
* Checks if the given character is a special character.
* E.g. not a letter, number, or separator.
*/
type IsSpecial<T extends string> = IsStringLiteral<T> extends true ? IsLetter<T> extends true ? false : IsDigit<T> extends true ? false : IsSeparator<T> extends true ? false : true : boolean;
type IsSpecial<T extends string> = IsStringLiteral<T> extends true ? IsLetter<T> extends true ? false : IsDigit<T> extends true ? false : IsSeparator<T> extends true ? false : IsApostrophe<T> extends true ? false : true : boolean;

@@ -434,3 +441,3 @@ /**

/**
* A strongly typed function to extract the words from a sentence.
* A strongly-typed function to extract the words from a sentence.
* @param sentence the sentence to extract the words from.

@@ -445,3 +452,3 @@ * @returns an array of words in both type level and runtime.

*/
type PascalCase<T extends string> = Join<PascalCaseAll<Words<T>>>;
type PascalCase<T extends string> = Join<PascalCaseAll<Words<RemoveApostrophe<T>>>>;
/**

@@ -464,3 +471,3 @@ * A strongly typed version of `pascalCase` that works in both runtime and type level.

*/
type CamelCase<T extends string> = Uncapitalize<PascalCase<T>>;
type CamelCase<T extends string> = Uncapitalize<PascalCase<RemoveApostrophe<T>>>;
/**

@@ -483,3 +490,3 @@ * A strongly typed version of `camelCase` that works in both runtime and type level.

*/
type DelimiterCase<T extends string, D extends string> = Join<Words<T>, D>;
type DelimiterCase<T extends string, D extends string> = Join<Words<RemoveApostrophe<T>>, D>;
/**

@@ -503,3 +510,3 @@ * A function that transforms a string by splitting it into words and joining them with the specified delimiter.

*/
type ConstantCase<T extends string> = Uppercase<DelimiterCase<T, '_'>>;
type ConstantCase<T extends string> = Uppercase<DelimiterCase<RemoveApostrophe<T>, '_'>>;
/**

@@ -522,3 +529,3 @@ * A strongly typed version of `constantCase` that works in both runtime and type level.

*/
type KebabCase<T extends string> = Lowercase<DelimiterCase<T, '-'>>;
type KebabCase<T extends string> = Lowercase<DelimiterCase<RemoveApostrophe<T>, '-'>>;
/**

@@ -541,3 +548,3 @@ * A strongly typed version of `kebabCase` that works in both runtime and type level.

*/
type SnakeCase<T extends string> = Lowercase<DelimiterCase<T, '_'>>;
type SnakeCase<T extends string> = Lowercase<DelimiterCase<RemoveApostrophe<T>, '_'>>;
/**

@@ -544,0 +551,0 @@ * A strongly typed version of `snakeCase` that works in both runtime and type level.

@@ -143,3 +143,3 @@ 'use strict';

function words(sentence) {
return sentence.replace(SEPARATOR_REGEX, " ").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").replace(/([a-zA-Z0-9_\-./])([^a-zA-Z0-9_\-./])/g, "$1 $2").replace(/([^a-zA-Z0-9_\-./])([a-zA-Z0-9_\-./])/g, "$1 $2").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").trim().split(/\s+/g);
return sentence.replace(SEPARATOR_REGEX, " ").replace(/([a-zA-Z])([0-9])/g, "$1 $2").replace(/([0-9])([a-zA-Z])/g, "$1 $2").replace(/([a-zA-Z0-9_\-./])([^a-zA-Z0-9_\-./'])/g, "$1 $2").replace(/([^a-zA-Z0-9_\-./'])([a-zA-Z0-9_\-./])/g, "$1 $2").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/([A-Z])([A-Z][a-z])/g, "$1 $2").trim().split(/\s+/g);
}

@@ -160,5 +160,10 @@

// src/utils/characters/apostrophe.ts
function removeApostrophe(str) {
return replaceAll(str, "'", "");
}
// src/utils/word-case/pascal-case.ts
function pascalCase(str) {
return join(pascalCaseAll(words(str)));
return join(pascalCaseAll(words(removeApostrophe(str))));
}

@@ -174,3 +179,3 @@ var toPascalCase = pascalCase;

function camelCase(str) {
return uncapitalize(pascalCase(str));
return uncapitalize(pascalCase(removeApostrophe(str)));
}

@@ -181,3 +186,3 @@ var toCamelCase = camelCase;

function delimiterCase(str, delimiter) {
return join(words(str), delimiter);
return join(words(removeApostrophe(str)), delimiter);
}

@@ -188,3 +193,3 @@ var toDelimiterCase = delimiterCase;

function constantCase(str) {
return toUpperCase(delimiterCase(str, "_"));
return toUpperCase(delimiterCase(removeApostrophe(str), "_"));
}

@@ -195,3 +200,3 @@ var toConstantCase = constantCase;

function kebabCase(str) {
return toLowerCase(delimiterCase(str, "-"));
return toLowerCase(delimiterCase(removeApostrophe(str), "-"));
}

@@ -202,3 +207,3 @@ var toKebabCase = kebabCase;

function snakeCase(str) {
return toLowerCase(delimiterCase(str, "_"));
return toLowerCase(delimiterCase(removeApostrophe(str), "_"));
}

@@ -205,0 +210,0 @@ var toSnakeCase = snakeCase;

{
"name": "string-ts",
"version": "1.3.3",
"version": "2.0.0",
"description": "Strongly-typed string functions.",

@@ -20,3 +20,3 @@ "main": "./dist/index.js",

"@typescript-eslint/eslint-plugin": "latest",
"@vitest/coverage-v8": "^0.34.6",
"@vitest/coverage-v8": "^1.0.2",
"eslint": "latest",

@@ -23,0 +23,0 @@ "prettier": "latest",

@@ -952,2 +952,3 @@ <p align="center">

<td align="center" valign="top" width="14.28%"><a href="https://github.com/mjuksel"><img src="https://avatars.githubusercontent.com/u/10691584?v=4?s=100" width="100px;" alt="Mjuksel"/><br /><sub><b>Mjuksel</b></sub></a><br /><a href="https://github.com/gustavoguichard/string-ts/commits?author=mjuksel" title="Code">💻</a> <a href="#ideas-mjuksel" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://huguesverlin.fr"><img src="https://avatars.githubusercontent.com/u/9151470?v=4?s=100" width="100px;" alt="hverlin"/><br /><sub><b>hverlin</b></sub></a><br /><a href="https://github.com/gustavoguichard/string-ts/commits?author=hverlin" title="Code">💻</a></td>
</tr>

@@ -954,0 +955,0 @@ </tbody>

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