@visulima/string 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.
- package/CHANGELOG.md +5 -0
- package/LICENSE.md +77 -0
- package/README.md +880 -0
- package/dist/case/camel-case.cjs +59 -0
- package/dist/case/camel-case.d.cts +7 -0
- package/dist/case/camel-case.d.mts +7 -0
- package/dist/case/camel-case.d.ts +7 -0
- package/dist/case/camel-case.mjs +57 -0
- package/dist/case/capital-case.cjs +51 -0
- package/dist/case/capital-case.d.cts +7 -0
- package/dist/case/capital-case.d.mts +7 -0
- package/dist/case/capital-case.d.ts +7 -0
- package/dist/case/capital-case.mjs +49 -0
- package/dist/case/constant-case.cjs +11 -0
- package/dist/case/constant-case.d.cts +7 -0
- package/dist/case/constant-case.d.mts +7 -0
- package/dist/case/constant-case.d.ts +7 -0
- package/dist/case/constant-case.mjs +9 -0
- package/dist/case/dot-case.cjs +11 -0
- package/dist/case/dot-case.d.cts +7 -0
- package/dist/case/dot-case.d.mts +7 -0
- package/dist/case/dot-case.d.ts +7 -0
- package/dist/case/dot-case.mjs +9 -0
- package/dist/case/flat-case.cjs +11 -0
- package/dist/case/flat-case.d.cts +7 -0
- package/dist/case/flat-case.d.mts +7 -0
- package/dist/case/flat-case.d.ts +7 -0
- package/dist/case/flat-case.mjs +9 -0
- package/dist/case/flip-case.cjs +61 -0
- package/dist/case/flip-case.d.cts +8 -0
- package/dist/case/flip-case.d.mts +8 -0
- package/dist/case/flip-case.d.ts +8 -0
- package/dist/case/flip-case.mjs +57 -0
- package/dist/case/identify-case.cjs +30 -0
- package/dist/case/identify-case.d.cts +7 -0
- package/dist/case/identify-case.d.mts +7 -0
- package/dist/case/identify-case.d.ts +7 -0
- package/dist/case/identify-case.mjs +28 -0
- package/dist/case/index.cjs +47 -0
- package/dist/case/index.d.cts +26 -0
- package/dist/case/index.d.mts +26 -0
- package/dist/case/index.d.ts +26 -0
- package/dist/case/index.mjs +20 -0
- package/dist/case/kebab-case.cjs +61 -0
- package/dist/case/kebab-case.d.cts +11 -0
- package/dist/case/kebab-case.d.mts +11 -0
- package/dist/case/kebab-case.d.ts +11 -0
- package/dist/case/kebab-case.mjs +57 -0
- package/dist/case/lower-first.cjs +13 -0
- package/dist/case/lower-first.d.cts +7 -0
- package/dist/case/lower-first.d.mts +7 -0
- package/dist/case/lower-first.d.ts +7 -0
- package/dist/case/lower-first.mjs +11 -0
- package/dist/case/no-case.cjs +11 -0
- package/dist/case/no-case.d.cts +7 -0
- package/dist/case/no-case.d.mts +7 -0
- package/dist/case/no-case.d.ts +7 -0
- package/dist/case/no-case.mjs +9 -0
- package/dist/case/pascal-case.cjs +52 -0
- package/dist/case/pascal-case.d.cts +7 -0
- package/dist/case/pascal-case.d.mts +7 -0
- package/dist/case/pascal-case.d.ts +7 -0
- package/dist/case/pascal-case.mjs +50 -0
- package/dist/case/pascal-snake-case.cjs +32 -0
- package/dist/case/pascal-snake-case.d.cts +7 -0
- package/dist/case/pascal-snake-case.d.mts +7 -0
- package/dist/case/pascal-snake-case.d.ts +7 -0
- package/dist/case/pascal-snake-case.mjs +30 -0
- package/dist/case/path-case.cjs +11 -0
- package/dist/case/path-case.d.cts +7 -0
- package/dist/case/path-case.d.mts +7 -0
- package/dist/case/path-case.d.ts +7 -0
- package/dist/case/path-case.mjs +9 -0
- package/dist/case/sentence-case.cjs +58 -0
- package/dist/case/sentence-case.d.cts +7 -0
- package/dist/case/sentence-case.d.mts +7 -0
- package/dist/case/sentence-case.d.ts +7 -0
- package/dist/case/sentence-case.mjs +56 -0
- package/dist/case/snake-case.cjs +11 -0
- package/dist/case/snake-case.d.cts +7 -0
- package/dist/case/snake-case.d.mts +7 -0
- package/dist/case/snake-case.d.ts +7 -0
- package/dist/case/snake-case.mjs +9 -0
- package/dist/case/split-by-case.cjs +638 -0
- package/dist/case/split-by-case.d.cts +16 -0
- package/dist/case/split-by-case.d.mts +16 -0
- package/dist/case/split-by-case.d.ts +16 -0
- package/dist/case/split-by-case.mjs +634 -0
- package/dist/case/title-case.cjs +47 -0
- package/dist/case/title-case.d.cts +7 -0
- package/dist/case/title-case.d.mts +7 -0
- package/dist/case/title-case.d.ts +7 -0
- package/dist/case/title-case.mjs +45 -0
- package/dist/case/train-case.cjs +44 -0
- package/dist/case/train-case.d.cts +7 -0
- package/dist/case/train-case.d.mts +7 -0
- package/dist/case/train-case.d.ts +7 -0
- package/dist/case/train-case.mjs +42 -0
- package/dist/case/upper-first.cjs +13 -0
- package/dist/case/upper-first.d.cts +7 -0
- package/dist/case/upper-first.d.mts +7 -0
- package/dist/case/upper-first.d.ts +7 -0
- package/dist/case/upper-first.mjs +11 -0
- package/dist/get-string-truncated-width.cjs +386 -0
- package/dist/get-string-truncated-width.d.cts +25 -0
- package/dist/get-string-truncated-width.d.mts +25 -0
- package/dist/get-string-truncated-width.d.ts +25 -0
- package/dist/get-string-truncated-width.mjs +382 -0
- package/dist/get-string-width.cjs +11 -0
- package/dist/get-string-width.d.cts +6 -0
- package/dist/get-string-width.d.mts +6 -0
- package/dist/get-string-width.d.ts +6 -0
- package/dist/get-string-width.mjs +7 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.mts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.mjs +26 -0
- package/dist/native-string-types.d.cts +128 -0
- package/dist/native-string-types.d.mts +128 -0
- package/dist/native-string-types.d.ts +128 -0
- package/dist/outdent.cjs +122 -0
- package/dist/outdent.d.cts +15 -0
- package/dist/outdent.d.mts +15 -0
- package/dist/outdent.d.ts +15 -0
- package/dist/outdent.mjs +118 -0
- package/dist/packem_shared/LRUCache-Crb-m7cw.cjs +53 -0
- package/dist/packem_shared/LRUCache-udNErhWw.mjs +51 -0
- package/dist/packem_shared/WrapMode-BgOOthJV.mjs +545 -0
- package/dist/packem_shared/WrapMode-ZqTeXK8X.cjs +550 -0
- package/dist/packem_shared/constants-BnVGLrDr.mjs +99 -0
- package/dist/packem_shared/constants-HevSYUjU.cjs +149 -0
- package/dist/packem_shared/generate-cache-key-D8f1auDB.cjs +10 -0
- package/dist/packem_shared/generate-cache-key-YSju5pj2.mjs +8 -0
- package/dist/packem_shared/joinSegments-BH1CT4dK.cjs +48 -0
- package/dist/packem_shared/joinSegments-BHY8PPnk.mjs +46 -0
- package/dist/packem_shared/normalize-german-eszett-DJK0S2qj.cjs +11 -0
- package/dist/packem_shared/normalize-german-eszett-fpJ4lZL6.mjs +9 -0
- package/dist/packem_shared/types-BAd3WDHo.d.mts +59 -0
- package/dist/packem_shared/types-BNbQJg02.d.cts +41 -0
- package/dist/packem_shared/types-BNbQJg02.d.mts +41 -0
- package/dist/packem_shared/types-BNbQJg02.d.ts +41 -0
- package/dist/packem_shared/types-BttWSSIk.d.ts +59 -0
- package/dist/packem_shared/types-D2-6p7t1.d.cts +59 -0
- package/dist/slice.cjs +413 -0
- package/dist/slice.d.cts +10 -0
- package/dist/slice.d.mts +10 -0
- package/dist/slice.d.ts +10 -0
- package/dist/slice.mjs +409 -0
- package/dist/test/utils.cjs +77 -0
- package/dist/test/utils.d.cts +30 -0
- package/dist/test/utils.d.mts +30 -0
- package/dist/test/utils.d.ts +30 -0
- package/dist/test/utils.mjs +71 -0
- package/dist/test/vitest.cjs +11 -0
- package/dist/test/vitest.d.cts +8 -0
- package/dist/test/vitest.d.mts +8 -0
- package/dist/test/vitest.d.ts +8 -0
- package/dist/test/vitest.mjs +7 -0
- package/dist/truncate.cjs +90 -0
- package/dist/truncate.d.cts +12 -0
- package/dist/truncate.d.mts +12 -0
- package/dist/truncate.d.ts +12 -0
- package/dist/truncate.mjs +86 -0
- package/dist/utils.cjs +9 -0
- package/dist/utils.d.cts +14 -0
- package/dist/utils.d.mts +14 -0
- package/dist/utils.d.ts +14 -0
- package/dist/utils.mjs +1 -0
- package/package.json +468 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { default as camelCase } from './case/camel-case.mjs';
|
|
2
|
+
export { default as capitalCase } from './case/capital-case.mjs';
|
|
3
|
+
export { default as constantCase } from './case/constant-case.mjs';
|
|
4
|
+
export { default as dotCase } from './case/dot-case.mjs';
|
|
5
|
+
export { default as flatCase } from './case/flat-case.mjs';
|
|
6
|
+
export { flipCase } from './case/flip-case.mjs';
|
|
7
|
+
export { default as identifyCase } from './case/identify-case.mjs';
|
|
8
|
+
export { kebabCase } from './case/kebab-case.mjs';
|
|
9
|
+
export { default as lowerFirst } from './case/lower-first.mjs';
|
|
10
|
+
export { default as noCase } from './case/no-case.mjs';
|
|
11
|
+
export { default as pascalCase } from './case/pascal-case.mjs';
|
|
12
|
+
export { default as pascalSnakeCase } from './case/pascal-snake-case.mjs';
|
|
13
|
+
export { default as pathCase } from './case/path-case.mjs';
|
|
14
|
+
export { default as sentenceCase } from './case/sentence-case.mjs';
|
|
15
|
+
export { default as snakeCase } from './case/snake-case.mjs';
|
|
16
|
+
export { splitByCase } from './case/split-by-case.mjs';
|
|
17
|
+
export { default as titleCase } from './case/title-case.mjs';
|
|
18
|
+
export { default as trainCase } from './case/train-case.mjs';
|
|
19
|
+
export { default as upperFirst } from './case/upper-first.mjs';
|
|
20
|
+
export { default as joinSegments } from './packem_shared/joinSegments-BHY8PPnk.mjs';
|
|
21
|
+
export { getStringTruncatedWidth } from './get-string-truncated-width.mjs';
|
|
22
|
+
export { getStringWidth } from './get-string-width.mjs';
|
|
23
|
+
export { outdent } from './outdent.mjs';
|
|
24
|
+
export { slice } from './slice.mjs';
|
|
25
|
+
export { truncate } from './truncate.mjs';
|
|
26
|
+
export { WrapMode, wordWrap } from './packem_shared/WrapMode-BgOOthJV.mjs';
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { C as CharAt, a as Concat, E as EndsWith, I as Includes, L as Length, P as PadEnd, b as PadStart, R as Replace, c as ReplaceAll, S as Slice, d as Split, e as StartsWith, T as ToLowerCase, f as ToUpperCase, g as Trim, h as TrimEnd, i as TrimStart } from './packem_shared/types-BNbQJg02.cjs';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface String {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the character at the specified index.
|
|
7
|
+
* @param index The zero-based index of the desired character.
|
|
8
|
+
*/
|
|
9
|
+
charAt<T extends string = string, I extends number = number>(this: T, index: I): CharAt<T, I>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns a string that contains the concatenation of two or more strings.
|
|
13
|
+
* @param strings The strings to append to the end of the string.
|
|
14
|
+
*/
|
|
15
|
+
concat<T extends string = string, S extends string[] | string = string>(
|
|
16
|
+
this: T,
|
|
17
|
+
...strings: S extends string ? [S] : S extends string[] ? S : never
|
|
18
|
+
): S extends string ? Concat<[T, S]> : S extends string[] ? Concat<[T, ...S]> : never;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
22
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
23
|
+
* position. Otherwise returns false.
|
|
24
|
+
*/
|
|
25
|
+
endsWith<T extends string = string, S extends string = string, P extends number | undefined = undefined>(
|
|
26
|
+
this: T,
|
|
27
|
+
searchString: S,
|
|
28
|
+
position?: P,
|
|
29
|
+
): EndsWith<T, S, P>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if searchString appears as a substring of the result of converting this
|
|
33
|
+
* object to a String, at one or more positions that are greater than or equal to
|
|
34
|
+
* position; otherwise, returns false.
|
|
35
|
+
* @param searchString search string
|
|
36
|
+
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
|
37
|
+
*/
|
|
38
|
+
includes<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): Includes<T, S, P>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the length of a String object.
|
|
42
|
+
*/
|
|
43
|
+
length: Length<this>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
47
|
+
* The padding is applied from the end (right) of the current string.
|
|
48
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
49
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
50
|
+
*/
|
|
51
|
+
padEnd<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadEnd<T, N, P>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
55
|
+
* The padding is applied from the start (left) of the current string.
|
|
56
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
57
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
58
|
+
*/
|
|
59
|
+
padStart<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadStart<T, N, P>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Replace text in a string, using a regular expression or search string.
|
|
63
|
+
* @param searchValue A string to search for.
|
|
64
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
65
|
+
*/
|
|
66
|
+
replace<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
67
|
+
this: T,
|
|
68
|
+
searchValue: S,
|
|
69
|
+
replaceValue: R,
|
|
70
|
+
): Replace<T, S, R>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Replace all instances of a substring in a string, using a regular expression or search string.
|
|
74
|
+
* @param searchValue A string to search for.
|
|
75
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
76
|
+
*/
|
|
77
|
+
replaceAll<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
78
|
+
this: T,
|
|
79
|
+
searchValue: S,
|
|
80
|
+
replaceValue: R,
|
|
81
|
+
): ReplaceAll<T, S, R>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns a section of a string.
|
|
85
|
+
* @param start The index to the beginning of the specified portion of stringObj.
|
|
86
|
+
* @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
|
|
87
|
+
*/
|
|
88
|
+
slice<T extends string = string, S extends number = number, E extends number | undefined = undefined>(this: T, start?: S, end?: E): Slice<T, S, E>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Split a string into substrings using the specified separator and return them as an array.
|
|
92
|
+
* @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
|
|
93
|
+
*/
|
|
94
|
+
split<T extends string = string, S extends string = string>(this: T, separator: S): Split<T, S>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
98
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
99
|
+
* position. Otherwise returns false.
|
|
100
|
+
*/
|
|
101
|
+
startsWith<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): StartsWith<T, S, P>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Converts all alphabetic characters in a string to lowercase.
|
|
105
|
+
*/
|
|
106
|
+
toLowerCase<T extends string = string>(this: T): ToLowerCase<T>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts all alphabetic characters in a string to uppercase.
|
|
110
|
+
*/
|
|
111
|
+
toUpperCase<T extends string = string>(this: T): ToUpperCase<T>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a string with all whitespace removed from both ends of a string.
|
|
115
|
+
*/
|
|
116
|
+
trim<T extends string = string>(this: T): Trim<T>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns a string with all whitespace removed from the end of a string.
|
|
120
|
+
*/
|
|
121
|
+
trimEnd<T extends string = string>(this: T): TrimEnd<T>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Returns a string with all whitespace removed from the start of a string.
|
|
125
|
+
*/
|
|
126
|
+
trimStart<T extends string = string>(this: T): TrimStart<T>;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { C as CharAt, a as Concat, E as EndsWith, I as Includes, L as Length, P as PadEnd, b as PadStart, R as Replace, c as ReplaceAll, S as Slice, d as Split, e as StartsWith, T as ToLowerCase, f as ToUpperCase, g as Trim, h as TrimEnd, i as TrimStart } from './packem_shared/types-BNbQJg02.mjs';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface String {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the character at the specified index.
|
|
7
|
+
* @param index The zero-based index of the desired character.
|
|
8
|
+
*/
|
|
9
|
+
charAt<T extends string = string, I extends number = number>(this: T, index: I): CharAt<T, I>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns a string that contains the concatenation of two or more strings.
|
|
13
|
+
* @param strings The strings to append to the end of the string.
|
|
14
|
+
*/
|
|
15
|
+
concat<T extends string = string, S extends string[] | string = string>(
|
|
16
|
+
this: T,
|
|
17
|
+
...strings: S extends string ? [S] : S extends string[] ? S : never
|
|
18
|
+
): S extends string ? Concat<[T, S]> : S extends string[] ? Concat<[T, ...S]> : never;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
22
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
23
|
+
* position. Otherwise returns false.
|
|
24
|
+
*/
|
|
25
|
+
endsWith<T extends string = string, S extends string = string, P extends number | undefined = undefined>(
|
|
26
|
+
this: T,
|
|
27
|
+
searchString: S,
|
|
28
|
+
position?: P,
|
|
29
|
+
): EndsWith<T, S, P>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if searchString appears as a substring of the result of converting this
|
|
33
|
+
* object to a String, at one or more positions that are greater than or equal to
|
|
34
|
+
* position; otherwise, returns false.
|
|
35
|
+
* @param searchString search string
|
|
36
|
+
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
|
37
|
+
*/
|
|
38
|
+
includes<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): Includes<T, S, P>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the length of a String object.
|
|
42
|
+
*/
|
|
43
|
+
length: Length<this>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
47
|
+
* The padding is applied from the end (right) of the current string.
|
|
48
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
49
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
50
|
+
*/
|
|
51
|
+
padEnd<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadEnd<T, N, P>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
55
|
+
* The padding is applied from the start (left) of the current string.
|
|
56
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
57
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
58
|
+
*/
|
|
59
|
+
padStart<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadStart<T, N, P>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Replace text in a string, using a regular expression or search string.
|
|
63
|
+
* @param searchValue A string to search for.
|
|
64
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
65
|
+
*/
|
|
66
|
+
replace<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
67
|
+
this: T,
|
|
68
|
+
searchValue: S,
|
|
69
|
+
replaceValue: R,
|
|
70
|
+
): Replace<T, S, R>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Replace all instances of a substring in a string, using a regular expression or search string.
|
|
74
|
+
* @param searchValue A string to search for.
|
|
75
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
76
|
+
*/
|
|
77
|
+
replaceAll<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
78
|
+
this: T,
|
|
79
|
+
searchValue: S,
|
|
80
|
+
replaceValue: R,
|
|
81
|
+
): ReplaceAll<T, S, R>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns a section of a string.
|
|
85
|
+
* @param start The index to the beginning of the specified portion of stringObj.
|
|
86
|
+
* @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
|
|
87
|
+
*/
|
|
88
|
+
slice<T extends string = string, S extends number = number, E extends number | undefined = undefined>(this: T, start?: S, end?: E): Slice<T, S, E>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Split a string into substrings using the specified separator and return them as an array.
|
|
92
|
+
* @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
|
|
93
|
+
*/
|
|
94
|
+
split<T extends string = string, S extends string = string>(this: T, separator: S): Split<T, S>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
98
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
99
|
+
* position. Otherwise returns false.
|
|
100
|
+
*/
|
|
101
|
+
startsWith<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): StartsWith<T, S, P>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Converts all alphabetic characters in a string to lowercase.
|
|
105
|
+
*/
|
|
106
|
+
toLowerCase<T extends string = string>(this: T): ToLowerCase<T>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts all alphabetic characters in a string to uppercase.
|
|
110
|
+
*/
|
|
111
|
+
toUpperCase<T extends string = string>(this: T): ToUpperCase<T>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a string with all whitespace removed from both ends of a string.
|
|
115
|
+
*/
|
|
116
|
+
trim<T extends string = string>(this: T): Trim<T>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns a string with all whitespace removed from the end of a string.
|
|
120
|
+
*/
|
|
121
|
+
trimEnd<T extends string = string>(this: T): TrimEnd<T>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Returns a string with all whitespace removed from the start of a string.
|
|
125
|
+
*/
|
|
126
|
+
trimStart<T extends string = string>(this: T): TrimStart<T>;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { C as CharAt, a as Concat, E as EndsWith, I as Includes, L as Length, P as PadEnd, b as PadStart, R as Replace, c as ReplaceAll, S as Slice, d as Split, e as StartsWith, T as ToLowerCase, f as ToUpperCase, g as Trim, h as TrimEnd, i as TrimStart } from './packem_shared/types-BNbQJg02.js';
|
|
2
|
+
|
|
3
|
+
declare global {
|
|
4
|
+
interface String {
|
|
5
|
+
/**
|
|
6
|
+
* Returns the character at the specified index.
|
|
7
|
+
* @param index The zero-based index of the desired character.
|
|
8
|
+
*/
|
|
9
|
+
charAt<T extends string = string, I extends number = number>(this: T, index: I): CharAt<T, I>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Returns a string that contains the concatenation of two or more strings.
|
|
13
|
+
* @param strings The strings to append to the end of the string.
|
|
14
|
+
*/
|
|
15
|
+
concat<T extends string = string, S extends string[] | string = string>(
|
|
16
|
+
this: T,
|
|
17
|
+
...strings: S extends string ? [S] : S extends string[] ? S : never
|
|
18
|
+
): S extends string ? Concat<[T, S]> : S extends string[] ? Concat<[T, ...S]> : never;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
22
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
23
|
+
* position. Otherwise returns false.
|
|
24
|
+
*/
|
|
25
|
+
endsWith<T extends string = string, S extends string = string, P extends number | undefined = undefined>(
|
|
26
|
+
this: T,
|
|
27
|
+
searchString: S,
|
|
28
|
+
position?: P,
|
|
29
|
+
): EndsWith<T, S, P>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if searchString appears as a substring of the result of converting this
|
|
33
|
+
* object to a String, at one or more positions that are greater than or equal to
|
|
34
|
+
* position; otherwise, returns false.
|
|
35
|
+
* @param searchString search string
|
|
36
|
+
* @param position If position is undefined, 0 is assumed, so as to search all of the String.
|
|
37
|
+
*/
|
|
38
|
+
includes<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): Includes<T, S, P>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the length of a String object.
|
|
42
|
+
*/
|
|
43
|
+
length: Length<this>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
47
|
+
* The padding is applied from the end (right) of the current string.
|
|
48
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
49
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
50
|
+
*/
|
|
51
|
+
padEnd<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadEnd<T, N, P>;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length.
|
|
55
|
+
* The padding is applied from the start (left) of the current string.
|
|
56
|
+
* @param maxLength The length of the resulting string once the current string has been padded.
|
|
57
|
+
* @param fillString The string to pad the current string with. If this string is too long, it will be truncated and the left-most part will be applied.
|
|
58
|
+
*/
|
|
59
|
+
padStart<T extends string = string, N extends number = number, P extends string = " ">(this: T, maxLength: N, fillString?: P): PadStart<T, N, P>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Replace text in a string, using a regular expression or search string.
|
|
63
|
+
* @param searchValue A string to search for.
|
|
64
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
65
|
+
*/
|
|
66
|
+
replace<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
67
|
+
this: T,
|
|
68
|
+
searchValue: S,
|
|
69
|
+
replaceValue: R,
|
|
70
|
+
): Replace<T, S, R>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Replace all instances of a substring in a string, using a regular expression or search string.
|
|
74
|
+
* @param searchValue A string to search for.
|
|
75
|
+
* @param replaceValue A string containing the text to replace for every successful match of searchValue in this string.
|
|
76
|
+
*/
|
|
77
|
+
replaceAll<T extends string = string, S extends RegExp | string = string, R extends string = string>(
|
|
78
|
+
this: T,
|
|
79
|
+
searchValue: S,
|
|
80
|
+
replaceValue: R,
|
|
81
|
+
): ReplaceAll<T, S, R>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns a section of a string.
|
|
85
|
+
* @param start The index to the beginning of the specified portion of stringObj.
|
|
86
|
+
* @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end.
|
|
87
|
+
*/
|
|
88
|
+
slice<T extends string = string, S extends number = number, E extends number | undefined = undefined>(this: T, start?: S, end?: E): Slice<T, S, E>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Split a string into substrings using the specified separator and return them as an array.
|
|
92
|
+
* @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned.
|
|
93
|
+
*/
|
|
94
|
+
split<T extends string = string, S extends string = string>(this: T, separator: S): Split<T, S>;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns true if the sequence of elements of searchString converted to a String is the
|
|
98
|
+
* same as the corresponding elements of this object (converted to a String) starting at
|
|
99
|
+
* position. Otherwise returns false.
|
|
100
|
+
*/
|
|
101
|
+
startsWith<T extends string = string, S extends string = string, P extends number = 0>(this: T, searchString: S, position?: P): StartsWith<T, S, P>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Converts all alphabetic characters in a string to lowercase.
|
|
105
|
+
*/
|
|
106
|
+
toLowerCase<T extends string = string>(this: T): ToLowerCase<T>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Converts all alphabetic characters in a string to uppercase.
|
|
110
|
+
*/
|
|
111
|
+
toUpperCase<T extends string = string>(this: T): ToUpperCase<T>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Returns a string with all whitespace removed from both ends of a string.
|
|
115
|
+
*/
|
|
116
|
+
trim<T extends string = string>(this: T): Trim<T>;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Returns a string with all whitespace removed from the end of a string.
|
|
120
|
+
*/
|
|
121
|
+
trimEnd<T extends string = string>(this: T): TrimEnd<T>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Returns a string with all whitespace removed from the start of a string.
|
|
125
|
+
*/
|
|
126
|
+
trimStart<T extends string = string>(this: T): TrimStart<T>;
|
|
127
|
+
}
|
|
128
|
+
}
|
package/dist/outdent.cjs
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const constants = require('./packem_shared/constants-HevSYUjU.cjs');
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
+
const hop = Object.prototype.hasOwnProperty;
|
|
10
|
+
const has = /* @__PURE__ */ __name((object, property) => hop.call(object, property), "has");
|
|
11
|
+
const extend = /* @__PURE__ */ __name((target, source) => {
|
|
12
|
+
for (const property in source) {
|
|
13
|
+
if (has(source, property)) {
|
|
14
|
+
target[property] = source[property];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
|
+
}, "extend");
|
|
19
|
+
const internalOutdentArray = /* @__PURE__ */ __name((strings, firstInterpolatedValueSetsIndentationLevel, options) => {
|
|
20
|
+
if (strings.length === 0) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
let indentationLevel = 0;
|
|
24
|
+
const match = constants.RE_DETECT_INDENTATION.exec(strings[0]);
|
|
25
|
+
if (match) {
|
|
26
|
+
indentationLevel = match[1].length;
|
|
27
|
+
}
|
|
28
|
+
const reSource = `(\\r\\n|\\r|\\n).{0,${indentationLevel}}`;
|
|
29
|
+
const reMatchIndent = new RegExp(reSource, "g");
|
|
30
|
+
if (firstInterpolatedValueSetsIndentationLevel) {
|
|
31
|
+
strings = strings.slice(1);
|
|
32
|
+
}
|
|
33
|
+
const { newline, trimLeadingNewline, trimTrailingNewline } = options;
|
|
34
|
+
const normalizeNewlines = typeof newline === "string";
|
|
35
|
+
const l = strings.length;
|
|
36
|
+
const outdentedStrings = Array.from({ length: l });
|
|
37
|
+
for (let index = 0; index < l; index++) {
|
|
38
|
+
let v = strings[index];
|
|
39
|
+
v = v.replace(reMatchIndent, "$1");
|
|
40
|
+
if (index === 0 && trimLeadingNewline) {
|
|
41
|
+
v = v.replace(constants.RE_LEADING_NEWLINE, "");
|
|
42
|
+
}
|
|
43
|
+
if (index === l - 1 && trimTrailingNewline) {
|
|
44
|
+
v = v.replace(constants.RE_TRAILING_NEWLINE, "");
|
|
45
|
+
}
|
|
46
|
+
if (normalizeNewlines) {
|
|
47
|
+
v = v.replaceAll(constants.RE_MATCH_NEWLINES, newline);
|
|
48
|
+
}
|
|
49
|
+
outdentedStrings[index] = v;
|
|
50
|
+
}
|
|
51
|
+
return outdentedStrings;
|
|
52
|
+
}, "internalOutdentArray");
|
|
53
|
+
const concatStringsAndValues = /* @__PURE__ */ __name((strings, values) => {
|
|
54
|
+
const chunks = Array.from({ length: strings.length + values.length });
|
|
55
|
+
let index = 0;
|
|
56
|
+
const l = strings.length;
|
|
57
|
+
for (; index < l - 1; index++) {
|
|
58
|
+
chunks[index * 2] = strings[index];
|
|
59
|
+
chunks[index * 2 + 1] = String(values[index]);
|
|
60
|
+
}
|
|
61
|
+
chunks[index * 2] = strings[index];
|
|
62
|
+
return chunks.join("");
|
|
63
|
+
}, "concatStringsAndValues");
|
|
64
|
+
const isTemplateStringsArray = /* @__PURE__ */ __name((v) => has(v, "raw") && has(v, "length"), "isTemplateStringsArray");
|
|
65
|
+
const templateCache = /* @__PURE__ */ new WeakMap();
|
|
66
|
+
const createInstance = /* @__PURE__ */ __name((options) => {
|
|
67
|
+
const enableCache = options.cache !== false;
|
|
68
|
+
const cache = enableCache ? options.cacheStore ?? templateCache : null;
|
|
69
|
+
const hasNewlineOption = options.newline !== void 0;
|
|
70
|
+
function outdent2(stringsOrOptions, ...values) {
|
|
71
|
+
if (isTemplateStringsArray(stringsOrOptions)) {
|
|
72
|
+
const strings = stringsOrOptions;
|
|
73
|
+
const valuesLength = values.length;
|
|
74
|
+
if (strings.length === 1 && strings[0] === "") {
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
if (valuesLength === 0) {
|
|
78
|
+
if (enableCache && cache && !hasNewlineOption) {
|
|
79
|
+
const cached = cache.get(strings);
|
|
80
|
+
if (cached) {
|
|
81
|
+
return cached[0];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const result = internalOutdentArray(strings, false, options);
|
|
85
|
+
if (enableCache && cache) {
|
|
86
|
+
cache.set(strings, result);
|
|
87
|
+
}
|
|
88
|
+
return result[0];
|
|
89
|
+
}
|
|
90
|
+
const firstValueIsOutdent = values[0] === outdent2 || values[0] === defaultOutdent;
|
|
91
|
+
const firstInterpolatedValueSetsIndentationLevel = firstValueIsOutdent && constants.RE_ONLY_WHITESPACE_WITH_AT_LEAST_ONE_NEWLINE.test(strings[0]) && constants.RE_STARTS_WITH_NEWLINE_OR_IS_EMPTY.test(strings[1]);
|
|
92
|
+
let renderedArray;
|
|
93
|
+
if (enableCache && cache && !hasNewlineOption) {
|
|
94
|
+
renderedArray = cache.get(strings);
|
|
95
|
+
}
|
|
96
|
+
if (!renderedArray) {
|
|
97
|
+
renderedArray = internalOutdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
|
|
98
|
+
if (enableCache && cache) {
|
|
99
|
+
cache.set(strings, renderedArray);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
|
|
103
|
+
}
|
|
104
|
+
return createInstance(extend(extend({}, options), stringsOrOptions));
|
|
105
|
+
}
|
|
106
|
+
__name(outdent2, "outdent");
|
|
107
|
+
return extend(outdent2, {
|
|
108
|
+
string(string_) {
|
|
109
|
+
if (string_ === "" || !string_) {
|
|
110
|
+
return "";
|
|
111
|
+
}
|
|
112
|
+
return internalOutdentArray([string_], false, options)[0];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}, "createInstance");
|
|
116
|
+
const defaultOutdent = createInstance({
|
|
117
|
+
trimLeadingNewline: true,
|
|
118
|
+
trimTrailingNewline: true
|
|
119
|
+
});
|
|
120
|
+
const outdent = defaultOutdent;
|
|
121
|
+
|
|
122
|
+
exports.outdent = outdent;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const outdent: Outdent;
|
|
2
|
+
interface Outdent {
|
|
3
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
4
|
+
(options: Options): Outdent;
|
|
5
|
+
string: (string_: string) => string;
|
|
6
|
+
}
|
|
7
|
+
interface Options {
|
|
8
|
+
cache?: boolean;
|
|
9
|
+
cacheStore?: WeakMap<TemplateStringsArray, string[]>;
|
|
10
|
+
newline?: string | null;
|
|
11
|
+
trimLeadingNewline?: boolean;
|
|
12
|
+
trimTrailingNewline?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { type Options, type Outdent, outdent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const outdent: Outdent;
|
|
2
|
+
interface Outdent {
|
|
3
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
4
|
+
(options: Options): Outdent;
|
|
5
|
+
string: (string_: string) => string;
|
|
6
|
+
}
|
|
7
|
+
interface Options {
|
|
8
|
+
cache?: boolean;
|
|
9
|
+
cacheStore?: WeakMap<TemplateStringsArray, string[]>;
|
|
10
|
+
newline?: string | null;
|
|
11
|
+
trimLeadingNewline?: boolean;
|
|
12
|
+
trimTrailingNewline?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { type Options, type Outdent, outdent };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const outdent: Outdent;
|
|
2
|
+
interface Outdent {
|
|
3
|
+
(strings: TemplateStringsArray, ...values: any[]): string;
|
|
4
|
+
(options: Options): Outdent;
|
|
5
|
+
string: (string_: string) => string;
|
|
6
|
+
}
|
|
7
|
+
interface Options {
|
|
8
|
+
cache?: boolean;
|
|
9
|
+
cacheStore?: WeakMap<TemplateStringsArray, string[]>;
|
|
10
|
+
newline?: string | null;
|
|
11
|
+
trimLeadingNewline?: boolean;
|
|
12
|
+
trimTrailingNewline?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { type Options, type Outdent, outdent };
|