@visulima/string 3.1.1 → 3.1.2
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 +10 -0
- package/LICENSE.md +26 -0
- package/README.md +1 -1
- package/dist/case/camel-case.d.ts +2 -2
- package/dist/case/capital-case.d.ts +2 -2
- package/dist/case/constant-case.d.ts +2 -2
- package/dist/case/dot-case.d.ts +2 -2
- package/dist/case/flat-case.d.ts +2 -2
- package/dist/case/flip-case.d.ts +2 -2
- package/dist/case/identify-case.d.ts +2 -2
- package/dist/case/index.d.ts +2 -2
- package/dist/case/kebab-case.d.ts +2 -2
- package/dist/case/lower-first.d.ts +2 -2
- package/dist/case/no-case.d.ts +2 -2
- package/dist/case/pascal-case.d.ts +2 -2
- package/dist/case/pascal-snake-case.d.ts +2 -2
- package/dist/case/path-case.d.ts +2 -2
- package/dist/case/sentence-case.d.ts +2 -2
- package/dist/case/snake-case.d.ts +2 -2
- package/dist/case/split-by-case.d.ts +2 -2
- package/dist/case/title-case.d.ts +2 -2
- package/dist/case/train-case.d.ts +2 -2
- package/dist/case/upper-first.d.ts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/native-string-types.d.ts +6 -1
- package/dist/packem_shared/{types.d-CMNqA5bi.d.ts → types.d-BdJ2aEyS.d.ts} +1 -1
- package/dist/packem_shared/{types.d-LgsTR37y.d.ts → types.d-Bky9TnxG.d.ts} +6 -1
- package/dist/replace-string.d.ts +1 -1
- package/dist/slugify.d.ts +1 -1
- package/dist/transliterate.d.ts +1 -1
- package/dist/utilities.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## @visulima/string [3.1.2](https://github.com/visulima/visulima/compare/@visulima/string@3.1.1...@visulima/string@3.1.2) (2026-10-31)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **string:** ship license notice and port Repeat fixes ([#989](https://github.com/visulima/visulima/issues/989)) ([11faab9](https://github.com/visulima/visulima/commit/11faab9bd61412339f20bb88e37e5ce2032130c6))
|
|
6
|
+
|
|
7
|
+
### Miscellaneous Chores
|
|
8
|
+
|
|
9
|
+
* improve npm search metadata ([#979](https://github.com/visulima/visulima/issues/979)) ([3f4ed10](https://github.com/visulima/visulima/commit/3f4ed1087286a57b5abbccbb481e352e8a9d4f58))
|
|
10
|
+
|
|
1
11
|
## @visulima/string [3.1.1](https://github.com/visulima/visulima/compare/@visulima/string@3.1.0...@visulima/string@3.1.1) (2026-10-05)
|
|
2
12
|
|
|
3
13
|
### Bug Fixes
|
package/LICENSE.md
CHANGED
|
@@ -20,6 +20,32 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
22
|
|
|
23
|
+
# Adapted code
|
|
24
|
+
|
|
25
|
+
The type-level utilities in this package are modified copies of types from string-ts v2.2.1 (https://github.com/gustavoguichard/string-ts), distributed under the following license:
|
|
26
|
+
|
|
27
|
+
MIT License
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2023 Gustavo Guichard
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
33
|
+
in the Software without restriction, including without limitation the rights
|
|
34
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
36
|
+
furnished to do so, subject to the following conditions:
|
|
37
|
+
|
|
38
|
+
The above copyright notice and this permission notice shall be included in all
|
|
39
|
+
copies or substantial portions of the Software.
|
|
40
|
+
|
|
41
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
+
SOFTWARE.
|
|
48
|
+
|
|
23
49
|
<!-- DEPENDENCIES -->
|
|
24
50
|
|
|
25
51
|
# Licenses of bundled dependencies
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, C as CamelCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, C as CamelCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to camelCase.
|
|
5
5
|
* @param value The string to convert.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, a as CapitalCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, a as CapitalCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to Capital Case.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, c as ConstantCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, c as ConstantCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to CONSTANT_CASE.
|
|
5
5
|
* @example
|
package/dist/case/dot-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, D as DotCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, D as DotCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to dot.case.
|
|
5
5
|
* @example
|
package/dist/case/flat-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, F as FlatCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, F as FlatCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to flat case (all lowercase, no separators).
|
|
5
5
|
* @example
|
package/dist/case/flip-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, d as FlipCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, d as FlipCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Options specific to flip case operations.
|
|
5
5
|
* Note: handleEmoji is not needed as the function preserves emojis by default
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { I as IdentifyCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { I as IdentifyCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Identifies the case style of a string.
|
|
5
5
|
* @example
|
package/dist/case/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { N as NodeLocale } from "../packem_shared/types.d-
|
|
1
|
+
export type { N as NodeLocale } from "../packem_shared/types.d-Bky9TnxG.js";
|
|
2
2
|
export { default as camelCase } from "./camel-case.js";
|
|
3
3
|
export { default as capitalCase } from "./capital-case.js";
|
|
4
4
|
export { default as constantCase } from "./constant-case.js";
|
|
@@ -17,7 +17,7 @@ export { default as snakeCase } from "./snake-case.js";
|
|
|
17
17
|
export { type SplitOptions, splitByCase } from "./split-by-case.js";
|
|
18
18
|
export { default as titleCase } from "./title-case.js";
|
|
19
19
|
export { default as trainCase } from "./train-case.js";
|
|
20
|
-
export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "../packem_shared/types.d-
|
|
20
|
+
export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
21
21
|
export { default as upperFirst } from "./upper-first.js";
|
|
22
22
|
/**
|
|
23
23
|
* Joins segments with a joiner, handling ANSI sequences and emojis correctly.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, K as KebabCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, K as KebabCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
interface KebabCaseOptions extends CaseOptions {
|
|
4
4
|
/**
|
|
5
5
|
* String used to join words together in kebab case format.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { L as LocaleOptions, e as LowerFirst } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts first character to lower case.
|
|
5
5
|
* @param value The string to convert.
|
package/dist/case/no-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, N as NoCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, N as NoCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to no case (space separated words).
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, P as PascalCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, P as PascalCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to PascalCase.
|
|
5
5
|
* @param value The string to convert.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, f as PascalSnakeCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to Pascal_Snake_Case.
|
|
5
5
|
* @example
|
package/dist/case/path-case.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, g as PathCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, g as PathCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to path/case.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, S as SentenceCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to Sentence case.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, h as SnakeCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to snake_case.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { L as LocaleOptions, i as SplitByCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/** Options for the `splitByCase` function. */
|
|
4
4
|
interface SplitOptions extends LocaleOptions {
|
|
5
5
|
/** Whether to handle ANSI escape sequences. (default: false) */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, T as TitleCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, T as TitleCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* With Title Case all words are capitalized, except for minor words.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as CaseOptions, j as TrainCase } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { b as CaseOptions, j as TrainCase } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts a string to Train-Case.
|
|
5
5
|
* @example
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LocaleOptions, U as UpperFirst } from "../packem_shared/types.d-
|
|
2
|
-
import "../packem_shared/types.d-
|
|
1
|
+
import { L as LocaleOptions, U as UpperFirst } from "../packem_shared/types.d-BdJ2aEyS.js";
|
|
2
|
+
import "../packem_shared/types.d-Bky9TnxG.js";
|
|
3
3
|
/**
|
|
4
4
|
* Converts first character to upper case.
|
|
5
5
|
* @param value The string to convert.
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { default as snakeCase } from "./case/snake-case.js";
|
|
|
17
17
|
export { type SplitOptions, splitByCase } from "./case/split-by-case.js";
|
|
18
18
|
export { default as titleCase } from "./case/title-case.js";
|
|
19
19
|
export { default as trainCase } from "./case/train-case.js";
|
|
20
|
-
export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "./packem_shared/types.d-
|
|
20
|
+
export type { C as CamelCase, a as CapitalCase, b as CaseOptions, c as ConstantCase, D as DotCase, F as FlatCase, d as FlipCase, I as IdentifyCase, K as KebabCase, L as LocaleOptions, e as LowerFirst, N as NoCase, P as PascalCase, f as PascalSnakeCase, g as PathCase, S as SentenceCase, h as SnakeCase, i as SplitByCase, T as TitleCase, j as TrainCase, U as UpperFirst } from "./packem_shared/types.d-BdJ2aEyS.js";
|
|
21
21
|
export { default as upperFirst } from "./case/upper-first.js";
|
|
22
22
|
export { joinSegments } from "./case/index.js";
|
|
23
23
|
export { type ClosestStringOptions, closestString } from "./closest-string.js";
|
|
@@ -35,7 +35,7 @@ export { type SliceOptions, slice } from "./slice.js";
|
|
|
35
35
|
export { default as slugify } from "./slugify.js";
|
|
36
36
|
export { default as transliterate } from "./transliterate.js";
|
|
37
37
|
export { type TruncateOptions, truncate } from "./truncate.js";
|
|
38
|
-
export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as EndsWith, I as Includes, d as Interval, e as IntervalArray, f as IsBooleanLiteral, g as IsNumberLiteral, h as IsStringLiteral, i as IsStringLiteralArray, J as Join, L as Length, M as Math, N as NodeLocale, O as OptionReplaceArray, j as OptionReplaceCombined, k as OptionReplaceObject, l as OptionsTransliterate, P as PadEnd, m as PadStart, R as Repeat, n as Replace, o as ReplaceAll, p as Reverse, S as Slice, q as SlugifyOptions, r as Split, s as StartsWith, T as ToLowerCase, t as ToUpperCase, u as Trim, v as TrimEnd, w as TrimStart } from "./packem_shared/types.d-
|
|
38
|
+
export type { A as All, a as Any, C as CharAt, b as Charmap, c as Concat, E as EndsWith, I as Includes, d as Interval, e as IntervalArray, f as IsBooleanLiteral, g as IsNumberLiteral, h as IsStringLiteral, i as IsStringLiteralArray, J as Join, L as Length, M as Math, N as NodeLocale, O as OptionReplaceArray, j as OptionReplaceCombined, k as OptionReplaceObject, l as OptionsTransliterate, P as PadEnd, m as PadStart, R as Repeat, n as Replace, o as ReplaceAll, p as Reverse, S as Slice, q as SlugifyOptions, r as Split, s as StartsWith, T as ToLowerCase, t as ToUpperCase, u as Trim, v as TrimEnd, w as TrimStart } from "./packem_shared/types.d-Bky9TnxG.js";
|
|
39
39
|
export { escapeRegExp, findStringOccurrences, hasChinese, hasPunctuationOrSpace, inRange } from "./utilities.js";
|
|
40
40
|
export { type WordSimilaritySortOptions, wordSimilaritySort } from "./word-similarity-sort.js";
|
|
41
41
|
export { type WordWrapOptions, WrapMode, wordWrap } from "./word-wrap.js";
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* @returns A tuple type of length L filled with type T
|
|
8
8
|
*/
|
|
9
9
|
type TupleOf<L extends number, T = unknown, Result extends any[] = []> = Result["length"] extends L ? Result : TupleOf<L, T, [...Result, T]>;
|
|
10
|
+
/**
|
|
11
|
+
* Repeat counts whose literal expansion stays within TypeScript's instantiation depth limit.
|
|
12
|
+
*/
|
|
13
|
+
type SafeRepeatCount = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45;
|
|
10
14
|
/**
|
|
11
15
|
* Internal type for implementing string slicing with both start and end indices.
|
|
12
16
|
* Handles edge cases and type safety for string literal types.
|
|
@@ -165,13 +169,14 @@ type PadStart<T extends string, Times extends number = 0, Pad extends string = "
|
|
|
165
169
|
/**
|
|
166
170
|
* Type-level implementation of string.repeat() functionality.
|
|
167
171
|
* Creates a new string type by repeating the input string a specified number of times.
|
|
172
|
+
* Counts above 45 fall back to `string` to avoid TypeScript's type-instantiation depth limit (TS2589).
|
|
168
173
|
* @template T - The string type to repeat
|
|
169
174
|
* @template Times - The number of times to repeat the string
|
|
170
175
|
* @returns A string type containing T repeated Times times
|
|
171
176
|
* @example
|
|
172
177
|
* type Repeated = Repeat<'abc', 2> // type Repeated = 'abcabc'
|
|
173
178
|
*/
|
|
174
|
-
type Repeat<T extends string, Times extends number = 0> = All<[IsStringLiteral<T>, IsNumberLiteral<Times>]> extends true ? Times extends 0 ? "" : Math.IsNegative<Times> extends false ? Join<TupleOf<Times, T>> : never : string;
|
|
179
|
+
type Repeat<T extends string, Times extends number = 0> = T extends T ? All<[IsStringLiteral<T>, IsNumberLiteral<Times>]> extends true ? Times extends 0 ? "" : Math.IsNegative<Times> extends false ? Times extends SafeRepeatCount ? Join<TupleOf<Times, T>> : string : never : string : never;
|
|
175
180
|
/**
|
|
176
181
|
* Type-level implementation of string.replaceAll() functionality.
|
|
177
182
|
* Replaces all occurrences of a substring with another string.
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* @returns A tuple type of length L filled with type T
|
|
8
8
|
*/
|
|
9
9
|
type TupleOf<L extends number, T = unknown, Result extends any[] = []> = Result["length"] extends L ? Result : TupleOf<L, T, [...Result, T]>;
|
|
10
|
+
/**
|
|
11
|
+
* Repeat counts whose literal expansion stays within TypeScript's instantiation depth limit.
|
|
12
|
+
*/
|
|
13
|
+
type SafeRepeatCount = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45;
|
|
10
14
|
/**
|
|
11
15
|
* Internal type for implementing string slicing with both start and end indices.
|
|
12
16
|
* Handles edge cases and type safety for string literal types.
|
|
@@ -174,13 +178,14 @@ type PadStart<T extends string, Times extends number = 0, Pad extends string = "
|
|
|
174
178
|
/**
|
|
175
179
|
* Type-level implementation of string.repeat() functionality.
|
|
176
180
|
* Creates a new string type by repeating the input string a specified number of times.
|
|
181
|
+
* Counts above 45 fall back to `string` to avoid TypeScript's type-instantiation depth limit (TS2589).
|
|
177
182
|
* @template T - The string type to repeat
|
|
178
183
|
* @template Times - The number of times to repeat the string
|
|
179
184
|
* @returns A string type containing T repeated Times times
|
|
180
185
|
* @example
|
|
181
186
|
* type Repeated = Repeat<'abc', 2> // type Repeated = 'abcabc'
|
|
182
187
|
*/
|
|
183
|
-
type Repeat<T extends string, Times extends number = 0> = All<[IsStringLiteral<T>, IsNumberLiteral<Times>]> extends true ? Times extends 0 ? "" : Math.IsNegative<Times> extends false ? Join<TupleOf<Times, T>> : never : string;
|
|
188
|
+
type Repeat<T extends string, Times extends number = 0> = T extends T ? All<[IsStringLiteral<T>, IsNumberLiteral<Times>]> extends true ? Times extends 0 ? "" : Math.IsNegative<Times> extends false ? Times extends SafeRepeatCount ? Join<TupleOf<Times, T>> : string : never : string : never;
|
|
184
189
|
/**
|
|
185
190
|
* Type-level implementation of string.replaceAll() functionality.
|
|
186
191
|
* Replaces all occurrences of a substring with another string.
|
package/dist/replace-string.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OptionReplaceArray, e as IntervalArray } from "./packem_shared/types.d-
|
|
1
|
+
import { O as OptionReplaceArray, e as IntervalArray } from "./packem_shared/types.d-Bky9TnxG.js";
|
|
2
2
|
/**
|
|
3
3
|
* Performs multiple string or RegExp replacements using a refined pre-processing approach.
|
|
4
4
|
* @param source The string to search and replace in.
|
package/dist/slugify.d.ts
CHANGED
package/dist/transliterate.d.ts
CHANGED
package/dist/utilities.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/string",
|
|
3
|
-
"version": "3.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.1.2",
|
|
4
|
+
"description": "Type-safe string utilities: case conversion, slugify, truncation, alignment and CJK-aware width.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"align",
|
|
7
7
|
"align-text",
|