@oscarpalmer/atoms 0.200.0 → 0.201.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/array/index.d.mts +2 -2
- package/dist/array/index.mjs +2 -2
- package/dist/array/select.d.mts +71 -64
- package/dist/array/select.mjs +17 -2
- package/dist/index.d.mts +70 -63
- package/dist/index.mjs +32 -6
- package/dist/internal/array/find.d.mts +5 -1
- package/dist/internal/array/find.mjs +16 -4
- package/package.json +1 -1
package/dist/array/index.d.mts
CHANGED
|
@@ -14,7 +14,7 @@ import { intersection } from "./intersection.mjs";
|
|
|
14
14
|
import { partition } from "./partition.mjs";
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { reverse } from "./reverse.mjs";
|
|
17
|
-
import { select } from "./select.mjs";
|
|
17
|
+
import { reverseSelect, select } from "./select.mjs";
|
|
18
18
|
import { single } from "./single.mjs";
|
|
19
19
|
import { drop, slice, take } from "./slice.mjs";
|
|
20
20
|
import { splice } from "./splice.mjs";
|
|
@@ -23,4 +23,4 @@ import { toggle } from "./toggle.mjs";
|
|
|
23
23
|
import { union } from "./union.mjs";
|
|
24
24
|
import { unique } from "./unique.mjs";
|
|
25
25
|
import { update } from "./update.mjs";
|
|
26
|
-
export { ArrayComparison, chunk, compact, difference, drop, endsWithArray, exists, find, findLast, flatten, getArray, getArrayComparison, includesArray, indexOf, indexOfArray, insert, intersection, lastIndexOf, partition, push, range, reverse, select, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
|
26
|
+
export { ArrayComparison, chunk, compact, difference, drop, endsWithArray, exists, find, findLast, flatten, getArray, getArrayComparison, includesArray, indexOf, indexOfArray, insert, intersection, lastIndexOf, partition, push, range, reverse, reverseSelect, select, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { intersection } from "./intersection.mjs";
|
|
|
14
14
|
import { partition } from "./partition.mjs";
|
|
15
15
|
import { push } from "./push.mjs";
|
|
16
16
|
import { reverse } from "./reverse.mjs";
|
|
17
|
-
import { select } from "./select.mjs";
|
|
17
|
+
import { reverseSelect, select } from "./select.mjs";
|
|
18
18
|
import { single } from "./single.mjs";
|
|
19
19
|
import { drop, slice, take } from "./slice.mjs";
|
|
20
20
|
import { splice } from "./splice.mjs";
|
|
@@ -23,4 +23,4 @@ import { toggle } from "./toggle.mjs";
|
|
|
23
23
|
import { union } from "./union.mjs";
|
|
24
24
|
import { unique } from "./unique.mjs";
|
|
25
25
|
import { update } from "./update.mjs";
|
|
26
|
-
export { chunk, compact, difference, drop, endsWithArray, exists, find, findLast, flatten, getArray, getArrayComparison, includesArray, indexOf, indexOfArray, insert, intersection, lastIndexOf, partition, push, range, reverse, select, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
|
26
|
+
export { chunk, compact, difference, drop, endsWithArray, exists, find, findLast, flatten, getArray, getArrayComparison, includesArray, indexOf, indexOfArray, insert, intersection, lastIndexOf, partition, push, range, reverse, reverseSelect, select, shuffle, single, slice, splice, startsWithArray, take, times, toSet, toggle, union, unique, update };
|
package/dist/array/select.d.mts
CHANGED
|
@@ -1,109 +1,111 @@
|
|
|
1
1
|
import { PlainObject } from "../models.mjs";
|
|
2
2
|
//#region src/array/select.d.ts
|
|
3
|
+
type MapKeyOrCallback<Item> = ((item: Item, index: number, array: Item[]) => unknown) | (Item extends PlainObject ? keyof Item : never);
|
|
4
|
+
type Mapped<Item, Map extends MapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
|
|
5
|
+
type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
|
|
3
6
|
/**
|
|
4
|
-
* Get a
|
|
7
|
+
* Get a mapped and filtered array of items
|
|
5
8
|
*
|
|
6
9
|
* @param array Array to search in
|
|
7
|
-
* @param
|
|
10
|
+
* @param map Callback or key to map the items
|
|
11
|
+
* @param filterCallback Callback to get a mapped value's value for matching
|
|
8
12
|
* @param filterValue Value to match against
|
|
9
|
-
* @
|
|
10
|
-
* @returns Filtered and mapped array of items
|
|
13
|
+
* @returns Mapped and filtered array of items
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
13
16
|
* ```typescript
|
|
14
|
-
*
|
|
17
|
+
* reverseSelect(
|
|
15
18
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
16
|
-
* item => item.id,
|
|
17
|
-
* 2,
|
|
18
19
|
* item => item.name,
|
|
20
|
+
* value => value.length,
|
|
21
|
+
* 3,
|
|
19
22
|
* ); // => ['Bob']
|
|
20
23
|
* ```
|
|
21
24
|
*/
|
|
22
|
-
declare function
|
|
25
|
+
declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterCallback extends (item: Mapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<Mapped<Item, Map>>;
|
|
23
26
|
/**
|
|
24
|
-
* Get a
|
|
27
|
+
* Get a mapped and filtered array of items
|
|
25
28
|
*
|
|
26
29
|
* @param array Array to search in
|
|
27
|
-
* @param
|
|
30
|
+
* @param map Callback to map the items
|
|
31
|
+
* @param filterKey Key to get a mapped value's value for matching
|
|
28
32
|
* @param filterValue Value to match against
|
|
29
|
-
* @
|
|
30
|
-
* @returns Filtered and mapped array of items
|
|
33
|
+
* @returns Mapped and filtered array of items
|
|
31
34
|
*
|
|
32
35
|
* @example
|
|
33
36
|
* ```typescript
|
|
34
|
-
*
|
|
37
|
+
* reverseSelect(
|
|
35
38
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
36
|
-
* item => item.
|
|
37
|
-
*
|
|
38
|
-
* '
|
|
39
|
-
* ); // => ['Bob']
|
|
39
|
+
* item => ({label: item.name}),
|
|
40
|
+
* 'label',
|
|
41
|
+
* 'Bob',
|
|
42
|
+
* ); // => [{label: 'Bob'}]
|
|
40
43
|
* ```
|
|
41
44
|
*/
|
|
42
|
-
declare function
|
|
45
|
+
declare function reverseSelect<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
|
|
43
46
|
/**
|
|
44
|
-
* Get a
|
|
47
|
+
* Get a mapped and filtered array of items
|
|
45
48
|
*
|
|
46
49
|
* @param array Array to search in
|
|
47
|
-
* @param
|
|
50
|
+
* @param map Key to map the items
|
|
51
|
+
* @param filterKey Key to get a mapped value's value for matching
|
|
48
52
|
* @param filterValue Value to match against
|
|
49
|
-
* @
|
|
50
|
-
* @returns Filtered and mapped array of items
|
|
53
|
+
* @returns Mapped and filtered array of items
|
|
51
54
|
*
|
|
52
55
|
* @example
|
|
53
56
|
* ```typescript
|
|
54
|
-
*
|
|
55
|
-
* [{
|
|
56
|
-
* '
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* ); // => ['
|
|
57
|
+
* reverseSelect(
|
|
58
|
+
* [{meta: {tag: 'a'}}, {meta: {tag: 'b'}}],
|
|
59
|
+
* 'meta',
|
|
60
|
+
* 'tag',
|
|
61
|
+
* 'b',
|
|
62
|
+
* ); // => [{tag: 'b'}]
|
|
60
63
|
* ```
|
|
61
64
|
*/
|
|
62
|
-
declare function
|
|
65
|
+
declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
|
|
63
66
|
/**
|
|
64
|
-
* Get a
|
|
67
|
+
* Get a mapped and filtered array of items
|
|
65
68
|
*
|
|
66
69
|
* @param array Array to search in
|
|
67
|
-
* @param
|
|
68
|
-
* @param
|
|
69
|
-
* @
|
|
70
|
-
* @returns Filtered and mapped array of items
|
|
70
|
+
* @param map Callback or key to map the items
|
|
71
|
+
* @param filter Filter callback to match mapped values
|
|
72
|
+
* @returns Mapped and filtered array of items
|
|
71
73
|
*
|
|
72
74
|
* @example
|
|
73
75
|
* ```typescript
|
|
74
|
-
*
|
|
76
|
+
* reverseSelect(
|
|
75
77
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* 'name',
|
|
78
|
+
* item => item.name,
|
|
79
|
+
* value => value.startsWith('B'),
|
|
79
80
|
* ); // => ['Bob']
|
|
80
81
|
* ```
|
|
81
82
|
*/
|
|
82
|
-
declare function
|
|
83
|
+
declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
|
|
83
84
|
/**
|
|
84
|
-
* Get a
|
|
85
|
+
* Get a mapped and filtered array of items
|
|
85
86
|
*
|
|
86
87
|
* @param array Array to search in
|
|
87
|
-
* @param
|
|
88
|
-
* @param
|
|
89
|
-
* @returns
|
|
88
|
+
* @param map Callback or key to map the items
|
|
89
|
+
* @param value Mapped value to match against
|
|
90
|
+
* @returns Mapped and filtered array of items
|
|
90
91
|
*
|
|
91
92
|
* @example
|
|
92
93
|
* ```typescript
|
|
93
|
-
*
|
|
94
|
-
* [
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* ); // => [
|
|
94
|
+
* reverseSelect(
|
|
95
|
+
* [1, 2, 3, 2, 1],
|
|
96
|
+
* value => value ** 2,
|
|
97
|
+
* 4,
|
|
98
|
+
* ); // => [4, 4]
|
|
98
99
|
* ```
|
|
99
100
|
*/
|
|
100
|
-
declare function
|
|
101
|
+
declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
|
|
101
102
|
/**
|
|
102
103
|
* Get a filtered and mapped array of items
|
|
103
104
|
*
|
|
104
105
|
* @param array Array to search in
|
|
105
|
-
* @param filterCallback
|
|
106
|
-
* @param
|
|
106
|
+
* @param filterCallback Callback to get an item's value for matching
|
|
107
|
+
* @param filterValue Value to match against
|
|
108
|
+
* @param map Callback or key to map the matched items
|
|
107
109
|
* @returns Filtered and mapped array of items
|
|
108
110
|
*
|
|
109
111
|
* @example
|
|
@@ -112,35 +114,37 @@ declare function select<Item, FilterCallback extends (item: Item, index: number,
|
|
|
112
114
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
113
115
|
* item => item.id,
|
|
114
116
|
* 2,
|
|
115
|
-
*
|
|
117
|
+
* item => item.name,
|
|
116
118
|
* ); // => ['Bob']
|
|
117
119
|
* ```
|
|
118
120
|
*/
|
|
119
|
-
declare function select<Item
|
|
121
|
+
declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends MapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<Mapped<Item, Map>>;
|
|
120
122
|
/**
|
|
121
123
|
* Get a filtered and mapped array of items
|
|
122
124
|
*
|
|
123
125
|
* @param array Array to search in
|
|
124
|
-
* @param
|
|
125
|
-
* @param
|
|
126
|
+
* @param filterKey Key to get an item's value for matching
|
|
127
|
+
* @param filterValue Value to match against
|
|
128
|
+
* @param map Callback or key to map the matched items
|
|
126
129
|
* @returns Filtered and mapped array of items
|
|
127
130
|
*
|
|
128
131
|
* @example
|
|
129
132
|
* ```typescript
|
|
130
133
|
* select(
|
|
131
134
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
132
|
-
*
|
|
133
|
-
*
|
|
135
|
+
* 'id',
|
|
136
|
+
* 2,
|
|
137
|
+
* 'name',
|
|
134
138
|
* ); // => ['Bob']
|
|
135
139
|
* ```
|
|
136
140
|
*/
|
|
137
|
-
declare function select<Item,
|
|
141
|
+
declare function select<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
|
|
138
142
|
/**
|
|
139
143
|
* Get a filtered and mapped array of items
|
|
140
144
|
*
|
|
141
145
|
* @param array Array to search in
|
|
142
146
|
* @param filter Filter callback to match items
|
|
143
|
-
* @param map
|
|
147
|
+
* @param map Callback or key to map the matched items
|
|
144
148
|
* @returns Filtered and mapped array of items
|
|
145
149
|
*
|
|
146
150
|
* @example
|
|
@@ -148,17 +152,17 @@ declare function select<Item, MapCallback extends (item: Item, index: number, ar
|
|
|
148
152
|
* select(
|
|
149
153
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
150
154
|
* item => item.id === 2,
|
|
151
|
-
*
|
|
155
|
+
* item => item.name,
|
|
152
156
|
* ); // => ['Bob']
|
|
153
157
|
* ```
|
|
154
158
|
*/
|
|
155
|
-
declare function select<Item
|
|
159
|
+
declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
|
|
156
160
|
/**
|
|
157
161
|
* Get a filtered and mapped array of items
|
|
158
162
|
*
|
|
159
163
|
* @param array Array to search in
|
|
160
164
|
* @param item Item to match against
|
|
161
|
-
* @param map Callback to map the matched items
|
|
165
|
+
* @param map Callback or key to map the matched items
|
|
162
166
|
* @returns Filtered and mapped array of items
|
|
163
167
|
*
|
|
164
168
|
* @example
|
|
@@ -170,6 +174,9 @@ declare function select<Item extends PlainObject, MapKey extends keyof Item>(arr
|
|
|
170
174
|
* ); // => [9]
|
|
171
175
|
* ```
|
|
172
176
|
*/
|
|
173
|
-
declare function select<Item,
|
|
177
|
+
declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
|
|
178
|
+
declare namespace select {
|
|
179
|
+
var reverse: typeof reverseSelect;
|
|
180
|
+
}
|
|
174
181
|
//#endregion
|
|
175
|
-
export { select };
|
|
182
|
+
export { reverseSelect, select };
|
package/dist/array/select.mjs
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { findValues } from "../internal/array/find.mjs";
|
|
2
2
|
//#region src/array/select.ts
|
|
3
|
+
function reverseSelect(array, ...parameters) {
|
|
4
|
+
const mapper = parameters.shift();
|
|
5
|
+
return findValues("all", array, parameters, {
|
|
6
|
+
callback: mapper,
|
|
7
|
+
reverse: true
|
|
8
|
+
}).matched;
|
|
9
|
+
}
|
|
3
10
|
function select(array, ...parameters) {
|
|
11
|
+
return selectValues(array, parameters);
|
|
12
|
+
}
|
|
13
|
+
function selectValues(array, parameters) {
|
|
4
14
|
const mapper = parameters.pop();
|
|
5
|
-
return findValues("all", array, parameters,
|
|
15
|
+
return findValues("all", array, parameters, {
|
|
16
|
+
callback: mapper,
|
|
17
|
+
reverse: false
|
|
18
|
+
}).matched;
|
|
6
19
|
}
|
|
20
|
+
select.reverse = reverseSelect;
|
|
21
|
+
Object.defineProperty(select, "reverse", { value: reverseSelect });
|
|
7
22
|
//#endregion
|
|
8
|
-
export { select };
|
|
23
|
+
export { reverseSelect, select };
|
package/dist/index.d.mts
CHANGED
|
@@ -1778,110 +1778,112 @@ export declare function push<Item>(array: Item[], pushed: Item[]): number;
|
|
|
1778
1778
|
export declare function reverse<Item>(array: Item[]): Item[];
|
|
1779
1779
|
//#endregion
|
|
1780
1780
|
//#region src/array/select.d.ts
|
|
1781
|
+
type MapKeyOrCallback<Item> = ((item: Item, index: number, array: Item[]) => unknown) | (Item extends PlainObject ? keyof Item : never);
|
|
1782
|
+
type Mapped<Item, Map extends MapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
|
|
1783
|
+
type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
|
|
1781
1784
|
/**
|
|
1782
|
-
* Get a
|
|
1785
|
+
* Get a mapped and filtered array of items
|
|
1783
1786
|
*
|
|
1784
1787
|
* @param array Array to search in
|
|
1785
|
-
* @param
|
|
1788
|
+
* @param map Callback or key to map the items
|
|
1789
|
+
* @param filterCallback Callback to get a mapped value's value for matching
|
|
1786
1790
|
* @param filterValue Value to match against
|
|
1787
|
-
* @
|
|
1788
|
-
* @returns Filtered and mapped array of items
|
|
1791
|
+
* @returns Mapped and filtered array of items
|
|
1789
1792
|
*
|
|
1790
1793
|
* @example
|
|
1791
1794
|
* ```typescript
|
|
1792
|
-
*
|
|
1795
|
+
* reverseSelect(
|
|
1793
1796
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1794
|
-
* item => item.id,
|
|
1795
|
-
* 2,
|
|
1796
1797
|
* item => item.name,
|
|
1798
|
+
* value => value.length,
|
|
1799
|
+
* 3,
|
|
1797
1800
|
* ); // => ['Bob']
|
|
1798
1801
|
* ```
|
|
1799
1802
|
*/
|
|
1800
|
-
export declare function
|
|
1803
|
+
export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterCallback extends (item: Mapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<Mapped<Item, Map>>;
|
|
1801
1804
|
/**
|
|
1802
|
-
* Get a
|
|
1805
|
+
* Get a mapped and filtered array of items
|
|
1803
1806
|
*
|
|
1804
1807
|
* @param array Array to search in
|
|
1805
|
-
* @param
|
|
1808
|
+
* @param map Callback to map the items
|
|
1809
|
+
* @param filterKey Key to get a mapped value's value for matching
|
|
1806
1810
|
* @param filterValue Value to match against
|
|
1807
|
-
* @
|
|
1808
|
-
* @returns Filtered and mapped array of items
|
|
1811
|
+
* @returns Mapped and filtered array of items
|
|
1809
1812
|
*
|
|
1810
1813
|
* @example
|
|
1811
1814
|
* ```typescript
|
|
1812
|
-
*
|
|
1815
|
+
* reverseSelect(
|
|
1813
1816
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1814
|
-
* item => item.
|
|
1815
|
-
*
|
|
1816
|
-
* '
|
|
1817
|
-
* ); // => ['Bob']
|
|
1817
|
+
* item => ({label: item.name}),
|
|
1818
|
+
* 'label',
|
|
1819
|
+
* 'Bob',
|
|
1820
|
+
* ); // => [{label: 'Bob'}]
|
|
1818
1821
|
* ```
|
|
1819
1822
|
*/
|
|
1820
|
-
export declare function
|
|
1823
|
+
export declare function reverseSelect<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
|
|
1821
1824
|
/**
|
|
1822
|
-
* Get a
|
|
1825
|
+
* Get a mapped and filtered array of items
|
|
1823
1826
|
*
|
|
1824
1827
|
* @param array Array to search in
|
|
1825
|
-
* @param
|
|
1828
|
+
* @param map Key to map the items
|
|
1829
|
+
* @param filterKey Key to get a mapped value's value for matching
|
|
1826
1830
|
* @param filterValue Value to match against
|
|
1827
|
-
* @
|
|
1828
|
-
* @returns Filtered and mapped array of items
|
|
1831
|
+
* @returns Mapped and filtered array of items
|
|
1829
1832
|
*
|
|
1830
1833
|
* @example
|
|
1831
1834
|
* ```typescript
|
|
1832
|
-
*
|
|
1833
|
-
* [{
|
|
1834
|
-
* '
|
|
1835
|
-
*
|
|
1836
|
-
*
|
|
1837
|
-
* ); // => ['
|
|
1835
|
+
* reverseSelect(
|
|
1836
|
+
* [{meta: {tag: 'a'}}, {meta: {tag: 'b'}}],
|
|
1837
|
+
* 'meta',
|
|
1838
|
+
* 'tag',
|
|
1839
|
+
* 'b',
|
|
1840
|
+
* ); // => [{tag: 'b'}]
|
|
1838
1841
|
* ```
|
|
1839
1842
|
*/
|
|
1840
|
-
export declare function
|
|
1843
|
+
export declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
|
|
1841
1844
|
/**
|
|
1842
|
-
* Get a
|
|
1845
|
+
* Get a mapped and filtered array of items
|
|
1843
1846
|
*
|
|
1844
1847
|
* @param array Array to search in
|
|
1845
|
-
* @param
|
|
1846
|
-
* @param
|
|
1847
|
-
* @
|
|
1848
|
-
* @returns Filtered and mapped array of items
|
|
1848
|
+
* @param map Callback or key to map the items
|
|
1849
|
+
* @param filter Filter callback to match mapped values
|
|
1850
|
+
* @returns Mapped and filtered array of items
|
|
1849
1851
|
*
|
|
1850
1852
|
* @example
|
|
1851
1853
|
* ```typescript
|
|
1852
|
-
*
|
|
1854
|
+
* reverseSelect(
|
|
1853
1855
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1854
|
-
*
|
|
1855
|
-
*
|
|
1856
|
-
* 'name',
|
|
1856
|
+
* item => item.name,
|
|
1857
|
+
* value => value.startsWith('B'),
|
|
1857
1858
|
* ); // => ['Bob']
|
|
1858
1859
|
* ```
|
|
1859
1860
|
*/
|
|
1860
|
-
export declare function
|
|
1861
|
+
export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
|
|
1861
1862
|
/**
|
|
1862
|
-
* Get a
|
|
1863
|
+
* Get a mapped and filtered array of items
|
|
1863
1864
|
*
|
|
1864
1865
|
* @param array Array to search in
|
|
1865
|
-
* @param
|
|
1866
|
-
* @param
|
|
1867
|
-
* @returns
|
|
1866
|
+
* @param map Callback or key to map the items
|
|
1867
|
+
* @param value Mapped value to match against
|
|
1868
|
+
* @returns Mapped and filtered array of items
|
|
1868
1869
|
*
|
|
1869
1870
|
* @example
|
|
1870
1871
|
* ```typescript
|
|
1871
|
-
*
|
|
1872
|
-
* [
|
|
1873
|
-
*
|
|
1874
|
-
*
|
|
1875
|
-
* ); // => [
|
|
1872
|
+
* reverseSelect(
|
|
1873
|
+
* [1, 2, 3, 2, 1],
|
|
1874
|
+
* value => value ** 2,
|
|
1875
|
+
* 4,
|
|
1876
|
+
* ); // => [4, 4]
|
|
1876
1877
|
* ```
|
|
1877
1878
|
*/
|
|
1878
|
-
export declare function
|
|
1879
|
+
export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
|
|
1879
1880
|
/**
|
|
1880
1881
|
* Get a filtered and mapped array of items
|
|
1881
1882
|
*
|
|
1882
1883
|
* @param array Array to search in
|
|
1883
|
-
* @param filterCallback
|
|
1884
|
-
* @param
|
|
1884
|
+
* @param filterCallback Callback to get an item's value for matching
|
|
1885
|
+
* @param filterValue Value to match against
|
|
1886
|
+
* @param map Callback or key to map the matched items
|
|
1885
1887
|
* @returns Filtered and mapped array of items
|
|
1886
1888
|
*
|
|
1887
1889
|
* @example
|
|
@@ -1890,35 +1892,37 @@ export declare function select<Item, FilterCallback extends (item: Item, index:
|
|
|
1890
1892
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1891
1893
|
* item => item.id,
|
|
1892
1894
|
* 2,
|
|
1893
|
-
*
|
|
1895
|
+
* item => item.name,
|
|
1894
1896
|
* ); // => ['Bob']
|
|
1895
1897
|
* ```
|
|
1896
1898
|
*/
|
|
1897
|
-
export declare function select<Item
|
|
1899
|
+
export declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends MapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<Mapped<Item, Map>>;
|
|
1898
1900
|
/**
|
|
1899
1901
|
* Get a filtered and mapped array of items
|
|
1900
1902
|
*
|
|
1901
1903
|
* @param array Array to search in
|
|
1902
|
-
* @param
|
|
1903
|
-
* @param
|
|
1904
|
+
* @param filterKey Key to get an item's value for matching
|
|
1905
|
+
* @param filterValue Value to match against
|
|
1906
|
+
* @param map Callback or key to map the matched items
|
|
1904
1907
|
* @returns Filtered and mapped array of items
|
|
1905
1908
|
*
|
|
1906
1909
|
* @example
|
|
1907
1910
|
* ```typescript
|
|
1908
1911
|
* select(
|
|
1909
1912
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1910
|
-
*
|
|
1911
|
-
*
|
|
1913
|
+
* 'id',
|
|
1914
|
+
* 2,
|
|
1915
|
+
* 'name',
|
|
1912
1916
|
* ); // => ['Bob']
|
|
1913
1917
|
* ```
|
|
1914
1918
|
*/
|
|
1915
|
-
export declare function select<Item,
|
|
1919
|
+
export declare function select<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
|
|
1916
1920
|
/**
|
|
1917
1921
|
* Get a filtered and mapped array of items
|
|
1918
1922
|
*
|
|
1919
1923
|
* @param array Array to search in
|
|
1920
1924
|
* @param filter Filter callback to match items
|
|
1921
|
-
* @param map
|
|
1925
|
+
* @param map Callback or key to map the matched items
|
|
1922
1926
|
* @returns Filtered and mapped array of items
|
|
1923
1927
|
*
|
|
1924
1928
|
* @example
|
|
@@ -1926,17 +1930,17 @@ export declare function select<Item, MapCallback extends (item: Item, index: num
|
|
|
1926
1930
|
* select(
|
|
1927
1931
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
1928
1932
|
* item => item.id === 2,
|
|
1929
|
-
*
|
|
1933
|
+
* item => item.name,
|
|
1930
1934
|
* ); // => ['Bob']
|
|
1931
1935
|
* ```
|
|
1932
1936
|
*/
|
|
1933
|
-
export declare function select<Item
|
|
1937
|
+
export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
|
|
1934
1938
|
/**
|
|
1935
1939
|
* Get a filtered and mapped array of items
|
|
1936
1940
|
*
|
|
1937
1941
|
* @param array Array to search in
|
|
1938
1942
|
* @param item Item to match against
|
|
1939
|
-
* @param map Callback to map the matched items
|
|
1943
|
+
* @param map Callback or key to map the matched items
|
|
1940
1944
|
* @returns Filtered and mapped array of items
|
|
1941
1945
|
*
|
|
1942
1946
|
* @example
|
|
@@ -1948,7 +1952,10 @@ export declare function select<Item extends PlainObject, MapKey extends keyof It
|
|
|
1948
1952
|
* ); // => [9]
|
|
1949
1953
|
* ```
|
|
1950
1954
|
*/
|
|
1951
|
-
export declare function select<Item,
|
|
1955
|
+
export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
|
|
1956
|
+
export declare namespace select {
|
|
1957
|
+
var reverse: typeof reverseSelect;
|
|
1958
|
+
}
|
|
1952
1959
|
//#endregion
|
|
1953
1960
|
//#region src/array/single.d.ts
|
|
1954
1961
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -68,12 +68,16 @@ function findValues(type, array, parameters, mapper) {
|
|
|
68
68
|
result.matched = [...new Set(array)];
|
|
69
69
|
return result;
|
|
70
70
|
}
|
|
71
|
-
const mapCallback = getArrayCallback(mapper);
|
|
71
|
+
const mapCallback = getArrayCallback(mapper?.callback);
|
|
72
|
+
const mapReverse = mapper?.reverse ?? false;
|
|
73
|
+
const mapAfter = mapCallback == null ? void 0 : mapReverse ? void 0 : mapCallback;
|
|
74
|
+
const mapBefore = mapCallback == null ? void 0 : mapReverse ? mapCallback : void 0;
|
|
72
75
|
if (callbacks?.bool != null || type === "all" && key == null) {
|
|
73
76
|
const callback = callbacks?.bool ?? ((item) => Object.is(item, value));
|
|
74
77
|
for (let index = 0; index < length; index += 1) {
|
|
75
78
|
const item = array[index];
|
|
76
|
-
|
|
79
|
+
const transformed = mapBefore?.(item, index, array) ?? item;
|
|
80
|
+
if (callback(transformed, index, array)) result.matched.push(mapAfter?.(item, index, array) ?? transformed);
|
|
77
81
|
else result.notMatched.push(item);
|
|
78
82
|
}
|
|
79
83
|
return result;
|
|
@@ -81,10 +85,18 @@ function findValues(type, array, parameters, mapper) {
|
|
|
81
85
|
const keys = /* @__PURE__ */ new Set();
|
|
82
86
|
for (let index = 0; index < length; index += 1) {
|
|
83
87
|
const item = array[index];
|
|
84
|
-
|
|
88
|
+
let keyed;
|
|
89
|
+
let transformed;
|
|
90
|
+
if (mapBefore == null) {
|
|
91
|
+
keyed = callbacks?.keyed?.(item, index, array) ?? item;
|
|
92
|
+
transformed = item;
|
|
93
|
+
} else {
|
|
94
|
+
transformed = mapBefore(item, index, array);
|
|
95
|
+
keyed = callbacks?.keyed?.(transformed, index, array) ?? transformed;
|
|
96
|
+
}
|
|
85
97
|
if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
|
|
86
98
|
keys.add(keyed);
|
|
87
|
-
result.matched.push(
|
|
99
|
+
result.matched.push(mapAfter?.(item, index, array) ?? transformed);
|
|
88
100
|
} else result.notMatched.push(item);
|
|
89
101
|
}
|
|
90
102
|
return result;
|
|
@@ -661,9 +673,23 @@ function reverse(array) {
|
|
|
661
673
|
}
|
|
662
674
|
//#endregion
|
|
663
675
|
//#region src/array/select.ts
|
|
676
|
+
function reverseSelect(array, ...parameters) {
|
|
677
|
+
return findValues("all", array, parameters, {
|
|
678
|
+
callback: parameters.shift(),
|
|
679
|
+
reverse: true
|
|
680
|
+
}).matched;
|
|
681
|
+
}
|
|
664
682
|
function select(array, ...parameters) {
|
|
665
|
-
return
|
|
683
|
+
return selectValues(array, parameters);
|
|
684
|
+
}
|
|
685
|
+
function selectValues(array, parameters) {
|
|
686
|
+
return findValues("all", array, parameters, {
|
|
687
|
+
callback: parameters.pop(),
|
|
688
|
+
reverse: false
|
|
689
|
+
}).matched;
|
|
666
690
|
}
|
|
691
|
+
select.reverse = reverseSelect;
|
|
692
|
+
Object.defineProperty(select, "reverse", { value: reverseSelect });
|
|
667
693
|
//#endregion
|
|
668
694
|
//#region src/array/single.ts
|
|
669
695
|
function single(array, ...parameters) {
|
|
@@ -6488,4 +6514,4 @@ var SizedSet = class extends Set {
|
|
|
6488
6514
|
}
|
|
6489
6515
|
};
|
|
6490
6516
|
//#endregion
|
|
6491
|
-
export { CancelablePromise, Logger, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isSubscriptions, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|
|
6517
|
+
export { CancelablePromise, Logger, PromiseTimeoutError, QueueError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncDebounce, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncThrottle, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFrozen, isFulfilled, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isPlainObject, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isSubscription, isSubscriptions, isTimedLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, promises, push, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, reverseSelect, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, words };
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
//#region src/internal/array/find.d.ts
|
|
2
|
+
type FindMapper = {
|
|
3
|
+
callback: unknown;
|
|
4
|
+
reverse: boolean;
|
|
5
|
+
};
|
|
2
6
|
type FindValueType = 'index' | 'item';
|
|
3
7
|
type FindValuesResult = {
|
|
4
8
|
matched: unknown[];
|
|
@@ -14,7 +18,7 @@ declare function createFindParameters(original: unknown[]): Parameters;
|
|
|
14
18
|
declare function findValue(type: Exclude<FindValueType, 'item'>, array: unknown[], parameters: unknown[], reversed: boolean): number;
|
|
15
19
|
declare function findValue(type: Exclude<FindValueType, 'index'>, array: unknown[], parameters: unknown[], reversed: boolean): unknown;
|
|
16
20
|
declare function findAbsoluteValueOrDefault(array: unknown[], parameters: unknown[], defaultValue: unknown, useDefaultValue: boolean, reversed: boolean): unknown;
|
|
17
|
-
declare function findValues(type: FindValuesType, array: unknown[], parameters: unknown[], mapper?:
|
|
21
|
+
declare function findValues(type: FindValuesType, array: unknown[], parameters: unknown[], mapper?: FindMapper): FindValuesResult;
|
|
18
22
|
declare const FIND_VALUE_INDEX = "index";
|
|
19
23
|
declare const FIND_VALUE_ITEM = "item";
|
|
20
24
|
declare const FIND_VALUES_ALL: FindValuesType;
|
|
@@ -52,12 +52,16 @@ function findValues(type, array, parameters, mapper) {
|
|
|
52
52
|
result.matched = [...new Set(array)];
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
|
-
const mapCallback = getArrayCallback(mapper);
|
|
55
|
+
const mapCallback = getArrayCallback(mapper?.callback);
|
|
56
|
+
const mapReverse = mapper?.reverse ?? false;
|
|
57
|
+
const mapAfter = mapCallback == null ? void 0 : mapReverse ? void 0 : mapCallback;
|
|
58
|
+
const mapBefore = mapCallback == null ? void 0 : mapReverse ? mapCallback : void 0;
|
|
56
59
|
if (callbacks?.bool != null || type === "all" && key == null) {
|
|
57
60
|
const callback = callbacks?.bool ?? ((item) => Object.is(item, value));
|
|
58
61
|
for (let index = 0; index < length; index += 1) {
|
|
59
62
|
const item = array[index];
|
|
60
|
-
|
|
63
|
+
const transformed = mapBefore?.(item, index, array) ?? item;
|
|
64
|
+
if (callback(transformed, index, array)) result.matched.push(mapAfter?.(item, index, array) ?? transformed);
|
|
61
65
|
else result.notMatched.push(item);
|
|
62
66
|
}
|
|
63
67
|
return result;
|
|
@@ -65,10 +69,18 @@ function findValues(type, array, parameters, mapper) {
|
|
|
65
69
|
const keys = /* @__PURE__ */ new Set();
|
|
66
70
|
for (let index = 0; index < length; index += 1) {
|
|
67
71
|
const item = array[index];
|
|
68
|
-
|
|
72
|
+
let keyed;
|
|
73
|
+
let transformed;
|
|
74
|
+
if (mapBefore == null) {
|
|
75
|
+
keyed = callbacks?.keyed?.(item, index, array) ?? item;
|
|
76
|
+
transformed = item;
|
|
77
|
+
} else {
|
|
78
|
+
transformed = mapBefore(item, index, array);
|
|
79
|
+
keyed = callbacks?.keyed?.(transformed, index, array) ?? transformed;
|
|
80
|
+
}
|
|
69
81
|
if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
|
|
70
82
|
keys.add(keyed);
|
|
71
|
-
result.matched.push(
|
|
83
|
+
result.matched.push(mapAfter?.(item, index, array) ?? transformed);
|
|
72
84
|
} else result.notMatched.push(item);
|
|
73
85
|
}
|
|
74
86
|
return result;
|