@ls-stack/utils 3.39.0 → 3.41.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/dist/arrayUtils.d.cts +70 -57
- package/dist/arrayUtils.d.ts +70 -57
- package/dist/assertions.d.cts +128 -117
- package/dist/assertions.d.ts +128 -117
- package/dist/asyncQueue.cjs +117 -112
- package/dist/asyncQueue.d.cts +217 -215
- package/dist/asyncQueue.d.ts +217 -215
- package/dist/asyncQueue.js +117 -112
- package/dist/awaitDebounce.d.cts +26 -23
- package/dist/awaitDebounce.d.ts +26 -23
- package/dist/cache.cjs +2 -1
- package/dist/cache.d.cts +15 -9
- package/dist/cache.d.ts +15 -9
- package/dist/cache.js +2 -1
- package/dist/{chunk-GHAQOUA6.js → chunk-23KPGKDT.js} +22 -1
- package/dist/{chunk-ADM37GSC.js → chunk-7L4KCZJJ.js} +12 -10
- package/dist/{chunk-KW55OTUG.js → chunk-B3KFV2MH.js} +2 -2
- package/dist/chunk-DTE2QMWE.js +48 -0
- package/dist/concurrentCalls.d.cts +8 -4
- package/dist/concurrentCalls.d.ts +8 -4
- package/dist/concurrentCalls.js +1 -1
- package/dist/consoleFmt.cjs +1 -0
- package/dist/consoleFmt.d.cts +6 -0
- package/dist/consoleFmt.d.ts +6 -0
- package/dist/consoleFmt.js +1 -0
- package/dist/debounce.d.cts +12 -20
- package/dist/debounce.d.ts +12 -20
- package/dist/dedent.d.cts +31 -31
- package/dist/dedent.d.ts +31 -31
- package/dist/deepEqual.d.cts +10 -9
- package/dist/deepEqual.d.ts +10 -9
- package/dist/filterObjectOrArrayKeys.d.cts +44 -19
- package/dist/filterObjectOrArrayKeys.d.ts +44 -19
- package/dist/getAutoIncrementId.d.cts +25 -23
- package/dist/getAutoIncrementId.d.ts +25 -23
- package/dist/getCompositeKey.d.cts +2 -1
- package/dist/getCompositeKey.d.ts +2 -1
- package/dist/getValueStableKey.d.cts +4 -3
- package/dist/getValueStableKey.d.ts +4 -3
- package/dist/mutationUtils.d.cts +2 -2
- package/dist/mutationUtils.d.ts +2 -2
- package/dist/objUtils.cjs +51 -2
- package/dist/objUtils.d.cts +8 -3
- package/dist/objUtils.d.ts +8 -3
- package/dist/objUtils.js +11 -3
- package/dist/parallelAsyncCalls.cjs +2 -1
- package/dist/parallelAsyncCalls.d.cts +5 -4
- package/dist/parallelAsyncCalls.d.ts +5 -4
- package/dist/parallelAsyncCalls.js +2 -1
- package/dist/retryOnError.d.cts +23 -20
- package/dist/retryOnError.d.ts +23 -20
- package/dist/runShellCmd.d.cts +40 -40
- package/dist/runShellCmd.d.ts +40 -40
- package/dist/safeJson.d.cts +6 -2
- package/dist/safeJson.d.ts +6 -2
- package/dist/saferTyping.d.cts +21 -14
- package/dist/saferTyping.d.ts +21 -14
- package/dist/shallowEqual.d.cts +1 -1
- package/dist/shallowEqual.d.ts +1 -1
- package/dist/stringUtils.cjs +2 -2
- package/dist/stringUtils.d.cts +6 -7
- package/dist/stringUtils.d.ts +6 -7
- package/dist/stringUtils.js +1 -1
- package/dist/testUtils.cjs +11 -9
- package/dist/testUtils.d.cts +32 -14
- package/dist/testUtils.d.ts +32 -14
- package/dist/testUtils.js +4 -3
- package/dist/throttle.d.cts +57 -48
- package/dist/throttle.d.ts +57 -48
- package/dist/timers.d.cts +68 -63
- package/dist/timers.d.ts +68 -63
- package/dist/tsResult.d.cts +7 -6
- package/dist/tsResult.d.ts +7 -6
- package/dist/typeGuards.d.cts +65 -64
- package/dist/typeGuards.d.ts +65 -64
- package/dist/typeUtils.d.cts +18 -4
- package/dist/typeUtils.d.ts +18 -4
- package/dist/typedStrings.d.cts +68 -57
- package/dist/typedStrings.d.ts +68 -57
- package/dist/typingFnUtils.d.cts +12 -6
- package/dist/typingFnUtils.d.ts +12 -6
- package/dist/typingFnUtils.js +12 -35
- package/dist/typingTestUtils.cjs +7 -1
- package/dist/typingTestUtils.d.cts +52 -11
- package/dist/typingTestUtils.d.ts +52 -11
- package/dist/typingTestUtils.js +7 -1
- package/dist/typingUtils.d.cts +4 -1
- package/dist/typingUtils.d.ts +4 -1
- package/dist/yamlStringify.cjs +11 -9
- package/dist/yamlStringify.js +2 -2
- package/package.json +6 -2
- package/docs/README.md +0 -72
- package/docs/_media/modules.md +0 -58
- package/docs/arrayUtils/-internal-.md +0 -179
- package/docs/arrayUtils/README.md +0 -550
- package/docs/assertions/-internal-.md +0 -63
- package/docs/assertions/README.md +0 -565
- package/docs/asyncQueue/-internal-.md +0 -297
- package/docs/asyncQueue/README.md +0 -1485
- package/docs/awaitDebounce.md +0 -66
- package/docs/cache/-internal-.md +0 -168
- package/docs/cache/README.md +0 -360
- package/docs/castValues.md +0 -47
- package/docs/concurrentCalls/-internal-.md +0 -490
- package/docs/concurrentCalls/README.md +0 -299
- package/docs/consoleFmt.md +0 -91
- package/docs/conversions.md +0 -27
- package/docs/createThrottleController/-internal-.md +0 -73
- package/docs/createThrottleController/README.md +0 -31
- package/docs/debounce.md +0 -188
- package/docs/dedent/-internal-.md +0 -17
- package/docs/dedent/README.md +0 -204
- package/docs/deepEqual.md +0 -94
- package/docs/enhancedMap.md +0 -358
- package/docs/exhaustiveMatch/-internal-.md +0 -39
- package/docs/exhaustiveMatch/README.md +0 -146
- package/docs/filterObjectOrArrayKeys.md +0 -109
- package/docs/getAutoIncrementId.md +0 -93
- package/docs/getCompositeKey.md +0 -39
- package/docs/getValueStableKey.md +0 -57
- package/docs/hash.md +0 -31
- package/docs/interpolate/-internal-.md +0 -61
- package/docs/interpolate/README.md +0 -62
- package/docs/keepPrevIfUnchanged.md +0 -43
- package/docs/levenshtein.md +0 -93
- package/docs/main.md +0 -21
- package/docs/mathUtils.md +0 -137
- package/docs/modules.md +0 -58
- package/docs/mutationUtils.md +0 -44
- package/docs/objUtils.md +0 -237
- package/docs/parallelAsyncCalls/-internal-.md +0 -347
- package/docs/parallelAsyncCalls/README.md +0 -45
- package/docs/promiseUtils/-internal-.md +0 -69
- package/docs/promiseUtils/README.md +0 -31
- package/docs/retryOnError/-internal-.md +0 -111
- package/docs/retryOnError/README.md +0 -168
- package/docs/runShellCmd/-internal-.md +0 -111
- package/docs/runShellCmd/README.md +0 -201
- package/docs/safeJson.md +0 -51
- package/docs/saferTyping.md +0 -228
- package/docs/serializeXML.md +0 -100
- package/docs/shallowEqual.md +0 -33
- package/docs/sleep.md +0 -27
- package/docs/stringUtils/-internal-.md +0 -17
- package/docs/stringUtils/README.md +0 -270
- package/docs/testUtils.md +0 -382
- package/docs/throttle/-internal-.md +0 -47
- package/docs/throttle/README.md +0 -178
- package/docs/time.md +0 -274
- package/docs/timers.md +0 -256
- package/docs/tsResult/-internal-.md +0 -327
- package/docs/tsResult/README.md +0 -702
- package/docs/typeGuards.md +0 -399
- package/docs/typeUtils/-internal-.md +0 -99
- package/docs/typeUtils/README.md +0 -195
- package/docs/typeUtils.typesTest.md +0 -7
- package/docs/typedStrings.md +0 -458
- package/docs/typingFnUtils/-internal-.md +0 -43
- package/docs/typingFnUtils/README.md +0 -317
- package/docs/typingTestUtils.md +0 -172
- package/docs/typingUtils.md +0 -135
- package/docs/yamlStringify.md +0 -83
package/docs/typedStrings.md
DELETED
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / typedStrings
|
|
6
|
-
|
|
7
|
-
# typedStrings
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### NonEmptyString
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type NonEmptyString = string & object;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/typedStrings.ts:171](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L171)
|
|
18
|
-
|
|
19
|
-
A branded type representing a string that is guaranteed to be non-empty (length > 0).
|
|
20
|
-
This type provides compile-time safety by preventing empty strings from being
|
|
21
|
-
assigned without proper validation.
|
|
22
|
-
|
|
23
|
-
#### Type declaration
|
|
24
|
-
|
|
25
|
-
##### \_\_nonEmptyString
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
__nonEmptyString: true;
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
#### Example
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
function processName(name: NonEmptyString) {
|
|
35
|
-
// name is guaranteed to be non-empty
|
|
36
|
-
return name.toUpperCase();
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
***
|
|
41
|
-
|
|
42
|
-
### StringContaining\<T\>
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
type StringContaining<T> = string extends T ? never : `${string}${T}${string}`;
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Defined in: [packages/utils/src/typedStrings.ts:12](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L12)
|
|
49
|
-
|
|
50
|
-
A type representing a string that contains a specific substring.
|
|
51
|
-
Uses template literal types to ensure type safety at compile time.
|
|
52
|
-
|
|
53
|
-
#### Type Parameters
|
|
54
|
-
|
|
55
|
-
##### T
|
|
56
|
-
|
|
57
|
-
`T` *extends* `string`
|
|
58
|
-
|
|
59
|
-
The substring that must be contained within the string
|
|
60
|
-
|
|
61
|
-
#### Example
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
type EmailString = StringContaining<'@'>; // string that contains '@'
|
|
65
|
-
const email: EmailString = 'user@example.com'; // ✓ valid
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
***
|
|
69
|
-
|
|
70
|
-
### StringEndingWith\<T\>
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
type StringEndingWith<T> = string extends T ? never : `${string}${T}`;
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Defined in: [packages/utils/src/typedStrings.ts:40](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L40)
|
|
77
|
-
|
|
78
|
-
A type representing a string that ends with a specific substring.
|
|
79
|
-
Uses template literal types to ensure the string ends with the specified suffix.
|
|
80
|
-
|
|
81
|
-
#### Type Parameters
|
|
82
|
-
|
|
83
|
-
##### T
|
|
84
|
-
|
|
85
|
-
`T` *extends* `string`
|
|
86
|
-
|
|
87
|
-
The substring that the string must end with
|
|
88
|
-
|
|
89
|
-
#### Example
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
type JavaFile = StringEndingWith<'.java'>; // string ending with '.java'
|
|
93
|
-
const filename: JavaFile = 'HelloWorld.java'; // ✓ valid
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
***
|
|
97
|
-
|
|
98
|
-
### StringStartingWith\<T\>
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
type StringStartingWith<T> = string extends T ? never : `${T}${string}`;
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Defined in: [packages/utils/src/typedStrings.ts:26](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L26)
|
|
105
|
-
|
|
106
|
-
A type representing a string that starts with a specific substring.
|
|
107
|
-
Uses template literal types to ensure the string begins with the specified prefix.
|
|
108
|
-
|
|
109
|
-
#### Type Parameters
|
|
110
|
-
|
|
111
|
-
##### T
|
|
112
|
-
|
|
113
|
-
`T` *extends* `string`
|
|
114
|
-
|
|
115
|
-
The substring that the string must start with
|
|
116
|
-
|
|
117
|
-
#### Example
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
type HttpUrl = StringStartingWith<'http'>; // string starting with 'http'
|
|
121
|
-
const url: HttpUrl = 'https://example.com'; // ✓ valid
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
## Functions
|
|
125
|
-
|
|
126
|
-
### asNonEmptyStringOrNull()
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
function asNonEmptyStringOrNull(str): null | NonEmptyString;
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Defined in: [packages/utils/src/typedStrings.ts:208](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L208)
|
|
133
|
-
|
|
134
|
-
Converts a string to `NonEmptyString` or returns `null` if the string is empty.
|
|
135
|
-
Use this when empty strings should be handled gracefully rather than throwing errors.
|
|
136
|
-
|
|
137
|
-
#### Parameters
|
|
138
|
-
|
|
139
|
-
##### str
|
|
140
|
-
|
|
141
|
-
`string`
|
|
142
|
-
|
|
143
|
-
The string to convert
|
|
144
|
-
|
|
145
|
-
#### Returns
|
|
146
|
-
|
|
147
|
-
`null` \| [`NonEmptyString`](#nonemptystring)
|
|
148
|
-
|
|
149
|
-
The string as `NonEmptyString` or `null` if empty
|
|
150
|
-
|
|
151
|
-
***
|
|
152
|
-
|
|
153
|
-
### asNonEmptyStringOrThrow()
|
|
154
|
-
|
|
155
|
-
```ts
|
|
156
|
-
function asNonEmptyStringOrThrow(str): NonEmptyString;
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Defined in: [packages/utils/src/typedStrings.ts:194](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L194)
|
|
160
|
-
|
|
161
|
-
Converts a string to `NonEmptyString` or throws an error if the string is empty.
|
|
162
|
-
Use this when you need to ensure a string is non-empty and want to fail fast.
|
|
163
|
-
|
|
164
|
-
#### Parameters
|
|
165
|
-
|
|
166
|
-
##### str
|
|
167
|
-
|
|
168
|
-
`string`
|
|
169
|
-
|
|
170
|
-
The string to convert
|
|
171
|
-
|
|
172
|
-
#### Returns
|
|
173
|
-
|
|
174
|
-
[`NonEmptyString`](#nonemptystring)
|
|
175
|
-
|
|
176
|
-
The string as `NonEmptyString`
|
|
177
|
-
|
|
178
|
-
#### Throws
|
|
179
|
-
|
|
180
|
-
Error if the string is empty
|
|
181
|
-
|
|
182
|
-
***
|
|
183
|
-
|
|
184
|
-
### assertStringIsNonEmpty()
|
|
185
|
-
|
|
186
|
-
```ts
|
|
187
|
-
function assertStringIsNonEmpty(str): asserts str is NonEmptyString;
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
Defined in: [packages/utils/src/typedStrings.ts:222](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L222)
|
|
191
|
-
|
|
192
|
-
Assertion function that ensures a string is non-empty.
|
|
193
|
-
Throws an error if the string is empty, otherwise narrows the type to `NonEmptyString`.
|
|
194
|
-
|
|
195
|
-
#### Parameters
|
|
196
|
-
|
|
197
|
-
##### str
|
|
198
|
-
|
|
199
|
-
`string`
|
|
200
|
-
|
|
201
|
-
The string to assert as non-empty
|
|
202
|
-
|
|
203
|
-
#### Returns
|
|
204
|
-
|
|
205
|
-
`asserts str is NonEmptyString`
|
|
206
|
-
|
|
207
|
-
#### Throws
|
|
208
|
-
|
|
209
|
-
Error if the string is empty
|
|
210
|
-
|
|
211
|
-
***
|
|
212
|
-
|
|
213
|
-
### isNonEmptyString()
|
|
214
|
-
|
|
215
|
-
```ts
|
|
216
|
-
function isNonEmptyString(str): str is NonEmptyString;
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
Defined in: [packages/utils/src/typedStrings.ts:182](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L182)
|
|
220
|
-
|
|
221
|
-
Type guard function that checks if a string is non-empty.
|
|
222
|
-
Narrows the type to `NonEmptyString` when the check passes.
|
|
223
|
-
|
|
224
|
-
#### Parameters
|
|
225
|
-
|
|
226
|
-
##### str
|
|
227
|
-
|
|
228
|
-
`string`
|
|
229
|
-
|
|
230
|
-
The string to check
|
|
231
|
-
|
|
232
|
-
#### Returns
|
|
233
|
-
|
|
234
|
-
`str is NonEmptyString`
|
|
235
|
-
|
|
236
|
-
`true` if the string has length > 0, `false` otherwise
|
|
237
|
-
|
|
238
|
-
***
|
|
239
|
-
|
|
240
|
-
### splitTypedString()
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
function splitTypedString<T>(str, separator): [string, string, ...string[]];
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Defined in: [packages/utils/src/typedStrings.ts:103](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L103)
|
|
247
|
-
|
|
248
|
-
Splits a typed string by a separator that is guaranteed to exist in the string.
|
|
249
|
-
Returns an array with at least two elements: the parts before and after the first separator,
|
|
250
|
-
plus any additional parts if there are multiple separators.
|
|
251
|
-
|
|
252
|
-
#### Type Parameters
|
|
253
|
-
|
|
254
|
-
##### T
|
|
255
|
-
|
|
256
|
-
`T` *extends* `string`
|
|
257
|
-
|
|
258
|
-
#### Parameters
|
|
259
|
-
|
|
260
|
-
##### str
|
|
261
|
-
|
|
262
|
-
A string that contains, starts with, or ends with the separator
|
|
263
|
-
|
|
264
|
-
[`StringContaining`](#stringcontaining)\<`NoInfer`\<`T`\>\> | [`StringStartingWith`](#stringstartingwith)\<`NoInfer`\<`T`\>\> | [`StringEndingWith`](#stringendingwith)\<`NoInfer`\<`T`\>\>
|
|
265
|
-
|
|
266
|
-
##### separator
|
|
267
|
-
|
|
268
|
-
`T`
|
|
269
|
-
|
|
270
|
-
The separator to split by
|
|
271
|
-
|
|
272
|
-
#### Returns
|
|
273
|
-
|
|
274
|
-
\[`string`, `string`, `...string[]`\]
|
|
275
|
-
|
|
276
|
-
An array with at least two string elements
|
|
277
|
-
|
|
278
|
-
#### Example
|
|
279
|
-
|
|
280
|
-
```ts
|
|
281
|
-
const path: StringContaining<'/'> = 'src/utils/types.ts';
|
|
282
|
-
const [first, second, ...rest] = splitTypedString(path, '/');
|
|
283
|
-
// first: 'src', second: 'utils', rest: ['types.ts']
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
***
|
|
287
|
-
|
|
288
|
-
### splitTypedStringAt()
|
|
289
|
-
|
|
290
|
-
```ts
|
|
291
|
-
function splitTypedStringAt<T>(
|
|
292
|
-
str,
|
|
293
|
-
separator,
|
|
294
|
-
splitAtNSeparatorPos): [string, string];
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
Defined in: [packages/utils/src/typedStrings.ts:129](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L129)
|
|
298
|
-
|
|
299
|
-
Splits a typed string at a specific occurrence of the separator.
|
|
300
|
-
Unlike `splitTypedString`, this returns exactly two parts: everything before
|
|
301
|
-
the nth separator and everything after it.
|
|
302
|
-
|
|
303
|
-
#### Type Parameters
|
|
304
|
-
|
|
305
|
-
##### T
|
|
306
|
-
|
|
307
|
-
`T` *extends* `string`
|
|
308
|
-
|
|
309
|
-
#### Parameters
|
|
310
|
-
|
|
311
|
-
##### str
|
|
312
|
-
|
|
313
|
-
A string that contains, starts with, or ends with the separator
|
|
314
|
-
|
|
315
|
-
[`StringContaining`](#stringcontaining)\<`NoInfer`\<`T`\>\> | [`StringStartingWith`](#stringstartingwith)\<`NoInfer`\<`T`\>\> | [`StringEndingWith`](#stringendingwith)\<`NoInfer`\<`T`\>\>
|
|
316
|
-
|
|
317
|
-
##### separator
|
|
318
|
-
|
|
319
|
-
`T`
|
|
320
|
-
|
|
321
|
-
The separator to split by
|
|
322
|
-
|
|
323
|
-
##### splitAtNSeparatorPos
|
|
324
|
-
|
|
325
|
-
`number` = `1`
|
|
326
|
-
|
|
327
|
-
The position of the separator to split at (1-based)
|
|
328
|
-
|
|
329
|
-
#### Returns
|
|
330
|
-
|
|
331
|
-
\[`string`, `string`\]
|
|
332
|
-
|
|
333
|
-
A tuple with exactly two string elements
|
|
334
|
-
|
|
335
|
-
#### Example
|
|
336
|
-
|
|
337
|
-
```ts
|
|
338
|
-
const path: StringContaining<'.'> = 'file.name.ext';
|
|
339
|
-
const [name, ext] = splitTypedStringAt(path, '.', 2);
|
|
340
|
-
// name: 'file.name', ext: 'ext'
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
***
|
|
344
|
-
|
|
345
|
-
### stringContains()
|
|
346
|
-
|
|
347
|
-
```ts
|
|
348
|
-
function stringContains<T>(str, substring): str is StringContaining<T>;
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
Defined in: [packages/utils/src/typedStrings.ts:51](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L51)
|
|
352
|
-
|
|
353
|
-
Type guard function that checks if a string contains a specific substring.
|
|
354
|
-
Narrows the type to `StringContaining<T>` when the check passes.
|
|
355
|
-
|
|
356
|
-
#### Type Parameters
|
|
357
|
-
|
|
358
|
-
##### T
|
|
359
|
-
|
|
360
|
-
`T` *extends* `string`
|
|
361
|
-
|
|
362
|
-
#### Parameters
|
|
363
|
-
|
|
364
|
-
##### str
|
|
365
|
-
|
|
366
|
-
`string`
|
|
367
|
-
|
|
368
|
-
The string to check
|
|
369
|
-
|
|
370
|
-
##### substring
|
|
371
|
-
|
|
372
|
-
`T`
|
|
373
|
-
|
|
374
|
-
The substring to search for
|
|
375
|
-
|
|
376
|
-
#### Returns
|
|
377
|
-
|
|
378
|
-
`str is StringContaining<T>`
|
|
379
|
-
|
|
380
|
-
`true` if the string contains the substring, `false` otherwise
|
|
381
|
-
|
|
382
|
-
***
|
|
383
|
-
|
|
384
|
-
### stringEndsWith()
|
|
385
|
-
|
|
386
|
-
```ts
|
|
387
|
-
function stringEndsWith<T>(str, substring): str is StringEndingWith<T>;
|
|
388
|
-
```
|
|
389
|
-
|
|
390
|
-
Defined in: [packages/utils/src/typedStrings.ts:81](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L81)
|
|
391
|
-
|
|
392
|
-
Type guard function that checks if a string ends with a specific substring.
|
|
393
|
-
Narrows the type to `StringEndingWith<T>` when the check passes.
|
|
394
|
-
|
|
395
|
-
#### Type Parameters
|
|
396
|
-
|
|
397
|
-
##### T
|
|
398
|
-
|
|
399
|
-
`T` *extends* `string`
|
|
400
|
-
|
|
401
|
-
#### Parameters
|
|
402
|
-
|
|
403
|
-
##### str
|
|
404
|
-
|
|
405
|
-
`string`
|
|
406
|
-
|
|
407
|
-
The string to check
|
|
408
|
-
|
|
409
|
-
##### substring
|
|
410
|
-
|
|
411
|
-
`T`
|
|
412
|
-
|
|
413
|
-
The substring to check for at the end
|
|
414
|
-
|
|
415
|
-
#### Returns
|
|
416
|
-
|
|
417
|
-
`str is StringEndingWith<T>`
|
|
418
|
-
|
|
419
|
-
`true` if the string ends with the substring, `false` otherwise
|
|
420
|
-
|
|
421
|
-
***
|
|
422
|
-
|
|
423
|
-
### stringStartsWith()
|
|
424
|
-
|
|
425
|
-
```ts
|
|
426
|
-
function stringStartsWith<T>(str, substring): str is StringStartingWith<T>;
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
Defined in: [packages/utils/src/typedStrings.ts:66](https://github.com/lucasols/utils/blob/main/packages/utils/src/typedStrings.ts#L66)
|
|
430
|
-
|
|
431
|
-
Type guard function that checks if a string starts with a specific substring.
|
|
432
|
-
Narrows the type to `StringStartingWith<T>` when the check passes.
|
|
433
|
-
|
|
434
|
-
#### Type Parameters
|
|
435
|
-
|
|
436
|
-
##### T
|
|
437
|
-
|
|
438
|
-
`T` *extends* `string`
|
|
439
|
-
|
|
440
|
-
#### Parameters
|
|
441
|
-
|
|
442
|
-
##### str
|
|
443
|
-
|
|
444
|
-
`string`
|
|
445
|
-
|
|
446
|
-
The string to check
|
|
447
|
-
|
|
448
|
-
##### substring
|
|
449
|
-
|
|
450
|
-
`T`
|
|
451
|
-
|
|
452
|
-
The substring to check for at the beginning
|
|
453
|
-
|
|
454
|
-
#### Returns
|
|
455
|
-
|
|
456
|
-
`str is StringStartingWith<T>`
|
|
457
|
-
|
|
458
|
-
`true` if the string starts with the substring, `false` otherwise
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [typingFnUtils](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### KeysWithUndefinedValues\<T\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type KeysWithUndefinedValues<T> = { [K in keyof T]: undefined extends T[K] ? K : never }[keyof T];
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/typeUtils.ts:149](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L149)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### UnionDiff\<T, U\>
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
type UnionDiff<T, U> = [T] extends [U] ? [U] extends [T] ? null : object : [U] extends [T] ? object : object;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/typingFnUtils.ts:93](https://github.com/lucasols/utils/blob/main/packages/utils/src/typingFnUtils.ts#L93)
|
|
34
|
-
|
|
35
|
-
#### Type Parameters
|
|
36
|
-
|
|
37
|
-
##### T
|
|
38
|
-
|
|
39
|
-
`T`
|
|
40
|
-
|
|
41
|
-
##### U
|
|
42
|
-
|
|
43
|
-
`U`
|