@ls-stack/utils 3.32.0 → 3.33.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/docs/arrayUtils/-internal-.md +138 -0
- package/docs/arrayUtils/README.md +50 -14
- package/lib/arrayUtils.cjs +9 -0
- package/lib/arrayUtils.d.cts +36 -4
- package/lib/arrayUtils.d.ts +36 -4
- package/lib/arrayUtils.js +3 -1
- package/lib/{chunk-SRVMMYSW.js → chunk-RYBJST64.js} +9 -1
- package/lib/{chunk-J3ILVKZC.js → chunk-XUNY3QUT.js} +1 -1
- package/lib/concurrentCalls.js +1 -1
- package/lib/filterObjectOrArrayKeys.js +2 -2
- package/lib/serializeXML.cjs +1 -1
- package/lib/serializeXML.js +2 -2
- package/lib/testUtils.js +2 -2
- package/package.json +1 -1
|
@@ -8,6 +8,144 @@
|
|
|
8
8
|
|
|
9
9
|
## Type Aliases
|
|
10
10
|
|
|
11
|
+
### ArrayOps\<T\>
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
type ArrayOps<T> = object;
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Defined in: [packages/utils/src/arrayUtils.ts:238](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L238)
|
|
18
|
+
|
|
19
|
+
#### Type Parameters
|
|
20
|
+
|
|
21
|
+
##### T
|
|
22
|
+
|
|
23
|
+
`T`
|
|
24
|
+
|
|
25
|
+
#### Properties
|
|
26
|
+
|
|
27
|
+
##### filterAndMap()
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
filterAndMap: <R>(mapFilter) => R[];
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Defined in: [packages/utils/src/arrayUtils.ts:251](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L251)
|
|
34
|
+
|
|
35
|
+
Filter and map an array
|
|
36
|
+
|
|
37
|
+
###### Type Parameters
|
|
38
|
+
|
|
39
|
+
###### R
|
|
40
|
+
|
|
41
|
+
`R`
|
|
42
|
+
|
|
43
|
+
###### Parameters
|
|
44
|
+
|
|
45
|
+
###### mapFilter
|
|
46
|
+
|
|
47
|
+
(`item`, `index`) => `false` \| `R`
|
|
48
|
+
|
|
49
|
+
A function that takes an item and returns a value or `false`
|
|
50
|
+
to reject the item.
|
|
51
|
+
|
|
52
|
+
###### Returns
|
|
53
|
+
|
|
54
|
+
`R`[]
|
|
55
|
+
|
|
56
|
+
###### Example
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
const items = [1, 2, 3];
|
|
60
|
+
|
|
61
|
+
const enhancedItems = arrayOps(items);
|
|
62
|
+
|
|
63
|
+
enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
##### rejectDuplicates()
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
rejectDuplicates: (getKey) => T[];
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Defined in: [packages/utils/src/arrayUtils.ts:253](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L253)
|
|
73
|
+
|
|
74
|
+
###### Parameters
|
|
75
|
+
|
|
76
|
+
###### getKey
|
|
77
|
+
|
|
78
|
+
(`item`) => `unknown`
|
|
79
|
+
|
|
80
|
+
###### Returns
|
|
81
|
+
|
|
82
|
+
`T`[]
|
|
83
|
+
|
|
84
|
+
##### sortBy()
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
sortBy: (sortByValue, props) => T[];
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Defined in: [packages/utils/src/arrayUtils.ts:252](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L252)
|
|
91
|
+
|
|
92
|
+
###### Parameters
|
|
93
|
+
|
|
94
|
+
###### sortByValue
|
|
95
|
+
|
|
96
|
+
[`SortByValue`](#sortbyvalue)\<`T`\>
|
|
97
|
+
|
|
98
|
+
###### props
|
|
99
|
+
|
|
100
|
+
[`SortByProps`](#sortbyprops)
|
|
101
|
+
|
|
102
|
+
###### Returns
|
|
103
|
+
|
|
104
|
+
`T`[]
|
|
105
|
+
|
|
106
|
+
***
|
|
107
|
+
|
|
108
|
+
### SortByProps
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
type SortByProps =
|
|
112
|
+
| {
|
|
113
|
+
order?: SortOrder | SortOrder[];
|
|
114
|
+
}
|
|
115
|
+
| SortOrder
|
|
116
|
+
| SortOrder[];
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Defined in: [packages/utils/src/arrayUtils.ts:48](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L48)
|
|
120
|
+
|
|
121
|
+
***
|
|
122
|
+
|
|
123
|
+
### SortByValue()\<T\>
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
type SortByValue<T> = (item) => (number | string)[] | number | string;
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Defined in: [packages/utils/src/arrayUtils.ts:46](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L46)
|
|
130
|
+
|
|
131
|
+
#### Type Parameters
|
|
132
|
+
|
|
133
|
+
##### T
|
|
134
|
+
|
|
135
|
+
`T`
|
|
136
|
+
|
|
137
|
+
#### Parameters
|
|
138
|
+
|
|
139
|
+
##### item
|
|
140
|
+
|
|
141
|
+
`T`
|
|
142
|
+
|
|
143
|
+
#### Returns
|
|
144
|
+
|
|
145
|
+
(`number` \| `string`)[] \| `number` \| `string`
|
|
146
|
+
|
|
147
|
+
***
|
|
148
|
+
|
|
11
149
|
### SortOrder
|
|
12
150
|
|
|
13
151
|
```ts
|
|
@@ -28,13 +28,51 @@ Defined in: [packages/utils/src/arrayUtils.ts:42](https://github.com/lucasols/ut
|
|
|
28
28
|
|
|
29
29
|
## Functions
|
|
30
30
|
|
|
31
|
+
### arrayOps()
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
function arrayOps<T>(array): ArrayOps<T>;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Defined in: [packages/utils/src/arrayUtils.ts:268](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L268)
|
|
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
|
+
|
|
31
69
|
### arrayWithPrev()
|
|
32
70
|
|
|
33
71
|
```ts
|
|
34
72
|
function arrayWithPrev<T>(array): [T, null | T][];
|
|
35
73
|
```
|
|
36
74
|
|
|
37
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
75
|
+
Defined in: [packages/utils/src/arrayUtils.ts:117](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L117)
|
|
38
76
|
|
|
39
77
|
#### Type Parameters
|
|
40
78
|
|
|
@@ -60,7 +98,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:108](https://github.com/lucasols/u
|
|
|
60
98
|
function arrayWithPrevAndIndex<T>(array): object[];
|
|
61
99
|
```
|
|
62
100
|
|
|
63
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
101
|
+
Defined in: [packages/utils/src/arrayUtils.ts:121](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L121)
|
|
64
102
|
|
|
65
103
|
#### Type Parameters
|
|
66
104
|
|
|
@@ -143,7 +181,7 @@ function findAfterIndex<T>(
|
|
|
143
181
|
predicate): undefined | T;
|
|
144
182
|
```
|
|
145
183
|
|
|
146
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
184
|
+
Defined in: [packages/utils/src/arrayUtils.ts:144](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L144)
|
|
147
185
|
|
|
148
186
|
#### Type Parameters
|
|
149
187
|
|
|
@@ -180,7 +218,7 @@ function findBeforeIndex<T>(
|
|
|
180
218
|
predicate): undefined | T;
|
|
181
219
|
```
|
|
182
220
|
|
|
183
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
221
|
+
Defined in: [packages/utils/src/arrayUtils.ts:158](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L158)
|
|
184
222
|
|
|
185
223
|
#### Type Parameters
|
|
186
224
|
|
|
@@ -214,7 +252,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:149](https://github.com/lucasols/u
|
|
|
214
252
|
function hasDuplicates<T>(array, getKey): boolean;
|
|
215
253
|
```
|
|
216
254
|
|
|
217
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
255
|
+
Defined in: [packages/utils/src/arrayUtils.ts:182](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L182)
|
|
218
256
|
|
|
219
257
|
#### Type Parameters
|
|
220
258
|
|
|
@@ -244,7 +282,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:173](https://github.com/lucasols/u
|
|
|
244
282
|
function isInArray<T, U>(value, oneOf): value is U;
|
|
245
283
|
```
|
|
246
284
|
|
|
247
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
285
|
+
Defined in: [packages/utils/src/arrayUtils.ts:131](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L131)
|
|
248
286
|
|
|
249
287
|
#### Type Parameters
|
|
250
288
|
|
|
@@ -278,7 +316,7 @@ readonly `U`[]
|
|
|
278
316
|
function rejectArrayUndefinedValues<T>(array): T;
|
|
279
317
|
```
|
|
280
318
|
|
|
281
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
319
|
+
Defined in: [packages/utils/src/arrayUtils.ts:178](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L178)
|
|
282
320
|
|
|
283
321
|
#### Type Parameters
|
|
284
322
|
|
|
@@ -304,7 +342,7 @@ Defined in: [packages/utils/src/arrayUtils.ts:169](https://github.com/lucasols/u
|
|
|
304
342
|
function rejectDuplicates<T>(array, getKey): T[];
|
|
305
343
|
```
|
|
306
344
|
|
|
307
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
345
|
+
Defined in: [packages/utils/src/arrayUtils.ts:199](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L199)
|
|
308
346
|
|
|
309
347
|
#### Type Parameters
|
|
310
348
|
|
|
@@ -337,7 +375,7 @@ function sortBy<T>(
|
|
|
337
375
|
props): T[];
|
|
338
376
|
```
|
|
339
377
|
|
|
340
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
378
|
+
Defined in: [packages/utils/src/arrayUtils.ts:76](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L76)
|
|
341
379
|
|
|
342
380
|
Sort an array based on a value
|
|
343
381
|
|
|
@@ -359,13 +397,11 @@ Use `Infinity` as as wildcard to absolute max and min values
|
|
|
359
397
|
|
|
360
398
|
##### sortByValue
|
|
361
399
|
|
|
362
|
-
|
|
400
|
+
[`SortByValue`](-internal-.md#sortbyvalue)\<`T`\>
|
|
363
401
|
|
|
364
402
|
##### props
|
|
365
403
|
|
|
366
|
-
[`
|
|
367
|
-
`order?`: SortOrder \| SortOrder\[\] \| undefined;
|
|
368
|
-
\}
|
|
404
|
+
[`SortByProps`](-internal-.md#sortbyprops) = `'asc'`
|
|
369
405
|
|
|
370
406
|
#### Returns
|
|
371
407
|
|
|
@@ -396,7 +432,7 @@ function truncateArray<T>(
|
|
|
396
432
|
appendIfTruncated?): T[];
|
|
397
433
|
```
|
|
398
434
|
|
|
399
|
-
Defined in: [packages/utils/src/arrayUtils.ts:
|
|
435
|
+
Defined in: [packages/utils/src/arrayUtils.ts:219](https://github.com/lucasols/utils/blob/main/packages/utils/src/arrayUtils.ts#L219)
|
|
400
436
|
|
|
401
437
|
#### Type Parameters
|
|
402
438
|
|
package/lib/arrayUtils.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/arrayUtils.ts
|
|
21
21
|
var arrayUtils_exports = {};
|
|
22
22
|
__export(arrayUtils_exports, {
|
|
23
|
+
arrayOps: () => arrayOps,
|
|
23
24
|
arrayWithPrev: () => arrayWithPrev,
|
|
24
25
|
arrayWithPrevAndIndex: () => arrayWithPrevAndIndex,
|
|
25
26
|
filterAndMap: () => filterAndMap,
|
|
@@ -155,8 +156,16 @@ function truncateArray(array, maxLength, appendIfTruncated) {
|
|
|
155
156
|
}
|
|
156
157
|
return result;
|
|
157
158
|
}
|
|
159
|
+
function arrayOps(array) {
|
|
160
|
+
return {
|
|
161
|
+
filterAndMap: (mapFilter) => filterAndMap(array, mapFilter),
|
|
162
|
+
sortBy: (sortByValue, props) => sortBy(array, sortByValue, props),
|
|
163
|
+
rejectDuplicates: (getKey) => rejectDuplicates(array, getKey)
|
|
164
|
+
};
|
|
165
|
+
}
|
|
158
166
|
// Annotate the CommonJS export names for ESM import in node:
|
|
159
167
|
0 && (module.exports = {
|
|
168
|
+
arrayOps,
|
|
160
169
|
arrayWithPrev,
|
|
161
170
|
arrayWithPrevAndIndex,
|
|
162
171
|
filterAndMap,
|
package/lib/arrayUtils.d.cts
CHANGED
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
declare function filterAndMap<T, R>(array: IterableIterator<T> | readonly T[], mapFilter: (item: T, index: number) => false | R): R[];
|
|
22
22
|
type FilterAndMapReturn<T> = false | T;
|
|
23
23
|
type SortOrder = 'desc' | 'asc';
|
|
24
|
+
type SortByValue<T> = (item: T) => (number | string)[] | number | string;
|
|
25
|
+
type SortByProps = {
|
|
26
|
+
order?: SortOrder | SortOrder[];
|
|
27
|
+
} | SortOrder | SortOrder[];
|
|
24
28
|
/**
|
|
25
29
|
* Sort an array based on a value
|
|
26
30
|
*
|
|
@@ -42,9 +46,7 @@ type SortOrder = 'desc' | 'asc';
|
|
|
42
46
|
* // return a array to sort by multiple values
|
|
43
47
|
* const sortedItems = sortBy(items, (item) => [item.a, item.b]);
|
|
44
48
|
*/
|
|
45
|
-
declare function sortBy<T>(arr: T[], sortByValue:
|
|
46
|
-
order?: SortOrder | SortOrder[];
|
|
47
|
-
} | SortOrder | SortOrder[]): T[];
|
|
49
|
+
declare function sortBy<T>(arr: T[], sortByValue: SortByValue<T>, props?: SortByProps): T[];
|
|
48
50
|
declare function arrayWithPrev<T>(array: T[]): [current: T, prev: T | null][];
|
|
49
51
|
declare function arrayWithPrevAndIndex<T>(array: T[]): {
|
|
50
52
|
item: T;
|
|
@@ -58,5 +60,35 @@ declare function rejectArrayUndefinedValues<T extends unknown[]>(array: T): T;
|
|
|
58
60
|
declare function hasDuplicates<T>(array: T[], getKey?: (item: T) => unknown): boolean;
|
|
59
61
|
declare function rejectDuplicates<T>(array: T[], getKey?: (item: T) => unknown): T[];
|
|
60
62
|
declare function truncateArray<T>(array: T[], maxLength: number, appendIfTruncated?: T | ((truncatedCount: number) => T)): T[];
|
|
63
|
+
type ArrayOps<T> = {
|
|
64
|
+
/**
|
|
65
|
+
* Filter and map an array
|
|
66
|
+
*
|
|
67
|
+
* @param mapFilter - A function that takes an item and returns a value or `false`
|
|
68
|
+
* to reject the item.
|
|
69
|
+
* @example
|
|
70
|
+
* const items = [1, 2, 3];
|
|
71
|
+
*
|
|
72
|
+
* const enhancedItems = arrayOps(items);
|
|
73
|
+
*
|
|
74
|
+
* enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
75
|
+
*/
|
|
76
|
+
filterAndMap: <R>(mapFilter: (item: T, index: number) => false | R) => R[];
|
|
77
|
+
sortBy: (sortByValue: SortByValue<T>, props: SortByProps) => T[];
|
|
78
|
+
rejectDuplicates: (getKey: (item: T) => unknown) => T[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Enhance an array with extra methods
|
|
82
|
+
*
|
|
83
|
+
* @param array
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* const enhancedItems = arrayOps(array);
|
|
87
|
+
*
|
|
88
|
+
* enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
89
|
+
* enhancedItems.sortBy((item) => item);
|
|
90
|
+
* enhancedItems.rejectDuplicates((item) => item);
|
|
91
|
+
*/
|
|
92
|
+
declare function arrayOps<T>(array: T[]): ArrayOps<T>;
|
|
61
93
|
|
|
62
|
-
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
|
|
94
|
+
export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
|
package/lib/arrayUtils.d.ts
CHANGED
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
declare function filterAndMap<T, R>(array: IterableIterator<T> | readonly T[], mapFilter: (item: T, index: number) => false | R): R[];
|
|
22
22
|
type FilterAndMapReturn<T> = false | T;
|
|
23
23
|
type SortOrder = 'desc' | 'asc';
|
|
24
|
+
type SortByValue<T> = (item: T) => (number | string)[] | number | string;
|
|
25
|
+
type SortByProps = {
|
|
26
|
+
order?: SortOrder | SortOrder[];
|
|
27
|
+
} | SortOrder | SortOrder[];
|
|
24
28
|
/**
|
|
25
29
|
* Sort an array based on a value
|
|
26
30
|
*
|
|
@@ -42,9 +46,7 @@ type SortOrder = 'desc' | 'asc';
|
|
|
42
46
|
* // return a array to sort by multiple values
|
|
43
47
|
* const sortedItems = sortBy(items, (item) => [item.a, item.b]);
|
|
44
48
|
*/
|
|
45
|
-
declare function sortBy<T>(arr: T[], sortByValue:
|
|
46
|
-
order?: SortOrder | SortOrder[];
|
|
47
|
-
} | SortOrder | SortOrder[]): T[];
|
|
49
|
+
declare function sortBy<T>(arr: T[], sortByValue: SortByValue<T>, props?: SortByProps): T[];
|
|
48
50
|
declare function arrayWithPrev<T>(array: T[]): [current: T, prev: T | null][];
|
|
49
51
|
declare function arrayWithPrevAndIndex<T>(array: T[]): {
|
|
50
52
|
item: T;
|
|
@@ -58,5 +60,35 @@ declare function rejectArrayUndefinedValues<T extends unknown[]>(array: T): T;
|
|
|
58
60
|
declare function hasDuplicates<T>(array: T[], getKey?: (item: T) => unknown): boolean;
|
|
59
61
|
declare function rejectDuplicates<T>(array: T[], getKey?: (item: T) => unknown): T[];
|
|
60
62
|
declare function truncateArray<T>(array: T[], maxLength: number, appendIfTruncated?: T | ((truncatedCount: number) => T)): T[];
|
|
63
|
+
type ArrayOps<T> = {
|
|
64
|
+
/**
|
|
65
|
+
* Filter and map an array
|
|
66
|
+
*
|
|
67
|
+
* @param mapFilter - A function that takes an item and returns a value or `false`
|
|
68
|
+
* to reject the item.
|
|
69
|
+
* @example
|
|
70
|
+
* const items = [1, 2, 3];
|
|
71
|
+
*
|
|
72
|
+
* const enhancedItems = arrayOps(items);
|
|
73
|
+
*
|
|
74
|
+
* enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
75
|
+
*/
|
|
76
|
+
filterAndMap: <R>(mapFilter: (item: T, index: number) => false | R) => R[];
|
|
77
|
+
sortBy: (sortByValue: SortByValue<T>, props: SortByProps) => T[];
|
|
78
|
+
rejectDuplicates: (getKey: (item: T) => unknown) => T[];
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Enhance an array with extra methods
|
|
82
|
+
*
|
|
83
|
+
* @param array
|
|
84
|
+
* @example
|
|
85
|
+
*
|
|
86
|
+
* const enhancedItems = arrayOps(array);
|
|
87
|
+
*
|
|
88
|
+
* enhancedItems.filterAndMap((item) => item === 2 ? false : item);
|
|
89
|
+
* enhancedItems.sortBy((item) => item);
|
|
90
|
+
* enhancedItems.rejectDuplicates((item) => item);
|
|
91
|
+
*/
|
|
92
|
+
declare function arrayOps<T>(array: T[]): ArrayOps<T>;
|
|
61
93
|
|
|
62
|
-
export { type FilterAndMapReturn, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
|
|
94
|
+
export { type FilterAndMapReturn, arrayOps, arrayWithPrev, arrayWithPrevAndIndex, filterAndMap, findAfterIndex, findBeforeIndex, hasDuplicates, isInArray, rejectArrayUndefinedValues, rejectDuplicates, sortBy, truncateArray };
|
package/lib/arrayUtils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
arrayOps,
|
|
2
3
|
arrayWithPrev,
|
|
3
4
|
arrayWithPrevAndIndex,
|
|
4
5
|
filterAndMap,
|
|
@@ -10,10 +11,11 @@ import {
|
|
|
10
11
|
rejectDuplicates,
|
|
11
12
|
sortBy,
|
|
12
13
|
truncateArray
|
|
13
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-RYBJST64.js";
|
|
14
15
|
import "./chunk-C2SVCIWE.js";
|
|
15
16
|
import "./chunk-JF2MDHOJ.js";
|
|
16
17
|
export {
|
|
18
|
+
arrayOps,
|
|
17
19
|
arrayWithPrev,
|
|
18
20
|
arrayWithPrevAndIndex,
|
|
19
21
|
filterAndMap,
|
|
@@ -115,6 +115,13 @@ function truncateArray(array, maxLength, appendIfTruncated) {
|
|
|
115
115
|
}
|
|
116
116
|
return result;
|
|
117
117
|
}
|
|
118
|
+
function arrayOps(array) {
|
|
119
|
+
return {
|
|
120
|
+
filterAndMap: (mapFilter) => filterAndMap(array, mapFilter),
|
|
121
|
+
sortBy: (sortByValue, props) => sortBy(array, sortByValue, props),
|
|
122
|
+
rejectDuplicates: (getKey) => rejectDuplicates(array, getKey)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
118
125
|
|
|
119
126
|
export {
|
|
120
127
|
filterAndMap,
|
|
@@ -127,5 +134,6 @@ export {
|
|
|
127
134
|
rejectArrayUndefinedValues,
|
|
128
135
|
hasDuplicates,
|
|
129
136
|
rejectDuplicates,
|
|
130
|
-
truncateArray
|
|
137
|
+
truncateArray,
|
|
138
|
+
arrayOps
|
|
131
139
|
};
|
package/lib/concurrentCalls.js
CHANGED
package/lib/serializeXML.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function serializeXML(node, options) {
|
|
|
69
69
|
function serializeWithLevel(node, options = {}, level) {
|
|
70
70
|
const {
|
|
71
71
|
indent,
|
|
72
|
-
escapeText: globalEscapeText =
|
|
72
|
+
escapeText: globalEscapeText = false,
|
|
73
73
|
validateTagName = true,
|
|
74
74
|
invalidNodes = "throw"
|
|
75
75
|
} = options;
|
package/lib/serializeXML.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
filterAndMap
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-RYBJST64.js";
|
|
4
4
|
import "./chunk-C2SVCIWE.js";
|
|
5
5
|
import {
|
|
6
6
|
isTruthy
|
|
@@ -32,7 +32,7 @@ function serializeXML(node, options) {
|
|
|
32
32
|
function serializeWithLevel(node, options = {}, level) {
|
|
33
33
|
const {
|
|
34
34
|
indent,
|
|
35
|
-
escapeText: globalEscapeText =
|
|
35
|
+
escapeText: globalEscapeText = false,
|
|
36
36
|
validateTagName = true,
|
|
37
37
|
invalidNodes = "throw"
|
|
38
38
|
} = options;
|
package/lib/testUtils.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-JQFUKJU5.js";
|
|
12
12
|
import {
|
|
13
13
|
filterObjectOrArrayKeys
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XUNY3QUT.js";
|
|
15
15
|
import {
|
|
16
16
|
defer
|
|
17
17
|
} from "./chunk-DFXNVEH6.js";
|
|
@@ -22,7 +22,7 @@ import "./chunk-3LZQMZAS.js";
|
|
|
22
22
|
import {
|
|
23
23
|
arrayWithPrevAndIndex,
|
|
24
24
|
filterAndMap
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-RYBJST64.js";
|
|
26
26
|
import {
|
|
27
27
|
isObject
|
|
28
28
|
} from "./chunk-C2SVCIWE.js";
|