@ls-stack/utils 3.40.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/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 +5 -1
- 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 -115
- 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/enhancedMap.md
DELETED
|
@@ -1,358 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / enhancedMap
|
|
6
|
-
|
|
7
|
-
# enhancedMap
|
|
8
|
-
|
|
9
|
-
## Classes
|
|
10
|
-
|
|
11
|
-
### EnhancedMap\<K, V\>
|
|
12
|
-
|
|
13
|
-
Defined in: [packages/utils/src/enhancedMap.ts:5](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L5)
|
|
14
|
-
|
|
15
|
-
#### Extends
|
|
16
|
-
|
|
17
|
-
- `Map`\<`K`, `V`\>
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### K
|
|
22
|
-
|
|
23
|
-
`K`
|
|
24
|
-
|
|
25
|
-
##### V
|
|
26
|
-
|
|
27
|
-
`V`
|
|
28
|
-
|
|
29
|
-
#### Constructors
|
|
30
|
-
|
|
31
|
-
##### Constructor
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
new EnhancedMap<K, V>(entries?): EnhancedMap<K, V>;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es2015.collection.d.ts:50
|
|
38
|
-
|
|
39
|
-
###### Parameters
|
|
40
|
-
|
|
41
|
-
###### entries?
|
|
42
|
-
|
|
43
|
-
`null` | readonly readonly \[`K`, `V`\][]
|
|
44
|
-
|
|
45
|
-
###### Returns
|
|
46
|
-
|
|
47
|
-
[`EnhancedMap`](#enhancedmap)\<`K`, `V`\>
|
|
48
|
-
|
|
49
|
-
###### Inherited from
|
|
50
|
-
|
|
51
|
-
```ts
|
|
52
|
-
Map<K, V>.constructor
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
##### Constructor
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
new EnhancedMap<K, V>(iterable?): EnhancedMap<K, V>;
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Defined in: node\_modules/.pnpm/typescript@5.7.3/node\_modules/typescript/lib/lib.es2015.collection.d.ts:49
|
|
62
|
-
|
|
63
|
-
###### Parameters
|
|
64
|
-
|
|
65
|
-
###### iterable?
|
|
66
|
-
|
|
67
|
-
`null` | `Iterable`\<readonly \[`K`, `V`\], `any`, `any`\>
|
|
68
|
-
|
|
69
|
-
###### Returns
|
|
70
|
-
|
|
71
|
-
[`EnhancedMap`](#enhancedmap)\<`K`, `V`\>
|
|
72
|
-
|
|
73
|
-
###### Inherited from
|
|
74
|
-
|
|
75
|
-
```ts
|
|
76
|
-
Map<K, V>.constructor
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
#### Methods
|
|
80
|
-
|
|
81
|
-
##### find()
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
find(predicate):
|
|
85
|
-
| undefined
|
|
86
|
-
| {
|
|
87
|
-
key: K;
|
|
88
|
-
value: V;
|
|
89
|
-
};
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
Defined in: [packages/utils/src/enhancedMap.ts:6](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L6)
|
|
93
|
-
|
|
94
|
-
###### Parameters
|
|
95
|
-
|
|
96
|
-
###### predicate
|
|
97
|
-
|
|
98
|
-
(`value`, `key`) => `boolean`
|
|
99
|
-
|
|
100
|
-
###### Returns
|
|
101
|
-
|
|
102
|
-
\| `undefined`
|
|
103
|
-
\| \{
|
|
104
|
-
`key`: `K`;
|
|
105
|
-
`value`: `V`;
|
|
106
|
-
\}
|
|
107
|
-
|
|
108
|
-
##### getOrInsert()
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
getOrInsert(key, fallback): V;
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Defined in: [packages/utils/src/enhancedMap.ts:44](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L44)
|
|
115
|
-
|
|
116
|
-
###### Parameters
|
|
117
|
-
|
|
118
|
-
###### key
|
|
119
|
-
|
|
120
|
-
`K`
|
|
121
|
-
|
|
122
|
-
###### fallback
|
|
123
|
-
|
|
124
|
-
() => `V`
|
|
125
|
-
|
|
126
|
-
###### Returns
|
|
127
|
-
|
|
128
|
-
`V`
|
|
129
|
-
|
|
130
|
-
##### getOrThrow()
|
|
131
|
-
|
|
132
|
-
```ts
|
|
133
|
-
getOrThrow(key): V;
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Defined in: [packages/utils/src/enhancedMap.ts:34](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L34)
|
|
137
|
-
|
|
138
|
-
###### Parameters
|
|
139
|
-
|
|
140
|
-
###### key
|
|
141
|
-
|
|
142
|
-
`K`
|
|
143
|
-
|
|
144
|
-
###### Returns
|
|
145
|
-
|
|
146
|
-
`V`
|
|
147
|
-
|
|
148
|
-
##### setMultiple()
|
|
149
|
-
|
|
150
|
-
###### Call Signature
|
|
151
|
-
|
|
152
|
-
```ts
|
|
153
|
-
setMultiple(values): this;
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Defined in: [packages/utils/src/enhancedMap.ts:18](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L18)
|
|
157
|
-
|
|
158
|
-
###### Parameters
|
|
159
|
-
|
|
160
|
-
###### values
|
|
161
|
-
|
|
162
|
-
`Record`\<`K` & `string`, `V`\>
|
|
163
|
-
|
|
164
|
-
###### Returns
|
|
165
|
-
|
|
166
|
-
`this`
|
|
167
|
-
|
|
168
|
-
###### Call Signature
|
|
169
|
-
|
|
170
|
-
```ts
|
|
171
|
-
setMultiple(...values): this;
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Defined in: [packages/utils/src/enhancedMap.ts:19](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L19)
|
|
175
|
-
|
|
176
|
-
###### Parameters
|
|
177
|
-
|
|
178
|
-
###### values
|
|
179
|
-
|
|
180
|
-
...\[`K`, `V`\][]
|
|
181
|
-
|
|
182
|
-
###### Returns
|
|
183
|
-
|
|
184
|
-
`this`
|
|
185
|
-
|
|
186
|
-
##### toFilteredValues()
|
|
187
|
-
|
|
188
|
-
```ts
|
|
189
|
-
toFilteredValues(predicate): V[];
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
Defined in: [packages/utils/src/enhancedMap.ts:52](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L52)
|
|
193
|
-
|
|
194
|
-
###### Parameters
|
|
195
|
-
|
|
196
|
-
###### predicate
|
|
197
|
-
|
|
198
|
-
(`value`, `key`) => `boolean`
|
|
199
|
-
|
|
200
|
-
###### Returns
|
|
201
|
-
|
|
202
|
-
`V`[]
|
|
203
|
-
|
|
204
|
-
##### toKeys()
|
|
205
|
-
|
|
206
|
-
```ts
|
|
207
|
-
toKeys(): K[];
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
Defined in: [packages/utils/src/enhancedMap.ts:104](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L104)
|
|
211
|
-
|
|
212
|
-
###### Returns
|
|
213
|
-
|
|
214
|
-
`K`[]
|
|
215
|
-
|
|
216
|
-
##### toMap()
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
toMap<T>(mapFunction): T[];
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
Defined in: [packages/utils/src/enhancedMap.ts:64](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L64)
|
|
223
|
-
|
|
224
|
-
###### Type Parameters
|
|
225
|
-
|
|
226
|
-
###### T
|
|
227
|
-
|
|
228
|
-
`T`
|
|
229
|
-
|
|
230
|
-
###### Parameters
|
|
231
|
-
|
|
232
|
-
###### mapFunction
|
|
233
|
-
|
|
234
|
-
(`value`, `key`, `reject`) => *typeof* [`enhancedMapReject`](#enhancedmapreject) \| `T`
|
|
235
|
-
|
|
236
|
-
###### Returns
|
|
237
|
-
|
|
238
|
-
`T`[]
|
|
239
|
-
|
|
240
|
-
##### toObjMap()
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
toObjMap<ObjKey, ObjValue>(mapFunction): Record<ObjKey, ObjValue>;
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
Defined in: [packages/utils/src/enhancedMap.ts:84](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L84)
|
|
247
|
-
|
|
248
|
-
###### Type Parameters
|
|
249
|
-
|
|
250
|
-
###### ObjKey
|
|
251
|
-
|
|
252
|
-
`ObjKey` *extends* `PropertyKey`
|
|
253
|
-
|
|
254
|
-
###### ObjValue
|
|
255
|
-
|
|
256
|
-
`ObjValue`
|
|
257
|
-
|
|
258
|
-
###### Parameters
|
|
259
|
-
|
|
260
|
-
###### mapFunction
|
|
261
|
-
|
|
262
|
-
(`value`, `key`) => `false` \| \[`ObjKey`, `ObjValue`\]
|
|
263
|
-
|
|
264
|
-
###### Returns
|
|
265
|
-
|
|
266
|
-
`Record`\<`ObjKey`, `ObjValue`\>
|
|
267
|
-
|
|
268
|
-
##### toValues()
|
|
269
|
-
|
|
270
|
-
```ts
|
|
271
|
-
toValues(): V[];
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Defined in: [packages/utils/src/enhancedMap.ts:100](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L100)
|
|
275
|
-
|
|
276
|
-
###### Returns
|
|
277
|
-
|
|
278
|
-
`V`[]
|
|
279
|
-
|
|
280
|
-
##### from()
|
|
281
|
-
|
|
282
|
-
###### Call Signature
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
static from<T, K>(array, key): EnhancedMap<T[K], T>;
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Defined in: [packages/utils/src/enhancedMap.ts:108](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L108)
|
|
289
|
-
|
|
290
|
-
###### Type Parameters
|
|
291
|
-
|
|
292
|
-
###### T
|
|
293
|
-
|
|
294
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|
|
295
|
-
|
|
296
|
-
###### K
|
|
297
|
-
|
|
298
|
-
`K` *extends* `string` \| `number` \| `symbol`
|
|
299
|
-
|
|
300
|
-
###### Parameters
|
|
301
|
-
|
|
302
|
-
###### array
|
|
303
|
-
|
|
304
|
-
`undefined` | `null` | `Iterable`\<`T`, `any`, `any`\> | `T`[]
|
|
305
|
-
|
|
306
|
-
###### key
|
|
307
|
-
|
|
308
|
-
`K`
|
|
309
|
-
|
|
310
|
-
###### Returns
|
|
311
|
-
|
|
312
|
-
[`EnhancedMap`](#enhancedmap)\<`T`\[`K`\], `T`\>
|
|
313
|
-
|
|
314
|
-
###### Call Signature
|
|
315
|
-
|
|
316
|
-
```ts
|
|
317
|
-
static from<T, K, V>(array, mapFunction): EnhancedMap<K, V>;
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
Defined in: [packages/utils/src/enhancedMap.ts:112](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L112)
|
|
321
|
-
|
|
322
|
-
###### Type Parameters
|
|
323
|
-
|
|
324
|
-
###### T
|
|
325
|
-
|
|
326
|
-
`T`
|
|
327
|
-
|
|
328
|
-
###### K
|
|
329
|
-
|
|
330
|
-
`K`
|
|
331
|
-
|
|
332
|
-
###### V
|
|
333
|
-
|
|
334
|
-
`V`
|
|
335
|
-
|
|
336
|
-
###### Parameters
|
|
337
|
-
|
|
338
|
-
###### array
|
|
339
|
-
|
|
340
|
-
`undefined` | `null` | `T`[] | `Iterable`\<`T`, `any`, `any`\>
|
|
341
|
-
|
|
342
|
-
###### mapFunction
|
|
343
|
-
|
|
344
|
-
(`item`) => `false` \| \[`K`, `V`\]
|
|
345
|
-
|
|
346
|
-
###### Returns
|
|
347
|
-
|
|
348
|
-
[`EnhancedMap`](#enhancedmap)\<`K`, `V`\>
|
|
349
|
-
|
|
350
|
-
## Variables
|
|
351
|
-
|
|
352
|
-
### enhancedMapReject
|
|
353
|
-
|
|
354
|
-
```ts
|
|
355
|
-
const enhancedMapReject: typeof enhancedMapReject;
|
|
356
|
-
```
|
|
357
|
-
|
|
358
|
-
Defined in: [packages/utils/src/enhancedMap.ts:3](https://github.com/lucasols/utils/blob/main/packages/utils/src/enhancedMap.ts#L3)
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [exhaustiveMatch](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### Pattern\<R\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type Pattern<R> = { [K in T]: (() => R) | "_nxt" | "_never" };
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/exhaustiveMatch.ts:2](https://github.com/lucasols/utils/blob/main/packages/utils/src/exhaustiveMatch.ts#L2)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### R
|
|
22
|
-
|
|
23
|
-
`R`
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### Pattern\<R\>
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
type Pattern<R> = { [P in K]: ((props: Extract<T, Record<D, P>>) => R) | "_never" };
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/exhaustiveMatch.ts:56](https://github.com/lucasols/utils/blob/main/packages/utils/src/exhaustiveMatch.ts#L56)
|
|
34
|
-
|
|
35
|
-
#### Type Parameters
|
|
36
|
-
|
|
37
|
-
##### R
|
|
38
|
-
|
|
39
|
-
`R`
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / exhaustiveMatch
|
|
6
|
-
|
|
7
|
-
# exhaustiveMatch
|
|
8
|
-
|
|
9
|
-
## Modules
|
|
10
|
-
|
|
11
|
-
- [\<internal\>](-internal-.md)
|
|
12
|
-
|
|
13
|
-
## Functions
|
|
14
|
-
|
|
15
|
-
### exhaustiveMatch()
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
function exhaustiveMatch<T>(value): object;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Defined in: [packages/utils/src/exhaustiveMatch.ts:1](https://github.com/lucasols/utils/blob/main/packages/utils/src/exhaustiveMatch.ts#L1)
|
|
22
|
-
|
|
23
|
-
#### Type Parameters
|
|
24
|
-
|
|
25
|
-
##### T
|
|
26
|
-
|
|
27
|
-
`T` *extends* `string`
|
|
28
|
-
|
|
29
|
-
#### Parameters
|
|
30
|
-
|
|
31
|
-
##### value
|
|
32
|
-
|
|
33
|
-
`T`
|
|
34
|
-
|
|
35
|
-
#### Returns
|
|
36
|
-
|
|
37
|
-
##### with()
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
with: <R>(pattern) => R = matchWith;
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The pattern can be:
|
|
44
|
-
- a function that returns the result
|
|
45
|
-
- '_nxt' to try the next pattern
|
|
46
|
-
- '_never' to indicate that this pattern should never be matched
|
|
47
|
-
|
|
48
|
-
###### Type Parameters
|
|
49
|
-
|
|
50
|
-
###### R
|
|
51
|
-
|
|
52
|
-
`R`
|
|
53
|
-
|
|
54
|
-
###### Parameters
|
|
55
|
-
|
|
56
|
-
###### pattern
|
|
57
|
-
|
|
58
|
-
[`Pattern`](-internal-.md#pattern)\<`R`\>
|
|
59
|
-
|
|
60
|
-
###### Returns
|
|
61
|
-
|
|
62
|
-
`R`
|
|
63
|
-
|
|
64
|
-
##### withObject()
|
|
65
|
-
|
|
66
|
-
```ts
|
|
67
|
-
withObject: <R>(pattern) => R;
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
match with early evaluation of the values
|
|
71
|
-
|
|
72
|
-
###### Type Parameters
|
|
73
|
-
|
|
74
|
-
###### R
|
|
75
|
-
|
|
76
|
-
`R`
|
|
77
|
-
|
|
78
|
-
###### Parameters
|
|
79
|
-
|
|
80
|
-
###### pattern
|
|
81
|
-
|
|
82
|
-
`Record`\<`T`, `R`\>
|
|
83
|
-
|
|
84
|
-
###### Returns
|
|
85
|
-
|
|
86
|
-
`R`
|
|
87
|
-
|
|
88
|
-
***
|
|
89
|
-
|
|
90
|
-
### exhaustiveMatchObjUnion()
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
function exhaustiveMatchObjUnion<T, D, K>(obj, key): object;
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Defined in: [packages/utils/src/exhaustiveMatch.ts:51](https://github.com/lucasols/utils/blob/main/packages/utils/src/exhaustiveMatch.ts#L51)
|
|
97
|
-
|
|
98
|
-
#### Type Parameters
|
|
99
|
-
|
|
100
|
-
##### T
|
|
101
|
-
|
|
102
|
-
`T` *extends* `Record`\<`string`, `unknown`\>
|
|
103
|
-
|
|
104
|
-
##### D
|
|
105
|
-
|
|
106
|
-
`D` *extends* `string` \| `number` \| `symbol`
|
|
107
|
-
|
|
108
|
-
##### K
|
|
109
|
-
|
|
110
|
-
`K` *extends* `string`
|
|
111
|
-
|
|
112
|
-
#### Parameters
|
|
113
|
-
|
|
114
|
-
##### obj
|
|
115
|
-
|
|
116
|
-
`T`
|
|
117
|
-
|
|
118
|
-
##### key
|
|
119
|
-
|
|
120
|
-
`D`
|
|
121
|
-
|
|
122
|
-
#### Returns
|
|
123
|
-
|
|
124
|
-
`object`
|
|
125
|
-
|
|
126
|
-
##### with()
|
|
127
|
-
|
|
128
|
-
```ts
|
|
129
|
-
with: <R>(pattern) => R = withLazy;
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
###### Type Parameters
|
|
133
|
-
|
|
134
|
-
###### R
|
|
135
|
-
|
|
136
|
-
`R`
|
|
137
|
-
|
|
138
|
-
###### Parameters
|
|
139
|
-
|
|
140
|
-
###### pattern
|
|
141
|
-
|
|
142
|
-
[`Pattern`](-internal-.md#pattern-1)\<`R`\>
|
|
143
|
-
|
|
144
|
-
###### Returns
|
|
145
|
-
|
|
146
|
-
`R`
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](modules.md) / filterObjectOrArrayKeys
|
|
6
|
-
|
|
7
|
-
# filterObjectOrArrayKeys
|
|
8
|
-
|
|
9
|
-
## Functions
|
|
10
|
-
|
|
11
|
-
### filterObjectOrArrayKeys()
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
function filterObjectOrArrayKeys(objOrArray, options): Record<string, any> | Record<string, any>[];
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/filterObjectOrArrayKeys.ts:60](https://github.com/lucasols/utils/blob/main/packages/utils/src/filterObjectOrArrayKeys.ts#L60)
|
|
18
|
-
|
|
19
|
-
Filters the keys of an object based on the provided patterns.
|
|
20
|
-
|
|
21
|
-
Filtering patterns in `rejectKeys` and `filterKeys`:
|
|
22
|
-
- `'prop'` - Only root-level properties named 'prop'
|
|
23
|
-
- `'**prop'` - Any property named exactly 'prop' at any level (root or nested)
|
|
24
|
-
- `'*.prop'` - Any nested property named 'prop' at second level (excludes root-level matches)
|
|
25
|
-
- `'test.*.prop'` - Any property named 'prop' at second level of 'test'
|
|
26
|
-
- `'test.*.test.**prop'` - Any property named 'prop' inside of 'test.*.test'
|
|
27
|
-
- `'prop.nested'` - Exact nested property paths like `obj.prop.nested`
|
|
28
|
-
- `'prop.**nested'` - All nested properties inside root `prop` with name `nested`
|
|
29
|
-
- `'prop[0]'` - The first item of the `prop` array
|
|
30
|
-
- `'prop[*]'` - All items of the `prop` array
|
|
31
|
-
- `'prop[0].nested'` - `nested` prop of the first item of the `prop` array
|
|
32
|
-
- `'prop[*].nested'` - `nested` prop of all items of the `prop` array
|
|
33
|
-
- `'prop[*]**nested'` - all `nested` props of all items of the `prop` array
|
|
34
|
-
- `'prop[0-2]'` - The first three items of the `prop` array
|
|
35
|
-
- `'prop[4-*]'` - All items of the `prop` array from the fourth index to the end
|
|
36
|
-
- `'prop[0-2].nested.**prop'` - Combining multiple nested patterns is supported
|
|
37
|
-
- Root array:
|
|
38
|
-
- `'[0]'` - The first item of the root array
|
|
39
|
-
- `'[*]'` - All items of the array
|
|
40
|
-
- `'[0].nested'` - `nested` prop of the first item of the array
|
|
41
|
-
- `'[*].nested'` - `nested` prop of all items of the array
|
|
42
|
-
- `'[*]**nested'` - all `nested` props of all items of the array
|
|
43
|
-
- `'[0-2]'` - The first three items of the array
|
|
44
|
-
- `'[4-*]'` - All items of the array from the fourth index to the end
|
|
45
|
-
- Pattern expansion with parentheses:
|
|
46
|
-
- `'prop.test.(prop1|prop2|prop3)'` - Expands to `prop.test.prop1`, `prop.test.prop2`, and `prop.test.prop3`
|
|
47
|
-
- `'components[*].(table_id|columns|filters[*].value)'` - Expands to `components[*].table_id`, `components[*].columns`, and `components[*].filters[*].value`
|
|
48
|
-
- `'(users|admins)[*].name'` - Expands to `users[*].name` and `admins[*].name`
|
|
49
|
-
- Array filtering by value:
|
|
50
|
-
- `'users[%name="John"]'` - Filters the `users` with the `name` property equal to `John`
|
|
51
|
-
- `'users[%name="John" | "Jane"]'` - Value-level OR using `|` for multiple values of same property
|
|
52
|
-
- `'users[%name="Alice" || %age=35]'` - Property-level OR using `||` for different properties
|
|
53
|
-
- `'users[%age=30 && %role="admin"]'` - Property-level AND using `&&` for different properties
|
|
54
|
-
- Note: Mixing `&&` and `||` in the same filter is not supported - use separate filter patterns instead
|
|
55
|
-
- `'users[%config.name="John" | "Jane"]'` - Dot notation is supported
|
|
56
|
-
- `'users[%name*="oh"]'` - Contains operator (*=) - filters users where name contains "oh"
|
|
57
|
-
- `'users[%name^="Jo"]'` - Starts with operator (^=) - filters users where name starts with "Jo"
|
|
58
|
-
- `'users[%name$="hn"]'` - Ends with operator ($=) - filters users where name ends with "hn"
|
|
59
|
-
- `'users[%name!="John"]'` - Not equal operator (!=) - filters users where name is not "John"
|
|
60
|
-
- `'users[%name!*="admin"]'` - Not contains operator (!*=) - filters users where name doesn't contain "admin"
|
|
61
|
-
- `'users[i%name="john"]'` - Case-insensitive matching (i% prefix) - matches "John", "JOHN", "john", etc.
|
|
62
|
-
|
|
63
|
-
#### Parameters
|
|
64
|
-
|
|
65
|
-
##### objOrArray
|
|
66
|
-
|
|
67
|
-
The object or array to filter.
|
|
68
|
-
|
|
69
|
-
`Record`\<`string`, `any`\> | `Record`\<`string`, `any`\>[]
|
|
70
|
-
|
|
71
|
-
##### options
|
|
72
|
-
|
|
73
|
-
The options for the filter.
|
|
74
|
-
|
|
75
|
-
###### filterKeys?
|
|
76
|
-
|
|
77
|
-
`string` \| `string`[]
|
|
78
|
-
|
|
79
|
-
The keys to filter.
|
|
80
|
-
|
|
81
|
-
###### rejectEmptyObjectsInArray?
|
|
82
|
-
|
|
83
|
-
`boolean` = `true`
|
|
84
|
-
|
|
85
|
-
Whether to reject empty objects in arrays (default: true).
|
|
86
|
-
|
|
87
|
-
###### rejectKeys?
|
|
88
|
-
|
|
89
|
-
`string` \| `string`[]
|
|
90
|
-
|
|
91
|
-
The keys to reject.
|
|
92
|
-
|
|
93
|
-
###### sortKeys?
|
|
94
|
-
|
|
95
|
-
`false` \| `"asc"` \| `"simpleValuesFirst"` \| `"desc"` = `'simpleValuesFirst'`
|
|
96
|
-
|
|
97
|
-
Sort all keys by a specific order (optional, preserves original order when not specified).
|
|
98
|
-
|
|
99
|
-
###### sortPatterns?
|
|
100
|
-
|
|
101
|
-
`string`[]
|
|
102
|
-
|
|
103
|
-
Sort specific keys by pattern. Use to control the order of specific properties. The same patterns as `filterKeys` are supported.
|
|
104
|
-
|
|
105
|
-
#### Returns
|
|
106
|
-
|
|
107
|
-
`Record`\<`string`, `any`\> \| `Record`\<`string`, `any`\>[]
|
|
108
|
-
|
|
109
|
-
The filtered object or array.
|