@oscarpalmer/atoms 0.199.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/flatten.d.mts +1 -1
- package/dist/array/from.d.mts +1 -1
- package/dist/array/group-by.d.mts +2 -2
- 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/array/sort.d.mts +4 -0
- package/dist/array/to-map.d.mts +2 -2
- package/dist/array/to-record.d.mts +2 -2
- package/dist/index.d.mts +131 -113
- package/dist/index.mjs +74 -29
- package/dist/internal/array/compact.d.mts +2 -2
- package/dist/internal/array/find.d.mts +5 -1
- package/dist/internal/array/find.mjs +16 -4
- package/dist/promise/constants.d.mts +3 -1
- package/dist/promise/constants.mjs +3 -1
- package/dist/promise/helpers.d.mts +1 -2
- package/dist/promise/helpers.mjs +9 -1
- package/dist/promise/index.d.mts +34 -36
- package/dist/promise/index.mjs +25 -20
- package/dist/promise/misc.mjs +2 -2
- package/dist/promise/models.d.mts +7 -6
- package/dist/queue.d.mts +4 -0
- package/dist/string/fuzzy.d.mts +2 -0
- package/dist/string/fuzzy.mjs +2 -0
- package/dist/value/freeze.d.mts +2 -0
- package/dist/value/freeze.mjs +2 -0
- package/dist/value/merge.d.mts +1 -1
- package/dist/value/merge.mjs +2 -1
- package/package.json +4 -4
- package/plugin/index.js +1 -1
package/dist/array/flatten.d.mts
CHANGED
|
@@ -11,6 +11,6 @@ import { NestedArray } from "../models.mjs";
|
|
|
11
11
|
* flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare function flatten<Item>(array: Item[]): NestedArray<Item
|
|
14
|
+
declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { flatten };
|
package/dist/array/from.d.mts
CHANGED
|
@@ -62,7 +62,7 @@ declare function times(length: number): number[];
|
|
|
62
62
|
* times(5, index => index * 2); // => [0, 2, 4, 6, 8]
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): ReturnType<Callback
|
|
65
|
+
declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): Array<ReturnType<Callback>>;
|
|
66
66
|
/**
|
|
67
67
|
* Get an array with a specified length, filled with a specified value
|
|
68
68
|
*
|
|
@@ -155,7 +155,7 @@ declare namespace groupBy {
|
|
|
155
155
|
* // }
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
-
declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
158
|
+
declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
159
159
|
/**
|
|
160
160
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
161
161
|
*
|
|
@@ -201,7 +201,7 @@ declare function groupArraysBy<Item extends PlainObject, KeyCallback extends (it
|
|
|
201
201
|
* // }
|
|
202
202
|
* ```
|
|
203
203
|
*/
|
|
204
|
-
declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ValueCallback
|
|
204
|
+
declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ValueCallback>>>>;
|
|
205
205
|
/**
|
|
206
206
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
207
207
|
*
|
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/array/sort.d.mts
CHANGED
|
@@ -172,6 +172,8 @@ declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
|
|
|
172
172
|
/**
|
|
173
173
|
* Is the array sorted according to the sorters _(and the optional default direction)_?
|
|
174
174
|
*
|
|
175
|
+
* _Available as `isSorted` and `sort.is`_
|
|
176
|
+
*
|
|
175
177
|
* @param array Array to check
|
|
176
178
|
* @param sorters Sorters to determine sorting
|
|
177
179
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
@@ -181,6 +183,8 @@ declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>
|
|
|
181
183
|
/**
|
|
182
184
|
* Is the array sorted according to the sorter _(and the optional default direction)_?
|
|
183
185
|
*
|
|
186
|
+
* _Available as `isSorted` and `sort.is`_
|
|
187
|
+
*
|
|
184
188
|
* @param array Array to check
|
|
185
189
|
* @param sorter Sorter to determine sorting
|
|
186
190
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
package/dist/array/to-map.d.mts
CHANGED
|
@@ -152,7 +152,7 @@ declare namespace toMap {
|
|
|
152
152
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
|
-
declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
155
|
+
declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
156
156
|
/**
|
|
157
157
|
* Create a _Map_ from an array of items using a callback and value, grouping values into arrays
|
|
158
158
|
*
|
|
@@ -192,7 +192,7 @@ declare function toMapArrays<Item extends PlainObject, KeyCallback extends (item
|
|
|
192
192
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], ReturnType<ValueCallback
|
|
195
|
+
declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], Array<ReturnType<ValueCallback>>>;
|
|
196
196
|
/**
|
|
197
197
|
* Create a _Map_ from an array of items using a key and value, grouping values into arrays
|
|
198
198
|
*
|
|
@@ -152,7 +152,7 @@ declare namespace toRecord {
|
|
|
152
152
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
|
-
declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
155
|
+
declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
156
156
|
/**
|
|
157
157
|
* Create a record from an array of items using a callback and value, grouping values into arrays
|
|
158
158
|
*
|
|
@@ -192,7 +192,7 @@ declare function toRecordArrays<Item extends PlainObject, Callback extends (item
|
|
|
192
192
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<Callback
|
|
195
|
+
declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<Callback>>>>;
|
|
196
196
|
/**
|
|
197
197
|
* Create a record from an array of items using a key and value, grouping values into arrays
|
|
198
198
|
*
|