js-utils-kit 0.5.4 → 1.0.0

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.
@@ -1,694 +0,0 @@
1
- /**
2
- * String trimming utilities.
3
- * Trims whitespace from a string (both sides by default) with methods for leading and trailing and normalizing whitespace.
4
- */
5
- interface Trim {
6
- /**
7
- * Removes whitespace from both ends of a string.
8
- *
9
- * @param str - The string to trim.
10
- * @returns The trimmed string.
11
- */
12
- function(str: string): string;
13
- /**
14
- * Removes leading whitespace from a string.
15
- *
16
- * @param str - The string to trim.
17
- * @returns The string with leading whitespace removed.
18
- */
19
- start(str: string): string;
20
- /**
21
- * Removes trailing whitespace from a string.
22
- *
23
- * @param str - The string to trim.
24
- * @returns The string with trailing whitespace removed.
25
- */
26
- end(str: string): string;
27
- /**
28
- * Trims the string and replaces sequences of whitespace with a single space.
29
- *
30
- * @param str - The string to normalize.
31
- * @returns The string with normalized whitespace.
32
- */
33
- normalizeWhitespace(str: string): string;
34
- }
35
- /**
36
- * String trimming utilities.
37
- * Trims whitespace from a string (both sides by default) with methods for leading and trailing and normalizing whitespace.
38
- *
39
- * @param str - The string to trim.
40
- *
41
- * @returns The string with leading and trailing whitespace removed.
42
- *
43
- * @remarks
44
- * - The main callable form behaves like {@link String.prototype.trim}, removing whitespace from both ends.
45
- * - `.start` removes only leading whitespace (like {@link String.prototype.trimStart}).
46
- * - `.end` removes only trailing whitespace (like {@link String.prototype.trimEnd}).
47
- * - `.normalizeWhitespace` trims the string and replaces any sequence of whitespace characters with a single space.
48
- *
49
- * @example
50
- * ```ts
51
- * // Trim both sides
52
- * console.log(trim(" hello ")); // "hello"
53
- * console.log(trim("")); // ""
54
- * console.log(trim("hello")); // "hello"
55
- *
56
- * // Trim leading whitespace
57
- * console.log(trim.start(" hello ")); // "hello "
58
- * console.log(trim.start("")); // ""
59
- * console.log(trim.start("hello")); // "hello"
60
- *
61
- * // Trim trailing whitespace
62
- * console.log(trim.end(" hello ")); // " hello"
63
- * console.log(trim.end("")); // ""
64
- * console.log(trim.end("hello")); // "hello"
65
- *
66
- * // Normalize whitespace
67
- * console.log(trim.normalizeWhitespace(" hello world ")); // "hello world"
68
- * console.log(trim.normalizeWhitespace("hello\t world")); // "hello world"
69
- * console.log(trim.normalizeWhitespace("")); // ""
70
- * ```
71
- */
72
- declare const trim: Trim;
73
-
74
- /**
75
- * Capitalizes the first character of a string using a regular expression.
76
- *
77
- * @param value - The string to capitalize.
78
- *
79
- * @returns The input string with its first character capitalized, or the original string if empty or not a string.
80
- *
81
- * @example
82
- * ```ts
83
- * capitalize("hello"); // "Hello"
84
- * capitalize("world"); // "World"
85
- * capitalize(""); // ""
86
- * capitalize("a"); // "A"
87
- * ```
88
- */
89
- declare function capitalize(value: string): string;
90
-
91
- /**
92
- * Splits a string into an array of substrings using a given delimiter.
93
- *
94
- * @remarks
95
- * - Defaults to splitting by whitespace using `/\s+/`.
96
- * - Does not trim leading/trailing spaces unless explicitly passed.
97
- * - Leading/trailing delimiters may produce empty strings.
98
- * - With `/\s+/` specifically, consecutive whitespace is collapsed (no interior empty tokens).
99
- *
100
- * @returns An array of substrings.
101
- *
102
- * @example
103
- * ```ts
104
- * splitString("a b c"); // ["a", "b", "c"]
105
- * splitString("a,b,c", ","); // ["a", "b", "c"]
106
- * splitString("a1b2c3", /\d/); // ["a", "b", "c", ""]
107
- * ```
108
- */
109
- declare function splitString(
110
- /** The input string to split. */
111
- str: string,
112
- /**
113
- * The delimiter (string or RegExp)
114
- *
115
- * @default whitespace `/\s+/`
116
- */
117
- val?: string | RegExp): string[];
118
- /**
119
- * Counts characters in a string.
120
- *
121
- * @remarks
122
- * - If `char` is provided, only that character’s occurrences are counted.
123
- * - If `char` is omitted, the function counts the number of substrings returned by {@link splitString} (similar to a word count).
124
- *
125
- * @returns Number of characters or character occurrences.
126
- *
127
- * @example
128
- * ```ts
129
- * countChars("banana"); // 6
130
- * countChars("banana", "a"); // 3
131
- * countChars("banana", "n"); // 2
132
- * ```
133
- */
134
- declare function countChars(
135
- /** The input string. */
136
- str: string,
137
- /** Optional character to count. */
138
- char?: string): number;
139
- /**
140
- * Counts the number of words in a string.
141
- *
142
- * @returns Number of words in the string.
143
- *
144
- * @example
145
- * ```ts
146
- * countWords("js utils kit"); // 3
147
- * countWords(" js utils kit"); // 3
148
- * countWords(""); // 0
149
- * ```
150
- */
151
- declare function countWords(
152
- /** The input string */
153
- str: string): number;
154
- /**
155
- * Counts how many times a substring occurs within a string.
156
- *
157
- * @remarks
158
- * - Overlapping substrings are not double-counted.
159
- * - Returns `0` if the substring is not found.
160
- *
161
- * @returns Number of times `sub` occurs in `str`.
162
- *
163
- * @example
164
- * ```ts
165
- * countSubstring("lololol", "lo"); // 3
166
- * countSubstring("aaaaa", "a"); // 5
167
- * countSubstring("hello", "z"); // 0
168
- * ```
169
- */
170
- declare function countSubstring(
171
- /** The input string. */
172
- str: string,
173
- /** The substring to count. */
174
- sub: string): number;
175
- /**
176
- * Builds a frequency map of characters in a string.
177
- *
178
- * @remarks
179
- * - Returns an object where keys are characters and values are counts.
180
- * - Case-sensitive by default.
181
- *
182
- * @returns A mapping of each character to its frequency.
183
- *
184
- * @example
185
- * ```ts
186
- * countFrequencies("banana");
187
- * // { b: 1, a: 3, n: 2 }
188
- *
189
- * countFrequencies("");
190
- * // {}
191
- * ```
192
- */
193
- declare function countFrequencies(
194
- /** The input string. */
195
- str: string): Record<string, number>;
196
- /**
197
- * Counts the number of lines in a string.
198
- *
199
- * @remarks
200
- * - Handles Unix (`\n`), Windows (`\r\n`), and old Mac (`\r`) line endings.
201
- *
202
- * @returns Number of lines in the string.
203
- *
204
- * @example
205
- * ```ts
206
- * countLines("a\nb\nc"); // 3
207
- * countLines("a\r\nb\r\nc"); // 3
208
- * countLines("hello"); // 1
209
- * ```
210
- */
211
- declare function countLines(
212
- /** The input string. */
213
- str: string): number;
214
- /**
215
- * Returns an array of unique characters from a string.
216
- *
217
- * @remarks
218
- * - Preserves order of first appearance.
219
- *
220
- * @returns Array of unique characters.
221
- *
222
- * @example
223
- * ```ts
224
- * uniqueChars("banana"); // ["b", "a", "n"]
225
- * uniqueChars(""); // []
226
- * ```
227
- */
228
- declare function uniqueChars(
229
- /** The input string. */
230
- str: string): string[];
231
- /**
232
- * Finds the length of the longest word in a string.
233
- *
234
- * @remarks
235
- * - Words are split by whitespace (`/\s+/`).
236
- * - Symbols (punctuation, special chars) are removed using {@link stripSymbols}.
237
- * - Returns `0` if the string is empty or contains no words.
238
- *
239
- * @returns Length of the longest word.
240
- *
241
- * @example
242
- * ```ts
243
- * longestWordLength("js utils kit"); // 5
244
- * longestWordLength("short longerword mid"); // 10
245
- * longestWordLength("hello"); // 5
246
- * longestWordLength(""); // 0
247
- * ```
248
- */
249
- declare function longestWordLength(
250
- /** The input string. */
251
- str: string): number;
252
- /**
253
- * Finds the length of the shortest word in a string.
254
- *
255
- * @remarks
256
- * - Words are split by whitespace (`/\s+/`).
257
- * - Symbols (punctuation, special chars) are removed using {@link stripSymbols}.
258
- * - Returns `0` if the string is empty or contains no words.
259
- *
260
- * @returns Length of the shortest word.
261
- *
262
- * @example
263
- * ```ts
264
- * shortestWordLength("js utils kit"); // 2
265
- * shortestWordLength("one three five"); // 3
266
- * shortestWordLength(""); // 0
267
- * ```
268
- */
269
- declare function shortestWordLength(
270
- /** The input string. */
271
- str: string): number;
272
- /**
273
- * Finds the longest word(s) in a string.
274
- *
275
- * @remarks
276
- * - If only one longest word exists, returns it as a string.
277
- * - If multiple longest words have the same length, returns them as an array.
278
- * - Returns an empty string if there are no words.
279
- *
280
- * @returns The longest word as a string, or an array of tied words.
281
- *
282
- * @example
283
- * ```ts
284
- * longestWord("js utils kit"); // "utils"
285
- * longestWord("short longerword mid"); // "longerword"
286
- * longestWord("hello"); // "hello"
287
- * longestWord(""); // ""
288
- * ```
289
- */
290
- declare function longestWord(
291
- /** The input string. */
292
- str: string): string | string[];
293
- /**
294
- * Finds the shortest word(s) in a string.
295
- *
296
- * @remarks
297
- * - If only one shortest word exists, returns it as a string.
298
- * - If multiple shortest words have the same length, returns them as an array.
299
- * - Returns an empty string if there are no words.
300
- *
301
- * @returns The shortest word as a string, or an array of tied words.
302
- *
303
- * @example
304
- * ```ts
305
- * shortestWord("js utils kit"); // "js"
306
- * shortestWord("one three five"); // "one"
307
- * shortestWord("a ab abc abcd"); // "a"
308
- * shortestWord(""); // ""
309
- * ```
310
- */
311
- declare function shortestWord(
312
- /** The input string. */
313
- str: string): string | string[];
314
-
315
- /**
316
- * Pads a string on the left with a specified character until it reaches the desired length.
317
- * @param str - The string to pad.
318
- * @param length - The target length of the padded string.
319
- * @param char - The character to use for padding (defaults to a space).
320
- * @returns The padded string, or the original string if its length is already greater than or equal to the target length.
321
- * @example
322
- * ```ts
323
- * console.log(padLeft("hello", 8)); // " hello"
324
- * console.log(padLeft("hi", 5, "*")); // "***hi"
325
- * console.log(padLeft("hello", 3)); // "hello"
326
- * console.log(padLeft("", 3, "0")); // "000"
327
- * ```
328
- */
329
- declare function padLeft(str: string, length: number, char?: string): string;
330
- /**
331
- * Pads a string on the right with a specified character until it reaches the desired length.
332
- * @param str - The string to pad.
333
- * @param length - The target length of the padded string.
334
- * @param char - The character to use for padding (defaults to a space).
335
- * @returns The padded string, or the original string if its length is already greater than or equal to the target length.
336
- * @example
337
- * ```ts
338
- * console.log(padRight("hello", 8)); // "hello "
339
- * console.log(padRight("hi", 5, "*")); // "hi***"
340
- * console.log(padRight("hello", 3)); // "hello"
341
- * console.log(padRight("", 3, "0")); // "000"
342
- * ```
343
- */
344
- declare function padRight(str: string, length: number, char?: string): string;
345
- /**
346
- * Truncates a string to a specified length, appending a suffix if the string is too long.
347
- *
348
- * @returns The truncated string with the suffix if the original string exceeds the length, otherwise the original string.
349
- *
350
- * @example
351
- * ```ts
352
- * console.log(truncate("hello world", 8)); // "hello..."
353
- * console.log(truncate("hi", 5)); // "hi"
354
- * console.log(truncate("hello", 5, "...")); // "hello"
355
- * console.log(truncate("", 3)); // ""
356
- * ```
357
- */
358
- declare function truncate(
359
- /** The string to truncate */
360
- str: string,
361
- /** The maximum length of the resulting string */
362
- length: number,
363
- /**
364
- * The suffix to append if truncation occurs
365
- *
366
- * @default "..."
367
- */
368
- suffix?: string): string;
369
- /**
370
- * Repeats a string a specified number of times.
371
- * @param str - The string to repeat.
372
- * @param count - The number of times to repeat the string (must be non-negative).
373
- * @returns The string repeated the specified number of times.
374
- * @example
375
- * ```ts
376
- * console.log(repeatString("hi", 3)); // "hihihi"
377
- * console.log(repeatString("a", 2)); // "aa"
378
- * console.log(repeatString("test", 0)); // ""
379
- * console.log(repeatString("", 5)); // ""
380
- * ```
381
- */
382
- declare function repeatString(str: string, count: number): string;
383
- /**
384
- * Removes or replaces common symbol characters from a string.
385
- *
386
- * @remarks
387
- * - Strips symbols like `- _ @ ! $ % ^ & # * ( ) + = , . ; : ' " < > ? / \ | [ ] { }`.
388
- * - Keeps letters, numbers, and spaces intact.
389
- * - By default, removes symbols (replaces with `""`).
390
- *
391
- * @returns A new string with symbols removed or replaced.
392
- *
393
- * @example
394
- * ```ts
395
- * stripSymbols("hello-world!"); // "helloworld"
396
- * stripSymbols("hello-world!", " "); // "hello world "
397
- * stripSymbols("user_name@test", "_"); // "user_nametest"
398
- * stripSymbols("symbols-only!!!", "*"); // "symbols-only***"
399
- * ```
400
- */
401
- declare function stripSymbols(
402
- /** The input string */
403
- str: string,
404
- /**
405
- * Optional replacement string for removed symbols.
406
- *
407
- * @default ""
408
- */
409
- replacement?: string): string;
410
-
411
- /**
412
- * Determines whether the provided value is a string.
413
- *
414
- * This function returns `true` if the input is a non-null, non-undefined
415
- * primitive string. It acts as a type guard, so TypeScript will narrow
416
- * the type to `string` when used in conditionals.
417
- *
418
- * @template T - The type of the input value.
419
- * @param value - The value to be checked.
420
- * @returns - Whether the value is a string (`true`) or not (`false`).
421
- *
422
- * @example
423
- * ```ts
424
- * isString("hello"); // true
425
- * isString(123); // false
426
- * isString(null); // false
427
- * isString(undefined); // false
428
- *
429
- * const value: unknown = "test";
430
- * if (isString(value)) {
431
- * console.log(value.toUpperCase());
432
- * }
433
- * ```
434
- */
435
- declare function isString<T>(value: T): boolean;
436
- /**
437
- * Determines whether the given value is a non-empty string.
438
- *
439
- * This function first checks if the input is a string using {@link isString}.
440
- * If it is not a string, the function returns `false`.
441
- * If it is a string, it then checks whether the string contains any non-empty content.
442
- *
443
- * By default, the function trims the string before checking its length,
444
- * which means strings containing only whitespace (e.g., `" "`) will be considered empty.
445
- * This behavior can be controlled using the `trim` parameter.
446
- *
447
- * @template T - The type of the value being checked.
448
- *
449
- * @param value - The value to validate as a non-empty string.
450
- * @param trim - Whether to trim whitespace from the string before checking its length.
451
- * Defaults to `true`.
452
- *
453
- * @returns - A boolean indicating whether the input is a non-empty string.
454
- *
455
- * @example
456
- * ```ts
457
- * isNonEmptyString('hello'); // true
458
- * isNonEmptyString(' '); // false (trim is true by default)
459
- * isNonEmptyString(' ', false); // true (whitespace is counted)
460
- * isNonEmptyString(123); // false
461
- * isNonEmptyString(null); // false
462
- * ```
463
- */
464
- declare function isNonEmptyString<T>(value: T, trim?: boolean): boolean;
465
- /**
466
- * Checks whether a given string is a valid absolute URL.
467
- *
468
- * This function uses the native `URL` constructor to determine if the input is a valid,
469
- * absolute URL with a supported protocol (e.g., `http`, `https`, `ftp`, etc.).
470
- *
471
- * @param value - The string to validate as a URL.
472
- * @returns - `true` if the string is a valid absolute URL; otherwise, `false`.
473
- *
474
- * @example
475
- * ```ts
476
- * isURL('https://example.com'); // true
477
- * isURL('ftp://files.example.com'); // true
478
- * isURL('invalid-url'); // false
479
- * isURL('/relative/path'); // false
480
- * ```
481
- */
482
- declare function isURL(value: string): boolean;
483
- /**
484
- * Checks whether a given string is a valid email address.
485
- *
486
- * @remarks
487
- * This function uses a practical regular expression to validate email addresses,
488
- * allowing most common formats while ignoring edge cases defined by full RFC 5322.
489
- * It requires the presence of an `@` symbol and at least one `.` after it.
490
- *
491
- * **Limits enforced**:
492
- * - Local part (before `@`): 1–64 characters
493
- * - Domain part (after `@`): 1–255 characters
494
- * - Total email length: ≤ 254 characters
495
- *
496
- * @param value - The string to validate as an email address.
497
- *
498
- * @throws {TypeError} Throws if value is not a string.
499
- *
500
- * @returns - `true` if the string is a valid email; otherwise, `false`.
501
- *
502
- * @example
503
- * ```ts
504
- * isEmail('user@example.com'); // true
505
- * isEmail('first.last@college.university.in'); // true
506
- * isEmail('invalid-email'); // false
507
- * isEmail('name@domain'); // false
508
- * ```
509
- */
510
- declare function isEmail(value: string): boolean;
511
- /**
512
- * Checks if a string contains only alphabetic characters (A–Z, a–z).
513
- *
514
- * @param value - The string to check.
515
- * @returns - `true` if the string contains only letters; otherwise, `false`.
516
- *
517
- * @example
518
- * ```ts
519
- * isAlphabetic("Hello"); // true
520
- * isAlphabetic("world123"); // false
521
- * isAlphabetic("Test!"); // false
522
- * ```
523
- */
524
- declare function isAlphabetic(value: string): boolean;
525
- /**
526
- * Checks whether a given string represents a valid numeric value.
527
- *
528
- * This function attempts to convert the input string to a number using
529
- * both `Number()` and `parseFloat()`. It returns `true` only if both
530
- * conversions do not result in `NaN`, ensuring that the input is
531
- * a fully numeric string.
532
- *
533
- * Accepts integers, decimals, scientific notation (e.g. "1e5"), and
534
- * ignores surrounding whitespace. Does not allow trailing or embedded characters
535
- * like "123abc" or "abc123".
536
- *
537
- * @param value - The string to validate.
538
- * @returns - `true` if the string represents a valid number; otherwise, `false`.
539
- *
540
- * @example
541
- * ```ts
542
- * isNumericString("42"); // true
543
- * isNumericString("-3.14"); // true
544
- * isNumericString("1e5"); // true
545
- * isNumericString(" 123 "); // true
546
- * isNumericString("123abc"); // false
547
- * isNumericString("abc123"); // false
548
- * ```
549
- * See also:
550
- * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number Number()}
551
- * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat parseFloat()}
552
- * - {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN isNaN()}
553
- */
554
- declare function isNumericString(value: string): boolean;
555
- /**
556
- * Checks if a string starts with an uppercase letter.
557
- * @param value - The input string to check.
558
- * @returns True if the first character is uppercase, false otherwise.
559
- * @example
560
- * ```ts
561
- * startsWithUppercase('Hello') // true
562
- * startsWithUppercase('world') // false
563
- * ```
564
- */
565
- declare function startsWithUppercase(value: string): boolean;
566
- /**
567
- * Checks if a string ends with any Unicode punctuation character.
568
- *
569
- * @param value - The string to check.
570
- * @returns True if the string ends with a punctuation character.
571
- * @example
572
- * ```ts
573
- * endsWithPunctuation("Hi!") // true
574
- * endsWithPunctuation("Hello—") // true
575
- * endsWithPunctuation("Okay") // false
576
- * ```
577
- */
578
- declare function endsWithPunctuation(value: string): boolean;
579
- /**
580
- * Checks if a string contains any whitespace.
581
- * @param value - The string to check.
582
- * @returns True if the string contains whitespace.
583
- * @example
584
- * ```ts
585
- * containsWhitespace("Hello world") // true
586
- * containsWhitespace("Nowordspace") // false
587
- * ```
588
- */
589
- declare function containsWhitespace(value: string): boolean;
590
- /**
591
- * Checks if a string is in camelCase format.
592
- * @param value - The input string.
593
- * @returns True if the string is camelCase.
594
- * @example
595
- * ```ts
596
- * isCamelCase("helloWorld") // true
597
- * isCamelCase("HelloWorld") // false
598
- * ```
599
- */
600
- declare function isCamelCase(value: string): boolean;
601
- /**
602
- * Checks if a string is in PascalCase format.
603
- * @param value - The input string.
604
- * @returns True if the string is PascalCase.
605
- * @example
606
- * ```ts
607
- * isPascalCase("HelloWorld") // true
608
- * isPascalCase("helloWorld") // false
609
- * ```
610
- */
611
- declare function isPascalCase(value: string): boolean;
612
- /**
613
- * Checks if a string is in kebab-case format.
614
- * @param value - The input string.
615
- * @returns True if the string is kebab-case.
616
- * @example
617
- * ```ts
618
- * isKebabCase("hello-world") // true
619
- * isKebabCase("hello_world") // false
620
- * ```
621
- */
622
- declare function isKebabCase(value: string): boolean;
623
- /**
624
- * Checks if a string is in snake_case format.
625
- * @param value - The input string.
626
- * @returns True if the string is snake_case.
627
- * @example
628
- * ```ts
629
- * isSnakeCase("hello_world") // true
630
- * isSnakeCase("hello-world") // false
631
- * ```
632
- */
633
- declare function isSnakeCase(value: string): boolean;
634
- /**
635
- * Checks if a string contains only uppercase letters.
636
- * @param value - The input string.
637
- * @returns True if all letters are uppercase.
638
- * @example
639
- * ```ts
640
- * isUpperCase("HELLO") // true
641
- * isUpperCase("Hello") // false
642
- * ```
643
- */
644
- declare function isUpperCase(value: string): boolean;
645
- /**
646
- * Checks if a string contains only lowercase letters.
647
- * @param value - The input string.
648
- * @returns True if all letters are lowercase.
649
- * @example
650
- * ```ts
651
- * isLowerCase("hello") // true
652
- * isLowerCase("Hello") // false
653
- * ```
654
- */
655
- declare function isLowerCase(value: string): boolean;
656
-
657
- declare const _default: {
658
- capitalize: typeof capitalize;
659
- splitString: typeof splitString;
660
- countChars: typeof countChars;
661
- countWords: typeof countWords;
662
- countSubstring: typeof countSubstring;
663
- countFrequencies: typeof countFrequencies;
664
- countLines: typeof countLines;
665
- uniqueChars: typeof uniqueChars;
666
- longestWordLength: typeof longestWordLength;
667
- shortestWordLength: typeof shortestWordLength;
668
- longestWord: typeof longestWord;
669
- shortestWord: typeof shortestWord;
670
- padLeft: typeof padLeft;
671
- padRight: typeof padRight;
672
- truncate: typeof truncate;
673
- repeatString: typeof repeatString;
674
- stripSymbols: typeof stripSymbols;
675
- trim: Trim;
676
- isString: typeof isString;
677
- isNonEmptyString: typeof isNonEmptyString;
678
- isURL: typeof isURL;
679
- isEmail: typeof isEmail;
680
- isAlphabetic: typeof isAlphabetic;
681
- isNumericString: typeof isNumericString;
682
- startsWithUppercase: typeof startsWithUppercase;
683
- endsWithPunctuation: typeof endsWithPunctuation;
684
- containsWhitespace: typeof containsWhitespace;
685
- isCamelCase: typeof isCamelCase;
686
- isPascalCase: typeof isPascalCase;
687
- isKebabCase: typeof isKebabCase;
688
- isSnakeCase: typeof isSnakeCase;
689
- isUpperCase: typeof isUpperCase;
690
- isLowerCase: typeof isLowerCase;
691
- };
692
-
693
- export { capitalize, containsWhitespace, countChars, countFrequencies, countLines, countSubstring, countWords, _default as default, endsWithPunctuation, isAlphabetic, isCamelCase, isEmail, isKebabCase, isLowerCase, isNonEmptyString, isNumericString, isPascalCase, isSnakeCase, isString, isURL, isUpperCase, longestWord, longestWordLength, padLeft, padRight, repeatString, shortestWord, shortestWordLength, splitString, startsWithUppercase, stripSymbols, trim, truncate, uniqueChars };
694
- export type { Trim };
@@ -1 +0,0 @@
1
- function t(t){return t.replace(/^\w/,t=>t.toUpperCase())}function n(t,n,e=" "){return t.padStart(n,e)}function e(t,n,e=" "){return t.padEnd(n,e)}function r(t,n,e="..."){return n<=0?"":t.length<=n?t:e.length>=n?e.slice(0,n):t.trim().slice(0,n)+e}function i(t,n){return t.repeat(n)}function u(t,n=""){return t.replace(/[^\p{L}\p{N}\s]/gu,n)}function s(t,n=/\s+/){return t.split(n)}function o(t,n){return n?[...t].filter(t=>t===n).length:s(t).length}function a(t){return s(t.trim()).length}function c(t,n){return 0===n.length?0:s(t,n).length-1}function l(t){return[...t].reduce((t,n)=>(t[n]=(t[n]||0)+1,t),{})}function f(t){return t?s(t,/\r\n|\r|\n/).length:0}function h(t){return[...new Set(t)]}function g(t){const n=s(t).map(t=>u(t)).filter(Boolean);return 0===n.length?0:n.reduce((t,n)=>Math.max(t,n.length),0)}function p(t){const n=s(t.trim()).map(t=>u(t)).filter(Boolean);return 0===n.length?0:n.reduce((t,n)=>Math.min(t,n.length),1/0)}function m(t){const n=s(t.trim()).map(t=>u(t)).filter(Boolean);if(0===n.length)return"";const e=Math.max(...n.map(t=>t.length)),r=n.filter(t=>t.length===e),i=[...new Set(r)];return 1===i.length?i[0]:i}function d(t){const n=s(t.trim()).map(t=>u(t)).filter(Boolean);if(0===n.length)return"";const e=Math.min(...n.map(t=>t.length)),r=n.filter(t=>t.length===e),i=[...new Set(r)];return 1===i.length?i[0]:i}const z={function:t=>t.trim(),start:t=>t.trimStart(),end:t=>t.trimEnd(),normalizeWhitespace:t=>t.trim().replace(/\s+/g," ")};function S(t){return null!=t&&"string"==typeof t}function A(t,n=!0){return!!S(t)&&("string"==typeof t&&(n?t.trim().length>0:t.length>0))}function Z(t){try{return new URL(t),!0}catch{return!1}}function C(t){if("string"!=typeof t)throw new TypeError("Expected a string");if(t.length>254)return!1;const n=t.split("@");if(2!==n.length)return!1;const[e,r]=n;if(0===e.length||e.length>64)return!1;if(0===r.length||r.length>255)return!1;return!!/^[a-zA-Z0-9_%+-]+(\.[a-zA-Z0-9_%+-]+)*$/.test(e)&&!!/^(?!.*\.\.)(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.[A-Za-z0-9-]{1,63}(?<!-))*\.[A-Za-z]{2,}$/.test(r)}function $(t){return/^[a-zA-Z]+$/.test(t)}function W(t){return!isNaN(Number(t))&&!isNaN(parseFloat(t))}function w(t){return/^[A-Z]/.test(t)}function L(t){return/[\p{P}]$/u.test(t)}function N(t){return/\s/.test(t)}function y(t){return/^[a-z][a-zA-Z0-9]*$/.test(t)}function b(t){return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function E(t){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(t)}function U(t){return/^[a-z0-9]+(_[a-z0-9]+)*$/.test(t)}function x(t){return/^[A-Z]+$/.test(t)}function B(t){return/^[a-z]+$/.test(t)}var M={capitalize:t,splitString:s,countChars:o,countWords:a,countSubstring:c,countFrequencies:l,countLines:f,uniqueChars:h,longestWordLength:g,shortestWordLength:p,longestWord:m,shortestWord:d,padLeft:n,padRight:e,truncate:r,repeatString:i,stripSymbols:u,trim:z,isString:S,isNonEmptyString:A,isURL:Z,isEmail:C,isAlphabetic:$,isNumericString:W,startsWithUppercase:w,endsWithPunctuation:L,containsWhitespace:N,isCamelCase:y,isPascalCase:b,isKebabCase:E,isSnakeCase:U,isUpperCase:x,isLowerCase:B};export{t as capitalize,N as containsWhitespace,o as countChars,l as countFrequencies,f as countLines,c as countSubstring,a as countWords,M as default,L as endsWithPunctuation,$ as isAlphabetic,y as isCamelCase,C as isEmail,E as isKebabCase,B as isLowerCase,A as isNonEmptyString,W as isNumericString,b as isPascalCase,U as isSnakeCase,S as isString,Z as isURL,x as isUpperCase,m as longestWord,g as longestWordLength,n as padLeft,e as padRight,i as repeatString,d as shortestWord,p as shortestWordLength,s as splitString,w as startsWithUppercase,u as stripSymbols,z as trim,r as truncate,h as uniqueChars};
@@ -1 +0,0 @@
1
- "use strict";function r(r){return null!=r}exports.isArray=function(n){return r(n)&&Array.isArray(n)},exports.isDefined=r,exports.isUndefinedOrNull=function(r){return null==r};