@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
|
@@ -1,550 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / arrayUtils
|
|
6
|
-
|
|
7
|
-
# arrayUtils
|
|
8
|
-
|
|
9
|
-
## Modules
|
|
10
|
-
|
|
11
|
-
- [\<internal\>](-internal-.md)
|
|
12
|
-
|
|
13
|
-
## Type Aliases
|
|
14
|
-
|
|
15
|
-
### FilterAndMapReturn\<T\>
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
type FilterAndMapReturn<T> = false | T;
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Defined in: [packages/utils/src/arrayUtils.ts:42](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L42)
|
|
22
|
-
|
|
23
|
-
#### Type Parameters
|
|
24
|
-
|
|
25
|
-
##### T
|
|
26
|
-
|
|
27
|
-
`T`
|
|
28
|
-
|
|
29
|
-
## Functions
|
|
30
|
-
|
|
31
|
-
### arrayOps()
|
|
32
|
-
|
|
33
|
-
```ts
|
|
34
|
-
function arrayOps<T>(array): ArrayOps<T>;
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Defined in: [packages/utils/src/arrayUtils.ts:318](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L318)
|
|
38
|
-
|
|
39
|
-
Enhance an array with extra methods
|
|
40
|
-
|
|
41
|
-
#### Type Parameters
|
|
42
|
-
|
|
43
|
-
##### T
|
|
44
|
-
|
|
45
|
-
`T`
|
|
46
|
-
|
|
47
|
-
#### Parameters
|
|
48
|
-
|
|
49
|
-
##### array
|
|
50
|
-
|
|
51
|
-
`T`[]
|
|
52
|
-
|
|
53
|
-
#### Returns
|
|
54
|
-
|
|
55
|
-
[`ArrayOps`](-internal-.md#arrayops)\<`T`\>
|
|
56
|
-
|
|
57
|
-
#### Example
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
const enhancedItems = arrayOps(array);
|
|
61
|
-
|
|
62
|
-
enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
63
|
-
enhancedItems.sortBy((item) => item);
|
|
64
|
-
enhancedItems.rejectDuplicates((item) => item);
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
***
|
|
68
|
-
|
|
69
|
-
### arrayWithPrev()
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
function arrayWithPrev<T>(array): [T, null | T][];
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Defined in: [packages/utils/src/arrayUtils.ts:138](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L138)
|
|
76
|
-
|
|
77
|
-
#### Type Parameters
|
|
78
|
-
|
|
79
|
-
##### T
|
|
80
|
-
|
|
81
|
-
`T`
|
|
82
|
-
|
|
83
|
-
#### Parameters
|
|
84
|
-
|
|
85
|
-
##### array
|
|
86
|
-
|
|
87
|
-
`T`[]
|
|
88
|
-
|
|
89
|
-
#### Returns
|
|
90
|
-
|
|
91
|
-
\[`T`, `null` \| `T`\][]
|
|
92
|
-
|
|
93
|
-
***
|
|
94
|
-
|
|
95
|
-
### arrayWithPrevAndIndex()
|
|
96
|
-
|
|
97
|
-
```ts
|
|
98
|
-
function arrayWithPrevAndIndex<T>(array): object[];
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Defined in: [packages/utils/src/arrayUtils.ts:142](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L142)
|
|
102
|
-
|
|
103
|
-
#### Type Parameters
|
|
104
|
-
|
|
105
|
-
##### T
|
|
106
|
-
|
|
107
|
-
`T`
|
|
108
|
-
|
|
109
|
-
#### Parameters
|
|
110
|
-
|
|
111
|
-
##### array
|
|
112
|
-
|
|
113
|
-
`T`[]
|
|
114
|
-
|
|
115
|
-
#### Returns
|
|
116
|
-
|
|
117
|
-
`object`[]
|
|
118
|
-
|
|
119
|
-
***
|
|
120
|
-
|
|
121
|
-
### filterAndMap()
|
|
122
|
-
|
|
123
|
-
```ts
|
|
124
|
-
function filterAndMap<T, R>(array, mapFilter): R[];
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
Defined in: [packages/utils/src/arrayUtils.ts:23](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L23)
|
|
128
|
-
|
|
129
|
-
allow to filter and map with better typing ergonomics
|
|
130
|
-
|
|
131
|
-
In the `mapFilter` function return `false` to reject the item, or any other
|
|
132
|
-
value to map it.
|
|
133
|
-
|
|
134
|
-
#### Type Parameters
|
|
135
|
-
|
|
136
|
-
##### T
|
|
137
|
-
|
|
138
|
-
`T`
|
|
139
|
-
|
|
140
|
-
##### R
|
|
141
|
-
|
|
142
|
-
`R`
|
|
143
|
-
|
|
144
|
-
#### Parameters
|
|
145
|
-
|
|
146
|
-
##### array
|
|
147
|
-
|
|
148
|
-
`IterableIterator`\<`T`, `any`, `any`\> | readonly `T`[]
|
|
149
|
-
|
|
150
|
-
##### mapFilter
|
|
151
|
-
|
|
152
|
-
(`item`, `index`) => `false` \| `R`
|
|
153
|
-
|
|
154
|
-
#### Returns
|
|
155
|
-
|
|
156
|
-
`R`[]
|
|
157
|
-
|
|
158
|
-
#### Example
|
|
159
|
-
|
|
160
|
-
```ts
|
|
161
|
-
// Filter reject and turn value into `value mapped`
|
|
162
|
-
const items = ['value', 'value', 'reject', 'reject'];
|
|
163
|
-
|
|
164
|
-
const mappedItems = filterAndMap(items, (item) =>
|
|
165
|
-
item === 'reject'
|
|
166
|
-
? false
|
|
167
|
-
: `${item} mapped`,
|
|
168
|
-
);
|
|
169
|
-
|
|
170
|
-
mappedItems; // ['value mapped', 'value mapped']
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
***
|
|
174
|
-
|
|
175
|
-
### findAfterIndex()
|
|
176
|
-
|
|
177
|
-
```ts
|
|
178
|
-
function findAfterIndex<T>(
|
|
179
|
-
array,
|
|
180
|
-
index,
|
|
181
|
-
predicate): undefined | T;
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Defined in: [packages/utils/src/arrayUtils.ts:165](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L165)
|
|
185
|
-
|
|
186
|
-
#### Type Parameters
|
|
187
|
-
|
|
188
|
-
##### T
|
|
189
|
-
|
|
190
|
-
`T`
|
|
191
|
-
|
|
192
|
-
#### Parameters
|
|
193
|
-
|
|
194
|
-
##### array
|
|
195
|
-
|
|
196
|
-
`T`[]
|
|
197
|
-
|
|
198
|
-
##### index
|
|
199
|
-
|
|
200
|
-
`number`
|
|
201
|
-
|
|
202
|
-
##### predicate
|
|
203
|
-
|
|
204
|
-
(`item`) => `boolean`
|
|
205
|
-
|
|
206
|
-
#### Returns
|
|
207
|
-
|
|
208
|
-
`undefined` \| `T`
|
|
209
|
-
|
|
210
|
-
***
|
|
211
|
-
|
|
212
|
-
### findAndMap()
|
|
213
|
-
|
|
214
|
-
```ts
|
|
215
|
-
function findAndMap<T, R>(array, predicate): undefined | R;
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
Defined in: [packages/utils/src/arrayUtils.ts:295](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L295)
|
|
219
|
-
|
|
220
|
-
Finds the first item in an array where the predicate returns a non-false value and returns that mapped value.
|
|
221
|
-
|
|
222
|
-
Combines find and map operations - applies the predicate to each item until one returns
|
|
223
|
-
a value that is not `false`, then returns that mapped value. If no item matches, returns `undefined`.
|
|
224
|
-
|
|
225
|
-
#### Type Parameters
|
|
226
|
-
|
|
227
|
-
##### T
|
|
228
|
-
|
|
229
|
-
`T`
|
|
230
|
-
|
|
231
|
-
##### R
|
|
232
|
-
|
|
233
|
-
`R`
|
|
234
|
-
|
|
235
|
-
#### Parameters
|
|
236
|
-
|
|
237
|
-
##### array
|
|
238
|
-
|
|
239
|
-
`T`[]
|
|
240
|
-
|
|
241
|
-
The array to search through
|
|
242
|
-
|
|
243
|
-
##### predicate
|
|
244
|
-
|
|
245
|
-
(`value`) => `false` \| `R`
|
|
246
|
-
|
|
247
|
-
Function that returns a mapped value or `false` to skip the item
|
|
248
|
-
|
|
249
|
-
#### Returns
|
|
250
|
-
|
|
251
|
-
`undefined` \| `R`
|
|
252
|
-
|
|
253
|
-
The first mapped value that is not `false`, or `undefined` if no item matches
|
|
254
|
-
|
|
255
|
-
#### Example
|
|
256
|
-
|
|
257
|
-
```ts
|
|
258
|
-
const users = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
|
|
259
|
-
|
|
260
|
-
const foundName = findAndMap(users, (user) =>
|
|
261
|
-
user.id === 2 ? user.name.toUpperCase() : false
|
|
262
|
-
);
|
|
263
|
-
// foundName is 'BOB'
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
***
|
|
267
|
-
|
|
268
|
-
### findBeforeIndex()
|
|
269
|
-
|
|
270
|
-
```ts
|
|
271
|
-
function findBeforeIndex<T>(
|
|
272
|
-
array,
|
|
273
|
-
index,
|
|
274
|
-
predicate): undefined | T;
|
|
275
|
-
```
|
|
276
|
-
|
|
277
|
-
Defined in: [packages/utils/src/arrayUtils.ts:179](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L179)
|
|
278
|
-
|
|
279
|
-
#### Type Parameters
|
|
280
|
-
|
|
281
|
-
##### T
|
|
282
|
-
|
|
283
|
-
`T`
|
|
284
|
-
|
|
285
|
-
#### Parameters
|
|
286
|
-
|
|
287
|
-
##### array
|
|
288
|
-
|
|
289
|
-
`T`[]
|
|
290
|
-
|
|
291
|
-
##### index
|
|
292
|
-
|
|
293
|
-
`number`
|
|
294
|
-
|
|
295
|
-
##### predicate
|
|
296
|
-
|
|
297
|
-
(`item`) => `boolean`
|
|
298
|
-
|
|
299
|
-
#### Returns
|
|
300
|
-
|
|
301
|
-
`undefined` \| `T`
|
|
302
|
-
|
|
303
|
-
***
|
|
304
|
-
|
|
305
|
-
### getAscIndexOrder()
|
|
306
|
-
|
|
307
|
-
```ts
|
|
308
|
-
function getAscIndexOrder(index): number;
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
Defined in: [packages/utils/src/arrayUtils.ts:134](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L134)
|
|
312
|
-
|
|
313
|
-
Get the correct 0 based value for sync with other array in ascending order
|
|
314
|
-
|
|
315
|
-
#### Parameters
|
|
316
|
-
|
|
317
|
-
##### index
|
|
318
|
-
|
|
319
|
-
`undefined` | `number`
|
|
320
|
-
|
|
321
|
-
#### Returns
|
|
322
|
-
|
|
323
|
-
`number`
|
|
324
|
-
|
|
325
|
-
#### Example
|
|
326
|
-
|
|
327
|
-
```ts
|
|
328
|
-
const items = [1, 2, 3];
|
|
329
|
-
|
|
330
|
-
const index = sortBy(
|
|
331
|
-
items,
|
|
332
|
-
(item) => getAscIndexOrder(
|
|
333
|
-
followOrder.findIndex((order) => order === item)
|
|
334
|
-
)
|
|
335
|
-
);
|
|
336
|
-
```
|
|
337
|
-
|
|
338
|
-
***
|
|
339
|
-
|
|
340
|
-
### hasDuplicates()
|
|
341
|
-
|
|
342
|
-
```ts
|
|
343
|
-
function hasDuplicates<T>(array, getKey): boolean;
|
|
344
|
-
```
|
|
345
|
-
|
|
346
|
-
Defined in: [packages/utils/src/arrayUtils.ts:203](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L203)
|
|
347
|
-
|
|
348
|
-
#### Type Parameters
|
|
349
|
-
|
|
350
|
-
##### T
|
|
351
|
-
|
|
352
|
-
`T`
|
|
353
|
-
|
|
354
|
-
#### Parameters
|
|
355
|
-
|
|
356
|
-
##### array
|
|
357
|
-
|
|
358
|
-
`T`[]
|
|
359
|
-
|
|
360
|
-
##### getKey
|
|
361
|
-
|
|
362
|
-
(`item`) => `unknown`
|
|
363
|
-
|
|
364
|
-
#### Returns
|
|
365
|
-
|
|
366
|
-
`boolean`
|
|
367
|
-
|
|
368
|
-
***
|
|
369
|
-
|
|
370
|
-
### isInArray()
|
|
371
|
-
|
|
372
|
-
```ts
|
|
373
|
-
function isInArray<T, U>(value, oneOf): value is U;
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
Defined in: [packages/utils/src/arrayUtils.ts:152](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L152)
|
|
377
|
-
|
|
378
|
-
#### Type Parameters
|
|
379
|
-
|
|
380
|
-
##### T
|
|
381
|
-
|
|
382
|
-
`T`
|
|
383
|
-
|
|
384
|
-
##### U
|
|
385
|
-
|
|
386
|
-
`U`
|
|
387
|
-
|
|
388
|
-
#### Parameters
|
|
389
|
-
|
|
390
|
-
##### value
|
|
391
|
-
|
|
392
|
-
`T`
|
|
393
|
-
|
|
394
|
-
##### oneOf
|
|
395
|
-
|
|
396
|
-
readonly `U`[]
|
|
397
|
-
|
|
398
|
-
#### Returns
|
|
399
|
-
|
|
400
|
-
`value is U`
|
|
401
|
-
|
|
402
|
-
***
|
|
403
|
-
|
|
404
|
-
### rejectArrayUndefinedValues()
|
|
405
|
-
|
|
406
|
-
```ts
|
|
407
|
-
function rejectArrayUndefinedValues<T>(array): T;
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
Defined in: [packages/utils/src/arrayUtils.ts:199](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L199)
|
|
411
|
-
|
|
412
|
-
#### Type Parameters
|
|
413
|
-
|
|
414
|
-
##### T
|
|
415
|
-
|
|
416
|
-
`T` *extends* `unknown`[]
|
|
417
|
-
|
|
418
|
-
#### Parameters
|
|
419
|
-
|
|
420
|
-
##### array
|
|
421
|
-
|
|
422
|
-
`T`
|
|
423
|
-
|
|
424
|
-
#### Returns
|
|
425
|
-
|
|
426
|
-
`T`
|
|
427
|
-
|
|
428
|
-
***
|
|
429
|
-
|
|
430
|
-
### rejectDuplicates()
|
|
431
|
-
|
|
432
|
-
```ts
|
|
433
|
-
function rejectDuplicates<T>(array, getKey): T[];
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
Defined in: [packages/utils/src/arrayUtils.ts:220](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L220)
|
|
437
|
-
|
|
438
|
-
#### Type Parameters
|
|
439
|
-
|
|
440
|
-
##### T
|
|
441
|
-
|
|
442
|
-
`T`
|
|
443
|
-
|
|
444
|
-
#### Parameters
|
|
445
|
-
|
|
446
|
-
##### array
|
|
447
|
-
|
|
448
|
-
`T`[]
|
|
449
|
-
|
|
450
|
-
##### getKey
|
|
451
|
-
|
|
452
|
-
(`item`) => `unknown`
|
|
453
|
-
|
|
454
|
-
#### Returns
|
|
455
|
-
|
|
456
|
-
`T`[]
|
|
457
|
-
|
|
458
|
-
***
|
|
459
|
-
|
|
460
|
-
### sortBy()
|
|
461
|
-
|
|
462
|
-
```ts
|
|
463
|
-
function sortBy<T>(
|
|
464
|
-
arr,
|
|
465
|
-
sortByValue,
|
|
466
|
-
props): T[];
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
Defined in: [packages/utils/src/arrayUtils.ts:76](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L76)
|
|
470
|
-
|
|
471
|
-
Sort an array based on a value
|
|
472
|
-
|
|
473
|
-
Sort by `ascending` order by default
|
|
474
|
-
|
|
475
|
-
Use `Infinity` as as wildcard to absolute max and min values
|
|
476
|
-
|
|
477
|
-
#### Type Parameters
|
|
478
|
-
|
|
479
|
-
##### T
|
|
480
|
-
|
|
481
|
-
`T`
|
|
482
|
-
|
|
483
|
-
#### Parameters
|
|
484
|
-
|
|
485
|
-
##### arr
|
|
486
|
-
|
|
487
|
-
`T`[]
|
|
488
|
-
|
|
489
|
-
##### sortByValue
|
|
490
|
-
|
|
491
|
-
[`SortByValue`](-internal-.md#sortbyvalue)\<`T`\>
|
|
492
|
-
|
|
493
|
-
##### props
|
|
494
|
-
|
|
495
|
-
[`SortByProps`](-internal-.md#sortbyprops) = `'asc'`
|
|
496
|
-
|
|
497
|
-
#### Returns
|
|
498
|
-
|
|
499
|
-
`T`[]
|
|
500
|
-
|
|
501
|
-
#### Example
|
|
502
|
-
|
|
503
|
-
```ts
|
|
504
|
-
const items = [1, 3, 2, 4];
|
|
505
|
-
|
|
506
|
-
const sortedItems = sortBy(items, (item) => item);
|
|
507
|
-
// [1, 2, 3, 4]
|
|
508
|
-
|
|
509
|
-
const items2 = [{ a: 1, b: 2 }, { a: 2, b: 1 }, { a: 1, b: 1}]
|
|
510
|
-
|
|
511
|
-
// return a array to sort by multiple values
|
|
512
|
-
const sortedItems = sortBy(items, (item) => [item.a, item.b]);
|
|
513
|
-
```
|
|
514
|
-
|
|
515
|
-
***
|
|
516
|
-
|
|
517
|
-
### truncateArray()
|
|
518
|
-
|
|
519
|
-
```ts
|
|
520
|
-
function truncateArray<T>(
|
|
521
|
-
array,
|
|
522
|
-
maxLength,
|
|
523
|
-
appendIfTruncated?): T[];
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
Defined in: [packages/utils/src/arrayUtils.ts:240](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L240)
|
|
527
|
-
|
|
528
|
-
#### Type Parameters
|
|
529
|
-
|
|
530
|
-
##### T
|
|
531
|
-
|
|
532
|
-
`T`
|
|
533
|
-
|
|
534
|
-
#### Parameters
|
|
535
|
-
|
|
536
|
-
##### array
|
|
537
|
-
|
|
538
|
-
`T`[]
|
|
539
|
-
|
|
540
|
-
##### maxLength
|
|
541
|
-
|
|
542
|
-
`number`
|
|
543
|
-
|
|
544
|
-
##### appendIfTruncated?
|
|
545
|
-
|
|
546
|
-
`T` | (`truncatedCount`) => `T`
|
|
547
|
-
|
|
548
|
-
#### Returns
|
|
549
|
-
|
|
550
|
-
`T`[]
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
[**@ls-stack/utils**](../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[@ls-stack/utils](../modules.md) / [assertions](README.md) / \<internal\>
|
|
6
|
-
|
|
7
|
-
# \<internal\>
|
|
8
|
-
|
|
9
|
-
## Type Aliases
|
|
10
|
-
|
|
11
|
-
### NotUndefined\<T\>
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
type NotUndefined<T> = T extends undefined ? never : T;
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Defined in: [packages/utils/src/assertions.ts:11](https://github.com/lucasols/utils/blob/main/packages/utils/src/assertions.ts#L11)
|
|
18
|
-
|
|
19
|
-
#### Type Parameters
|
|
20
|
-
|
|
21
|
-
##### T
|
|
22
|
-
|
|
23
|
-
`T`
|
|
24
|
-
|
|
25
|
-
***
|
|
26
|
-
|
|
27
|
-
### StrictNonNullable\<T, N\>
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
type StrictNonNullable<T, N> = undefined extends T ? NonNullable<T> : null extends T ? NonNullable<T> : N;
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Defined in: [packages/utils/src/assertions.ts:50](https://github.com/lucasols/utils/blob/main/packages/utils/src/assertions.ts#L50)
|
|
34
|
-
|
|
35
|
-
#### Type Parameters
|
|
36
|
-
|
|
37
|
-
##### T
|
|
38
|
-
|
|
39
|
-
`T`
|
|
40
|
-
|
|
41
|
-
##### N
|
|
42
|
-
|
|
43
|
-
`N` = `unknown`
|
|
44
|
-
|
|
45
|
-
***
|
|
46
|
-
|
|
47
|
-
### StrictNonUndefined\<T, N\>
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
type StrictNonUndefined<T, N> = undefined extends T ? NotUndefined<T> : N;
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Defined in: [packages/utils/src/assertions.ts:13](https://github.com/lucasols/utils/blob/main/packages/utils/src/assertions.ts#L13)
|
|
54
|
-
|
|
55
|
-
#### Type Parameters
|
|
56
|
-
|
|
57
|
-
##### T
|
|
58
|
-
|
|
59
|
-
`T`
|
|
60
|
-
|
|
61
|
-
##### N
|
|
62
|
-
|
|
63
|
-
`N` = `unknown`
|