🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

string-ts

Package Overview
Dependencies
Maintainers
1
Versions
27
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

to
0.4.1

11

dist/index.d.ts

@@ -13,5 +13,8 @@ /**

/**
* Capitalizes all the words in a tuple of strings
* PascalCases all the words in a tuple of strings
*/
type CapitalizeAll<T extends string[]> = T extends [infer First, ...infer Rest] ? [Capitalize<Is<First, string>>, ...CapitalizeAll<Is<Rest, string[]>>] : T;
type PascalCaseAll<T extends string[]> = T extends [infer First, ...infer Rest] ? [
Capitalize<Lowercase<Is<First, string>>>,
...PascalCaseAll<Is<Rest, string[]>>
] : T;

@@ -204,3 +207,3 @@ type Digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';

*/
type CamelCase<T extends string> = Words<T> extends [infer first, ...infer rest] ? Join<[Lowercase<Is<first, string>>, ...CapitalizeAll<Is<rest, string[]>>]> : T;
type CamelCase<T extends string> = PascalCase<T> extends `${infer first}${infer rest}` ? `${Lowercase<first>}${rest}` : T;
/**

@@ -216,3 +219,3 @@ * A strongly typed version of `toCamelCase` that works in both runtime and type level.

*/
type PascalCase<T extends string> = Capitalize<CamelCase<T>>;
type PascalCase<T extends string> = Join<PascalCaseAll<Is<Words<T>, string[]>>>;
/**

@@ -219,0 +222,0 @@ * A strongly typed version of `toPascalCase` that works in both runtime and type level.

@@ -92,7 +92,7 @@ "use strict";

function toCamelCase(str) {
const result = words(str).map(capitalize).join("");
return result.slice(0, 1).toLowerCase() + result.slice(1);
const res = toPascalCase(str);
return res.slice(0, 1).toLowerCase() + res.slice(1);
}
function toPascalCase(str) {
return capitalize(toCamelCase(str));
return words(str).map((v) => capitalize(toLowerCase(v))).join("");
}

@@ -99,0 +99,0 @@ function toKebabCase(str) {

{
"name": "string-ts",
"version": "0.4.0",
"version": "0.4.1",
"description": "Strongly-typed string functions.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -1,2 +0,2 @@

# Strongly typed string functions for all!
# Strongly-typed string functions for all!

@@ -6,3 +6,3 @@ ## 😬 The problem

When you are working with literal strings, the string manipulation functions only work at the runtime level and the types don't follow those transformations.
You end up loosing type information and possibly having to cast the result.
You end up losing type information and possibly having to cast the result.

@@ -36,3 +36,3 @@ ```ts

- [capitalize](#capitalize)
- [Stronly-typed alternatives to native runtime utilities](#stronly-typed-alternatives-to-native-runtime-utilities)
- [Strongly-typed alternatives to native runtime utilities](#strongly-typed-alternatives-to-native-runtime-utilities)
- [toUpperCase](#touppercase)

@@ -46,3 +46,3 @@ - [toLowerCase](#tolowercase)

- [replaceAll](#replaceall)
- [Stronly-typed alternatives to common loosely-typed functions](#stronly-typed-alternatives-to-common-loosely-typed-functions)
- [Strongly-typed alternatives to common loosely-typed functions](#strongly-typed-alternatives-to-common-loosely-typed-functions)
- [words](#words)

@@ -56,3 +56,3 @@ - [toDelimiterCase](#todelimitercase)

- [toTitleCase](#totitlecase)
- [Strongly-typed deep trasnformation of objects](#strongly-typed-deep-trasnformation-of-objects)
- [Strongly-typed deep transformation of objects](#strongly-typed-deep-transformation-of-objects)
- [deepDelimiterKeys](#deepdelimiterkeys)

@@ -87,3 +87,3 @@ - [deepCamelKeys](#deepcamelkeys)

## Stronly-typed alternatives to native runtime utilities
## Strongly-typed alternatives to native runtime utilities
### toUpperCase

@@ -177,3 +177,3 @@ This function is a strongly-typed counterpart of `String.prototype.toUpperCase`.

## Stronly-typed alternatives to common loosely-typed functions
## Strongly-typed alternatives to common loosely-typed functions

@@ -268,3 +268,3 @@ ### words

## Strongly-typed deep trasnformation of objects
## Strongly-typed deep transformation of objects

@@ -362,3 +362,3 @@ ### deepDelimiterKeys

## Type Utilities
All the functions presented in this API have their type counterparts.
All the functions presented in this API have associated type counterparts.

@@ -437,3 +437,3 @@ ```ts

### deepTransformKeys
This function recursively converts the keys of an object to a custom format but only at runtime level.
This function recursively converts the keys of an object to a custom format, but only at runtime level.

@@ -440,0 +440,0 @@ ```ts

Sorry, the diff of this file is not supported yet