@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/typeGuards.md
DELETED
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / typeGuards
|
|
6
|
-
|
|
7
|
-
# typeGuards
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### NonEmptyArray\<T\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/typeGuards.ts:128](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L128)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T`
|
|
24
|
-
|
|
25
|
-
## Functions
|
|
26
|
-
|
|
27
|
-
### arrayHasAtLeastXItems()
|
|
28
|
-
|
|
29
|
-
#### Call Signature
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
function arrayHasAtLeastXItems<T>(array, minLength): array is [T, ...T[]];
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Defined in: [packages/utils/src/typeGuards.ts:136](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L136)
|
|
36
|
-
|
|
37
|
-
##### Type Parameters
|
|
38
|
-
|
|
39
|
-
###### T
|
|
40
|
-
|
|
41
|
-
`T`
|
|
42
|
-
|
|
43
|
-
##### Parameters
|
|
44
|
-
|
|
45
|
-
###### array
|
|
46
|
-
|
|
47
|
-
`T`[]
|
|
48
|
-
|
|
49
|
-
###### minLength
|
|
50
|
-
|
|
51
|
-
`1`
|
|
52
|
-
|
|
53
|
-
##### Returns
|
|
54
|
-
|
|
55
|
-
`array is [T, ...T[]]`
|
|
56
|
-
|
|
57
|
-
#### Call Signature
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
function arrayHasAtLeastXItems<T>(array, minLength): array is [T, T, ...T[]];
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Defined in: [packages/utils/src/typeGuards.ts:140](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L140)
|
|
64
|
-
|
|
65
|
-
##### Type Parameters
|
|
66
|
-
|
|
67
|
-
###### T
|
|
68
|
-
|
|
69
|
-
`T`
|
|
70
|
-
|
|
71
|
-
##### Parameters
|
|
72
|
-
|
|
73
|
-
###### array
|
|
74
|
-
|
|
75
|
-
`T`[]
|
|
76
|
-
|
|
77
|
-
###### minLength
|
|
78
|
-
|
|
79
|
-
`2`
|
|
80
|
-
|
|
81
|
-
##### Returns
|
|
82
|
-
|
|
83
|
-
`array is [T, T, ...T[]]`
|
|
84
|
-
|
|
85
|
-
#### Call Signature
|
|
86
|
-
|
|
87
|
-
```ts
|
|
88
|
-
function arrayHasAtLeastXItems<T>(array, minLength): array is [T, T, T, ...T[]];
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Defined in: [packages/utils/src/typeGuards.ts:144](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L144)
|
|
92
|
-
|
|
93
|
-
##### Type Parameters
|
|
94
|
-
|
|
95
|
-
###### T
|
|
96
|
-
|
|
97
|
-
`T`
|
|
98
|
-
|
|
99
|
-
##### Parameters
|
|
100
|
-
|
|
101
|
-
###### array
|
|
102
|
-
|
|
103
|
-
`T`[]
|
|
104
|
-
|
|
105
|
-
###### minLength
|
|
106
|
-
|
|
107
|
-
`3`
|
|
108
|
-
|
|
109
|
-
##### Returns
|
|
110
|
-
|
|
111
|
-
`array is [T, T, T, ...T[]]`
|
|
112
|
-
|
|
113
|
-
#### Call Signature
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
function arrayHasAtLeastXItems<T>(array, minLength): array is [T, T, T, T, ...T[]];
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Defined in: [packages/utils/src/typeGuards.ts:148](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L148)
|
|
120
|
-
|
|
121
|
-
##### Type Parameters
|
|
122
|
-
|
|
123
|
-
###### T
|
|
124
|
-
|
|
125
|
-
`T`
|
|
126
|
-
|
|
127
|
-
##### Parameters
|
|
128
|
-
|
|
129
|
-
###### array
|
|
130
|
-
|
|
131
|
-
`T`[]
|
|
132
|
-
|
|
133
|
-
###### minLength
|
|
134
|
-
|
|
135
|
-
`4`
|
|
136
|
-
|
|
137
|
-
##### Returns
|
|
138
|
-
|
|
139
|
-
`array is [T, T, T, T, ...T[]]`
|
|
140
|
-
|
|
141
|
-
#### Call Signature
|
|
142
|
-
|
|
143
|
-
```ts
|
|
144
|
-
function arrayHasAtLeastXItems<T>(array, minLength): array is [T, T, T, T, T, ...T[]];
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
Defined in: [packages/utils/src/typeGuards.ts:152](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L152)
|
|
148
|
-
|
|
149
|
-
##### Type Parameters
|
|
150
|
-
|
|
151
|
-
###### T
|
|
152
|
-
|
|
153
|
-
`T`
|
|
154
|
-
|
|
155
|
-
##### Parameters
|
|
156
|
-
|
|
157
|
-
###### array
|
|
158
|
-
|
|
159
|
-
`T`[]
|
|
160
|
-
|
|
161
|
-
###### minLength
|
|
162
|
-
|
|
163
|
-
`5`
|
|
164
|
-
|
|
165
|
-
##### Returns
|
|
166
|
-
|
|
167
|
-
`array is [T, T, T, T, T, ...T[]]`
|
|
168
|
-
|
|
169
|
-
***
|
|
170
|
-
|
|
171
|
-
### isFunction()
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
function isFunction(value): value is (args: any[]) => any;
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Defined in: [packages/utils/src/typeGuards.ts:51](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L51)
|
|
178
|
-
|
|
179
|
-
Type guard to check if a value is a function.
|
|
180
|
-
|
|
181
|
-
Returns true if the value is a function of any kind (regular function,
|
|
182
|
-
arrow function, method, constructor, etc.).
|
|
183
|
-
|
|
184
|
-
#### Parameters
|
|
185
|
-
|
|
186
|
-
##### value
|
|
187
|
-
|
|
188
|
-
`unknown`
|
|
189
|
-
|
|
190
|
-
The value to check
|
|
191
|
-
|
|
192
|
-
#### Returns
|
|
193
|
-
|
|
194
|
-
`value is (args: any[]) => any`
|
|
195
|
-
|
|
196
|
-
True if the value is a function, false otherwise
|
|
197
|
-
|
|
198
|
-
#### Example
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
if (isFunction(value)) {
|
|
202
|
-
// TypeScript knows value is (...args: any[]) => any
|
|
203
|
-
const result = value();
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
isFunction(() => {}); // true
|
|
207
|
-
isFunction(function() {}); // true
|
|
208
|
-
isFunction(Math.max); // true
|
|
209
|
-
isFunction('string'); // false
|
|
210
|
-
isFunction({}); // false
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
***
|
|
214
|
-
|
|
215
|
-
### isNonEmptyArray()
|
|
216
|
-
|
|
217
|
-
```ts
|
|
218
|
-
function isNonEmptyArray<T>(value): value is NonEmptyArray<T>;
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
Defined in: [packages/utils/src/typeGuards.ts:130](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L130)
|
|
222
|
-
|
|
223
|
-
#### Type Parameters
|
|
224
|
-
|
|
225
|
-
##### T
|
|
226
|
-
|
|
227
|
-
`T`
|
|
228
|
-
|
|
229
|
-
#### Parameters
|
|
230
|
-
|
|
231
|
-
##### value
|
|
232
|
-
|
|
233
|
-
`T`[] | readonly `T`[]
|
|
234
|
-
|
|
235
|
-
#### Returns
|
|
236
|
-
|
|
237
|
-
`value is NonEmptyArray<T>`
|
|
238
|
-
|
|
239
|
-
***
|
|
240
|
-
|
|
241
|
-
### isObject()
|
|
242
|
-
|
|
243
|
-
```ts
|
|
244
|
-
function isObject(value): value is Record<string, unknown>;
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
Defined in: [packages/utils/src/typeGuards.ts:24](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L24)
|
|
248
|
-
|
|
249
|
-
Type guard to check if a value is a plain object (not null, not an array).
|
|
250
|
-
|
|
251
|
-
Returns true if the value is an object that is not null and not an array.
|
|
252
|
-
This is useful for distinguishing between objects and other types.
|
|
253
|
-
|
|
254
|
-
#### Parameters
|
|
255
|
-
|
|
256
|
-
##### value
|
|
257
|
-
|
|
258
|
-
`unknown`
|
|
259
|
-
|
|
260
|
-
The value to check
|
|
261
|
-
|
|
262
|
-
#### Returns
|
|
263
|
-
|
|
264
|
-
`value is Record<string, unknown>`
|
|
265
|
-
|
|
266
|
-
True if the value is a plain object, false otherwise
|
|
267
|
-
|
|
268
|
-
#### Example
|
|
269
|
-
|
|
270
|
-
```typescript
|
|
271
|
-
if (isObject(value)) {
|
|
272
|
-
// TypeScript knows value is Record<string, unknown>
|
|
273
|
-
console.log(value.someProperty);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
isObject({}); // true
|
|
277
|
-
isObject({ a: 1 }); // true
|
|
278
|
-
isObject(null); // false
|
|
279
|
-
isObject([]); // false
|
|
280
|
-
isObject('string'); // false
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
***
|
|
284
|
-
|
|
285
|
-
### isPlainObject()
|
|
286
|
-
|
|
287
|
-
```ts
|
|
288
|
-
function isPlainObject(value): value is Record<string, unknown>;
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
Defined in: [packages/utils/src/typeGuards.ts:109](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L109)
|
|
292
|
-
|
|
293
|
-
Type guard to check if a value is a plain object (created by Object literal or Object constructor).
|
|
294
|
-
|
|
295
|
-
Returns true if the value is a plain object - an object created by the Object
|
|
296
|
-
constructor or object literal syntax. This excludes instances of classes,
|
|
297
|
-
built-in objects like Date, RegExp, etc.
|
|
298
|
-
|
|
299
|
-
#### Parameters
|
|
300
|
-
|
|
301
|
-
##### value
|
|
302
|
-
|
|
303
|
-
`any`
|
|
304
|
-
|
|
305
|
-
The value to check
|
|
306
|
-
|
|
307
|
-
#### Returns
|
|
308
|
-
|
|
309
|
-
`value is Record<string, unknown>`
|
|
310
|
-
|
|
311
|
-
True if the value is a plain object, false otherwise
|
|
312
|
-
|
|
313
|
-
#### Example
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
if (isPlainObject(value)) {
|
|
317
|
-
// TypeScript knows value is Record<string, unknown>
|
|
318
|
-
console.log(Object.keys(value));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
isPlainObject({}); // true
|
|
322
|
-
isPlainObject({ a: 1 }); // true
|
|
323
|
-
isPlainObject(Object.create(null)); // true
|
|
324
|
-
isPlainObject(new Date()); // false
|
|
325
|
-
isPlainObject(/regex/); // false
|
|
326
|
-
isPlainObject(new MyClass()); // false
|
|
327
|
-
isPlainObject([]); // false
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
***
|
|
331
|
-
|
|
332
|
-
### isPromise()
|
|
333
|
-
|
|
334
|
-
```ts
|
|
335
|
-
function isPromise(value): value is Promise<unknown>;
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
Defined in: [packages/utils/src/typeGuards.ts:79](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L79)
|
|
339
|
-
|
|
340
|
-
Type guard to check if a value is a Promise or thenable object.
|
|
341
|
-
|
|
342
|
-
Returns true if the value is an object with a `then` method that is a function.
|
|
343
|
-
This covers both native Promises and thenable objects that implement the
|
|
344
|
-
Promise interface.
|
|
345
|
-
|
|
346
|
-
#### Parameters
|
|
347
|
-
|
|
348
|
-
##### value
|
|
349
|
-
|
|
350
|
-
`unknown`
|
|
351
|
-
|
|
352
|
-
The value to check
|
|
353
|
-
|
|
354
|
-
#### Returns
|
|
355
|
-
|
|
356
|
-
`value is Promise<unknown>`
|
|
357
|
-
|
|
358
|
-
True if the value is a Promise or thenable, false otherwise
|
|
359
|
-
|
|
360
|
-
#### Example
|
|
361
|
-
|
|
362
|
-
```typescript
|
|
363
|
-
if (isPromise(value)) {
|
|
364
|
-
// TypeScript knows value is Promise<unknown>
|
|
365
|
-
const result = await value;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
isPromise(Promise.resolve()); // true
|
|
369
|
-
isPromise(new Promise(() => {})); // true
|
|
370
|
-
isPromise({ then: () => {} }); // true
|
|
371
|
-
isPromise({ then: 'not a function' }); // false
|
|
372
|
-
isPromise('string'); // false
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
***
|
|
376
|
-
|
|
377
|
-
### isTruthy()
|
|
378
|
-
|
|
379
|
-
```ts
|
|
380
|
-
function isTruthy<T>(value): value is Exclude<T, undefined | null | false | "" | 0 | 0n>;
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
Defined in: [packages/utils/src/typeGuards.ts:163](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeGuards.ts#L163)
|
|
384
|
-
|
|
385
|
-
#### Type Parameters
|
|
386
|
-
|
|
387
|
-
##### T
|
|
388
|
-
|
|
389
|
-
`T`
|
|
390
|
-
|
|
391
|
-
#### Parameters
|
|
392
|
-
|
|
393
|
-
##### value
|
|
394
|
-
|
|
395
|
-
`T`
|
|
396
|
-
|
|
397
|
-
#### Returns
|
|
398
|
-
|
|
399
|
-
value is Exclude\<T, undefined \| null \| false \| "" \| 0 \| 0n\>
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [typeUtils](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### BuildArrayPath\<BasePath\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type BuildArrayPath<BasePath> = BasePath extends "$" ? "[*]" : `${BasePath}[*]`;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/typeUtils.ts:62](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L62)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### BasePath
|
|
22
|
-
|
|
23
|
-
`BasePath` *extends* `string`
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### BuildPath\<BasePath, Key\>
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
type BuildPath<BasePath, Key> = BasePath extends "$" ? Key extends string | number ? `${Key}` : never : Key extends string | number ? `${BasePath}.${Key}` : never;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/typeUtils.ts:54](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L54)
|
|
34
|
-
|
|
35
|
-
#### Type Parameters
|
|
36
|
-
|
|
37
|
-
##### BasePath
|
|
38
|
-
|
|
39
|
-
`BasePath` *extends* `string`
|
|
40
|
-
|
|
41
|
-
##### Key
|
|
42
|
-
|
|
43
|
-
`Key` *extends* `PropertyKey`
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
### DeepReplaceValueImpl\<T, ReplaceType, NewType, SkipPaths, SkipType, Path\>
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
type DeepReplaceValueImpl<T, ReplaceType, NewType, SkipPaths, SkipType, Path> = SkipPaths extends string ? PathMatches<Path, SkipPaths> extends true ? T : T extends ReplaceType ? T extends SkipType ? T : NewType : T extends readonly infer U[] ? DeepReplaceValueImpl<U, ReplaceType, NewType, SkipPaths, SkipType, BuildArrayPath<Path>>[] : T extends SkipType ? T : T extends Record<string, any> ? { [K in keyof T]: DeepReplaceValueImpl<T[K], ReplaceType, NewType, SkipPaths, SkipType, BuildPath<Path, K>> } : T : T extends ReplaceType ? T extends SkipType ? T : NewType : T extends readonly infer U[] ? DeepReplaceValueImpl<U, ReplaceType, NewType, SkipPaths, SkipType, BuildArrayPath<Path>>[] : T extends SkipType ? T : T extends Record<string, any> ? { [K in keyof T]: DeepReplaceValueImpl<T[K], ReplaceType, NewType, SkipPaths, SkipType, BuildPath<Path, K>> } : T;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Defined in: [packages/utils/src/typeUtils.ts:65](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L65)
|
|
54
|
-
|
|
55
|
-
#### Type Parameters
|
|
56
|
-
|
|
57
|
-
##### T
|
|
58
|
-
|
|
59
|
-
`T`
|
|
60
|
-
|
|
61
|
-
##### ReplaceType
|
|
62
|
-
|
|
63
|
-
`ReplaceType`
|
|
64
|
-
|
|
65
|
-
##### NewType
|
|
66
|
-
|
|
67
|
-
`NewType`
|
|
68
|
-
|
|
69
|
-
##### SkipPaths
|
|
70
|
-
|
|
71
|
-
`SkipPaths` *extends* `string` \| `undefined`
|
|
72
|
-
|
|
73
|
-
##### SkipType
|
|
74
|
-
|
|
75
|
-
`SkipType`
|
|
76
|
-
|
|
77
|
-
##### Path
|
|
78
|
-
|
|
79
|
-
`Path` *extends* `string` = `"$"`
|
|
80
|
-
|
|
81
|
-
***
|
|
82
|
-
|
|
83
|
-
### PathMatches\<CurrentPath, SkipPaths\>
|
|
84
|
-
|
|
85
|
-
```ts
|
|
86
|
-
type PathMatches<CurrentPath, SkipPaths> = true extends SkipPaths extends any ? CurrentPath extends SkipPaths ? true : SkipPaths extends `${infer Prefix}[*]${infer Suffix}` ? CurrentPath extends `${Prefix}[${string}]${Suffix}` ? true : false : false : false ? true : false;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Defined in: [packages/utils/src/typeUtils.ts:40](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L40)
|
|
90
|
-
|
|
91
|
-
#### Type Parameters
|
|
92
|
-
|
|
93
|
-
##### CurrentPath
|
|
94
|
-
|
|
95
|
-
`CurrentPath` *extends* `string`
|
|
96
|
-
|
|
97
|
-
##### SkipPaths
|
|
98
|
-
|
|
99
|
-
`SkipPaths` *extends* `string`
|
package/docs/typeUtils/README.md
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / typeUtils
|
|
6
|
-
|
|
7
|
-
# typeUtils
|
|
8
|
-
|
|
9
|
-
## Modules
|
|
10
|
-
|
|
11
|
-
- [\<internal\>](-internal-.md)
|
|
12
|
-
|
|
13
|
-
## Type Aliases
|
|
14
|
-
|
|
15
|
-
### DeepPrettify\<T\>
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
type DeepPrettify<T> = { [K in keyof T]: T[K] extends Record<string, unknown> ? DeepPrettify<T[K]> : T[K] } & object;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Defined in: [packages/utils/src/typeUtils.ts:25](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L25)
|
|
22
|
-
|
|
23
|
-
#### Type Parameters
|
|
24
|
-
|
|
25
|
-
##### T
|
|
26
|
-
|
|
27
|
-
`T`
|
|
28
|
-
|
|
29
|
-
***
|
|
30
|
-
|
|
31
|
-
### DeepReplaceValue\<T, ReplaceType, NewType, SkipPaths, SkipTypes\>
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
type DeepReplaceValue<T, ReplaceType, NewType, SkipPaths, SkipTypes> = DeepReplaceValueImpl<T, ReplaceType, NewType, SkipPaths, SkipTypes>;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Defined in: [packages/utils/src/typeUtils.ts:141](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L141)
|
|
38
|
-
|
|
39
|
-
Replaces all values that extends `ReplaceType` with `NewType` in a deeply nested object or array.
|
|
40
|
-
|
|
41
|
-
#### Type Parameters
|
|
42
|
-
|
|
43
|
-
##### T
|
|
44
|
-
|
|
45
|
-
`T`
|
|
46
|
-
|
|
47
|
-
The object or array to replace values in.
|
|
48
|
-
|
|
49
|
-
##### ReplaceType
|
|
50
|
-
|
|
51
|
-
`ReplaceType`
|
|
52
|
-
|
|
53
|
-
The type to replace.
|
|
54
|
-
|
|
55
|
-
##### NewType
|
|
56
|
-
|
|
57
|
-
`NewType`
|
|
58
|
-
|
|
59
|
-
The new type to replace with.
|
|
60
|
-
|
|
61
|
-
##### SkipPaths
|
|
62
|
-
|
|
63
|
-
`SkipPaths` *extends* `string` \| `undefined` = `undefined`
|
|
64
|
-
|
|
65
|
-
The paths to skip in transverse. e.g. 'a.b.c' | 'array[*].b'
|
|
66
|
-
|
|
67
|
-
##### SkipTypes
|
|
68
|
-
|
|
69
|
-
`SkipTypes` = [`DefaultSkipTransverseDeepReplace`](#defaultskiptransversedeepreplace)
|
|
70
|
-
|
|
71
|
-
The types to skip in transverse and replace.
|
|
72
|
-
|
|
73
|
-
***
|
|
74
|
-
|
|
75
|
-
### DefaultSkipTransverseDeepReplace
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
type DefaultSkipTransverseDeepReplace =
|
|
79
|
-
| Date
|
|
80
|
-
| RegExp
|
|
81
|
-
| (...args) => any
|
|
82
|
-
| Error
|
|
83
|
-
| Set<any>
|
|
84
|
-
| Map<any, any>
|
|
85
|
-
| WeakSet<any>
|
|
86
|
-
| WeakMap<any, any>;
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
Defined in: [packages/utils/src/typeUtils.ts:30](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L30)
|
|
90
|
-
|
|
91
|
-
***
|
|
92
|
-
|
|
93
|
-
### IsAny\<T\>
|
|
94
|
-
|
|
95
|
-
```ts
|
|
96
|
-
type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
Defined in: [packages/utils/src/typeUtils.ts:14](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L14)
|
|
100
|
-
|
|
101
|
-
#### Type Parameters
|
|
102
|
-
|
|
103
|
-
##### T
|
|
104
|
-
|
|
105
|
-
`T`
|
|
106
|
-
|
|
107
|
-
***
|
|
108
|
-
|
|
109
|
-
### NonPartial\<T\>
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
type NonPartial<T> = { [K in keyof Required<T>]: T[K] };
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Defined in: [packages/utils/src/typeUtils.ts:5](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L5)
|
|
116
|
-
|
|
117
|
-
#### Type Parameters
|
|
118
|
-
|
|
119
|
-
##### T
|
|
120
|
-
|
|
121
|
-
`T`
|
|
122
|
-
|
|
123
|
-
***
|
|
124
|
-
|
|
125
|
-
### ObjKeysWithValuesOfType\<Obj, ValueType\>
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
type ObjKeysWithValuesOfType<Obj, ValueType> = { [K in keyof Obj]: Obj[K] extends ValueType ? K : never }[keyof Obj];
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
Defined in: [packages/utils/src/typeUtils.ts:7](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L7)
|
|
132
|
-
|
|
133
|
-
#### Type Parameters
|
|
134
|
-
|
|
135
|
-
##### Obj
|
|
136
|
-
|
|
137
|
-
`Obj` *extends* `Record`\<`PropertyKey`, `unknown`\>
|
|
138
|
-
|
|
139
|
-
##### ValueType
|
|
140
|
-
|
|
141
|
-
`ValueType`
|
|
142
|
-
|
|
143
|
-
***
|
|
144
|
-
|
|
145
|
-
### PartialPossiblyUndefinedValues\<T\>
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
type PartialPossiblyUndefinedValues<T> = Prettify<Partial<Pick<T, KeysWithUndefinedValues<T>>> & Omit<T, KeysWithUndefinedValues<T>>>;
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Defined in: [packages/utils/src/typeUtils.ts:156](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L156)
|
|
152
|
-
|
|
153
|
-
Marks all possible undefined values as partial at the root level of the object.
|
|
154
|
-
|
|
155
|
-
#### Type Parameters
|
|
156
|
-
|
|
157
|
-
##### T
|
|
158
|
-
|
|
159
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|
|
160
|
-
|
|
161
|
-
***
|
|
162
|
-
|
|
163
|
-
### PartialRecord\<K, T\>
|
|
164
|
-
|
|
165
|
-
```ts
|
|
166
|
-
type PartialRecord<K, T> = { [P in K]?: T };
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
Defined in: [packages/utils/src/typeUtils.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L1)
|
|
170
|
-
|
|
171
|
-
#### Type Parameters
|
|
172
|
-
|
|
173
|
-
##### K
|
|
174
|
-
|
|
175
|
-
`K` *extends* keyof `any`
|
|
176
|
-
|
|
177
|
-
##### T
|
|
178
|
-
|
|
179
|
-
`T`
|
|
180
|
-
|
|
181
|
-
***
|
|
182
|
-
|
|
183
|
-
### Prettify\<T\>
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
type Prettify<T> = { [P in keyof T]: T[P] } & object;
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Defined in: [packages/utils/src/typeUtils.ts:21](https://github.com/lucasols/utils/blob/main/packages/utils/src/typeUtils.ts#L21)
|
|
190
|
-
|
|
191
|
-
#### Type Parameters
|
|
192
|
-
|
|
193
|
-
##### T
|
|
194
|
-
|
|
195
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|