nhb-toolbox 4.30.24 → 4.30.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
All notable changes to the package will be documented here.
|
|
6
6
|
|
|
7
|
+
## [4.30.26] - 2026-06-09
|
|
8
|
+
|
|
9
|
+
- **Fixed** issues with *delimiter normalizer* and *updated return types* for *non-literal strings* in *string case converter* utilities.
|
|
10
|
+
|
|
7
11
|
## [4.30.20-24] - 2026-05-26
|
|
8
12
|
|
|
9
13
|
- **Updated** `isValidUTCOffset`: Strict matching of offset format `+HH:MM` or `-HH:MM` (00-14h, 00/15/30/45m).
|
package/dist/cjs/string/case.js
CHANGED
|
@@ -70,11 +70,11 @@ function convertStringCase(value, format, options) {
|
|
|
70
70
|
return start.concat(body, end);
|
|
71
71
|
}
|
|
72
72
|
case 'snake_case': {
|
|
73
|
-
const body = tokens.map(
|
|
73
|
+
const body = tokens.map(lowerCase).join('_');
|
|
74
74
|
return start.concat(body, end);
|
|
75
75
|
}
|
|
76
76
|
case 'kebab-case': {
|
|
77
|
-
const body = tokens.map(
|
|
77
|
+
const body = tokens.map(lowerCase).join('-');
|
|
78
78
|
return start.concat(body, end);
|
|
79
79
|
}
|
|
80
80
|
case 'Title Case': {
|
|
@@ -169,7 +169,7 @@ function _getDelimiterRegex(delims) {
|
|
|
169
169
|
function _normalizeDelimiters(str, delims) {
|
|
170
170
|
const delRegExp = _getDelimiterRegex(delims);
|
|
171
171
|
return str
|
|
172
|
-
.replace(/(\p{Ll}?\d+|(?<=\p{Lu}))(\p{Lu})/gu, '$1 $2')
|
|
172
|
+
.replace(/(\p{Ll}?\d+|(?<=\p{Lu}|\p{Ll}))(\p{Lu})/gu, '$1 $2')
|
|
173
173
|
.replace(delRegExp, ' ')
|
|
174
174
|
.replace(/\s+/g, ' ')
|
|
175
175
|
.trim()
|
|
@@ -72,7 +72,7 @@ export declare function isIPAddress(value: unknown): value is string;
|
|
|
72
72
|
/**
|
|
73
73
|
* * Type guard to check if the current environment matches a given string.
|
|
74
74
|
* @param env - The expected environment (e.g., "production", "development").
|
|
75
|
-
* @returns `true` if the value
|
|
75
|
+
* @returns `true` if the value equals to `process.env.NODE_ENV`, otherwise `false`.
|
|
76
76
|
*/
|
|
77
77
|
export declare function isEnvironment(env: string): boolean;
|
|
78
78
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CamelCase, CapitalizeOptions, CaseFormat, ConstantCase, DotCase, KebabCase, PascalCase, PascalSnakeCase, PathCase, SentenceCase, SnakeCase, StringCaseOptions, TitleCase, TrainCase } from './types';
|
|
1
|
+
import type { $WidenEmpty, CamelCase, CapitalizeOptions, CaseFormat, ConstantCase, DotCase, KebabCase, PascalCase, PascalSnakeCase, PathCase, SentenceCase, SnakeCase, StringCaseOptions, TitleCase, TrainCase } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* * Converts a string to a specified case format with advanced handling for word boundaries, punctuation, acronyms, and Unicode characters.
|
|
4
4
|
*
|
|
@@ -83,7 +83,7 @@ export declare function convertStringCase(value: string, format: CaseFormat, opt
|
|
|
83
83
|
*
|
|
84
84
|
* @param string String to be capitalized.
|
|
85
85
|
* @param options Options to customize the capitalization.
|
|
86
|
-
* @returns Capitalized string or fully
|
|
86
|
+
* @returns Capitalized string or fully upper-cased string depending on `capitalizeAll` option.
|
|
87
87
|
*/
|
|
88
88
|
export declare function capitalizeString(string: string, options?: CapitalizeOptions): string;
|
|
89
89
|
/**
|
|
@@ -106,7 +106,7 @@ export declare function capitalizeString(string: string, options?: CapitalizeOpt
|
|
|
106
106
|
* @param del Additional delimiter characters to recognize.
|
|
107
107
|
* @returns The `camelCase` formatted string.
|
|
108
108
|
*/
|
|
109
|
-
export declare function toCamelCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): CamelCase<Str, Del
|
|
109
|
+
export declare function toCamelCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<CamelCase<Str, Del>>;
|
|
110
110
|
/**
|
|
111
111
|
* * Converts a string into `PascalCase`, using the optional custom delimiters in addition to the default delimiters.
|
|
112
112
|
*
|
|
@@ -127,7 +127,7 @@ export declare function toCamelCase<Str extends string, Del extends string = ''>
|
|
|
127
127
|
* @param del Additional delimiter characters to recognize.
|
|
128
128
|
* @returns The `PascalCase` formatted string.
|
|
129
129
|
*/
|
|
130
|
-
export declare function toPascalCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PascalCase<Str, Del
|
|
130
|
+
export declare function toPascalCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PascalCase<Str, Del>>;
|
|
131
131
|
/**
|
|
132
132
|
* * Converts a string into `snake_case`, using the optional custom delimiters in addition to the default delimiters.
|
|
133
133
|
*
|
|
@@ -147,7 +147,7 @@ export declare function toPascalCase<Str extends string, Del extends string = ''
|
|
|
147
147
|
* @param del Additional delimiter characters to recognize.
|
|
148
148
|
* @returns The `snake_case` formatted string.
|
|
149
149
|
*/
|
|
150
|
-
export declare function toSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): SnakeCase<Str, Del
|
|
150
|
+
export declare function toSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<SnakeCase<Str, Del>>;
|
|
151
151
|
/**
|
|
152
152
|
* * Converts a string into `kebab-case`, using the optional custom delimiters in addition to the default delimiters.
|
|
153
153
|
*
|
|
@@ -167,7 +167,7 @@ export declare function toSnakeCase<Str extends string, Del extends string = ''>
|
|
|
167
167
|
* @param del Additional delimiter characters to recognize.
|
|
168
168
|
* @returns The `kebab-case` formatted string.
|
|
169
169
|
*/
|
|
170
|
-
export declare function toKebabCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): KebabCase<Str, Del
|
|
170
|
+
export declare function toKebabCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<KebabCase<Str, Del>>;
|
|
171
171
|
/**
|
|
172
172
|
* * Converts a string into `Train-Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
173
173
|
*
|
|
@@ -186,7 +186,7 @@ export declare function toKebabCase<Str extends string, Del extends string = ''>
|
|
|
186
186
|
* @param del Additional delimiter characters to recognize.
|
|
187
187
|
* @returns The `Train-Case` formatted string.
|
|
188
188
|
*/
|
|
189
|
-
export declare function toTrainCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): TrainCase<Str, Del
|
|
189
|
+
export declare function toTrainCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<TrainCase<Str, Del>>;
|
|
190
190
|
/**
|
|
191
191
|
* * Converts a string into `dot.case`, using the optional custom delimiters in addition to the default delimiters.
|
|
192
192
|
*
|
|
@@ -205,7 +205,7 @@ export declare function toTrainCase<Str extends string, Del extends string = ''>
|
|
|
205
205
|
* @param del Additional delimiter characters to recognize.
|
|
206
206
|
* @returns The `dot.case` formatted string.
|
|
207
207
|
*/
|
|
208
|
-
export declare function toDotCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): DotCase<Str, Del
|
|
208
|
+
export declare function toDotCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<DotCase<Str, Del>>;
|
|
209
209
|
/**
|
|
210
210
|
* * Converts a string into `path/case`, using the optional custom delimiters in addition to the default delimiters.
|
|
211
211
|
*
|
|
@@ -224,7 +224,7 @@ export declare function toDotCase<Str extends string, Del extends string = ''>(s
|
|
|
224
224
|
* @param del Additional delimiter characters to recognize.
|
|
225
225
|
* @returns The `path/case` formatted string.
|
|
226
226
|
*/
|
|
227
|
-
export declare function toPathCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PathCase<Str, Del
|
|
227
|
+
export declare function toPathCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PathCase<Str, Del>>;
|
|
228
228
|
/**
|
|
229
229
|
* * Converts a string into `CONSTANT_CASE`, using the optional custom delimiters in addition to the default delimiters.
|
|
230
230
|
*
|
|
@@ -243,7 +243,7 @@ export declare function toPathCase<Str extends string, Del extends string = ''>(
|
|
|
243
243
|
* @param del Additional delimiter characters to recognize.
|
|
244
244
|
* @returns The `CONSTANT_CASE` formatted string.
|
|
245
245
|
*/
|
|
246
|
-
export declare function toConstantCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): ConstantCase<Str, Del
|
|
246
|
+
export declare function toConstantCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<ConstantCase<Str, Del>>;
|
|
247
247
|
/**
|
|
248
248
|
* * Converts a string into `Pascal_Snake_Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
249
249
|
*
|
|
@@ -262,7 +262,7 @@ export declare function toConstantCase<Str extends string, Del extends string =
|
|
|
262
262
|
* @param del Additional delimiter characters to recognize.
|
|
263
263
|
* @returns The `Pascal_Snake_Case` formatted string.
|
|
264
264
|
*/
|
|
265
|
-
export declare function toPascalSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): PascalSnakeCase<Str, Del
|
|
265
|
+
export declare function toPascalSnakeCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<PascalSnakeCase<Str, Del>>;
|
|
266
266
|
/**
|
|
267
267
|
* * Converts a string into `Title Case`, using the optional custom delimiters in addition to the default delimiters.
|
|
268
268
|
*
|
|
@@ -283,7 +283,7 @@ export declare function toPascalSnakeCase<Str extends string, Del extends string
|
|
|
283
283
|
* @param del Additional delimiter characters to recognize.
|
|
284
284
|
* @returns The `Title Case` formatted string.
|
|
285
285
|
*/
|
|
286
|
-
export declare function toTitleCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): TitleCase<Str, Del
|
|
286
|
+
export declare function toTitleCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<TitleCase<Str, Del>>;
|
|
287
287
|
/**
|
|
288
288
|
* * Converts a string into `Sentence case`, using the optional custom delimiters in addition to the default delimiters.
|
|
289
289
|
*
|
|
@@ -304,4 +304,4 @@ export declare function toTitleCase<Str extends string, Del extends string = ''>
|
|
|
304
304
|
* @param del Additional delimiter characters to recognize.
|
|
305
305
|
* @returns The `Sentence case` formatted string.
|
|
306
306
|
*/
|
|
307
|
-
export declare function toSentenceCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): SentenceCase<Str, Del
|
|
307
|
+
export declare function toSentenceCase<Str extends string, Del extends string = ''>(str: Str, ...del: Del[]): $WidenEmpty<SentenceCase<Str, Del>>;
|
|
@@ -218,6 +218,8 @@ export type SentenceCase<Str extends string, Del extends string = ''> = Split<$N
|
|
|
218
218
|
infer F extends string,
|
|
219
219
|
...infer R extends string[]
|
|
220
220
|
] ? `${Capitalize<Lowercase<F>>} ${Join<$LowercaseWords<R>, ' '>}` : ' ';
|
|
221
|
+
/** Helper type to convert an empty string to `string` while maintaining the literal type otherwise. */
|
|
222
|
+
export type $WidenEmpty<T extends string> = T extends '' ? string : T;
|
|
221
223
|
/** Matches any non-Latin character. */
|
|
222
224
|
export type SpecialCharacter = Lowercase<string> & Uppercase<string>;
|
|
223
225
|
/** Evaluates whether a string consists only of Latin alphabet characters. */
|
package/dist/esm/string/case.js
CHANGED
|
@@ -55,11 +55,11 @@ export function convertStringCase(value, format, options) {
|
|
|
55
55
|
return start.concat(body, end);
|
|
56
56
|
}
|
|
57
57
|
case 'snake_case': {
|
|
58
|
-
const body = tokens.map(
|
|
58
|
+
const body = tokens.map(lowerCase).join('_');
|
|
59
59
|
return start.concat(body, end);
|
|
60
60
|
}
|
|
61
61
|
case 'kebab-case': {
|
|
62
|
-
const body = tokens.map(
|
|
62
|
+
const body = tokens.map(lowerCase).join('-');
|
|
63
63
|
return start.concat(body, end);
|
|
64
64
|
}
|
|
65
65
|
case 'Title Case': {
|
|
@@ -154,7 +154,7 @@ function _getDelimiterRegex(delims) {
|
|
|
154
154
|
function _normalizeDelimiters(str, delims) {
|
|
155
155
|
const delRegExp = _getDelimiterRegex(delims);
|
|
156
156
|
return str
|
|
157
|
-
.replace(/(\p{Ll}?\d+|(?<=\p{Lu}))(\p{Lu})/gu, '$1 $2')
|
|
157
|
+
.replace(/(\p{Ll}?\d+|(?<=\p{Lu}|\p{Ll}))(\p{Lu})/gu, '$1 $2')
|
|
158
158
|
.replace(delRegExp, ' ')
|
|
159
159
|
.replace(/\s+/g, ' ')
|
|
160
160
|
.trim()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nhb-toolbox",
|
|
3
|
-
"version": "4.30.
|
|
3
|
+
"version": "4.30.26",
|
|
4
4
|
"description": "A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|