@oscarpalmer/atoms 0.200.0 → 0.202.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.
@@ -1,13 +1,13 @@
1
- import { Key, PlainObject } from "../models.mjs";
1
+ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue } from "../models.mjs";
2
2
  //#region src/array/to-map.d.ts
3
3
  /**
4
- * Create a _Map_ from an array of items using callbacks
4
+ * Create a _Map_ from an array of items using a specific key
5
5
  *
6
6
  * If multiple items have the same key, the latest item's value will be used
7
7
  *
8
8
  * @param array Array to convert
9
- * @param key Callback to get an item's grouping key
10
- * @param value Callback to get an item's value
9
+ * @param key Callback or key to use for grouping
10
+ * @param value Callback or key to use for value, defaulting to the item itself
11
11
  * @returns _Map_ of keyed values
12
12
  *
13
13
  * @example
@@ -19,74 +19,14 @@ import { Key, PlainObject } from "../models.mjs";
19
19
  * ); // => Map { 10 => 3, 20 => 2 }
20
20
  * ```
21
21
  */
22
- declare function toMap<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>>;
22
+ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
23
23
  /**
24
- * Create a _Map_ from an array of items using a callback and value
25
- *
26
- * If multiple items have the same key, the latest item's value will be used
27
- *
28
- * @param array Array to convert
29
- * @param key Callback to get an item's grouping key
30
- * @param value Key to use for value
31
- * @returns _Map_ of keyed values
32
- *
33
- * @example
34
- * ```typescript
35
- * toMap(
36
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
37
- * item => item.value,
38
- * 'id',
39
- * ); // => Map { 10 => 3, 20 => 2 }
40
- * ```
41
- */
42
- declare function toMap<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Map<ReturnType<KeyCallback>, Item[ItemValue]>;
43
- /**
44
- * Create a _Map_ from an array of items using a key and callback
45
- *
46
- * If multiple items have the same key, the latest item's value will be used
47
- *
48
- * @param array Array to convert
49
- * @param key Key to use for grouping
50
- * @param value Callback to get an item's value
51
- * @returns _Map_ of keyed values
52
- *
53
- * @example
54
- * ```typescript
55
- * toMap(
56
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
57
- * 'value',
58
- * item => item.id,
59
- * ); // => Map { 10 => 3, 20 => 2 }
60
- * ```
61
- */
62
- declare function toMap<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>>;
63
- /**
64
- * Create a _Map_ from an array of items using a key and value
65
- *
66
- * If multiple items have the same key, the latest item's value will be used
67
- *
68
- * @param array Array to convert
69
- * @param key Key to use for grouping
70
- * @param value Key to use for value
71
- * @returns _Map_ of keyed values
72
- *
73
- * @example
74
- * ```typescript
75
- * toMap(
76
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
77
- * 'value',
78
- * 'id',
79
- * ); // => Map { 10 => 3, 20 => 2 }
80
- * ```
81
- */
82
- declare function toMap<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Map<Item[ItemKey], Item[ItemValue]>;
83
- /**
84
- * Create a _Map_ from an array of items using a callback
24
+ * Create a _Map_ from an array of items using a specific key
85
25
  *
86
26
  * If multiple items have the same key, the latest item will be used
87
27
  *
88
28
  * @param array Array to convert
89
- * @param callback Callback to get an item's grouping key
29
+ * @param key Callback or key to use for grouping
90
30
  * @returns _Map_ of keyed items
91
31
  *
92
32
  * @example
@@ -97,25 +37,7 @@ declare function toMap<Item extends PlainObject, ItemKey extends keyof Item, Ite
97
37
  * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
98
38
  * ```
99
39
  */
100
- declare function toMap<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item>;
101
- /**
102
- * Create a _Map_ from an array of items using a key
103
- *
104
- * If multiple items have the same key, the latest item will be used
105
- *
106
- * @param array Array to convert
107
- * @param key Key to use for grouping
108
- * @returns _Map_ of keyed items
109
- *
110
- * @example
111
- * ```typescript
112
- * toMap(
113
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
114
- * 'value',
115
- * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
116
- * ```
117
- */
118
- declare function toMap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item>;
40
+ declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
119
41
  /**
120
42
  * Create a _Map_ from an array of items _(using indices as keys)_
121
43
  *
@@ -134,13 +56,13 @@ declare namespace toMap {
134
56
  var arrays: typeof toMapArrays;
135
57
  }
136
58
  /**
137
- * Create a _Map_ from an array of items using callbacks, grouping values into arrays
59
+ * Create a _Map_ from an array of items using a specific key, grouping values into arrays
138
60
  *
139
61
  * _Available as `toMapArrays` and `toMap.arrays`_
140
62
  *
141
63
  * @param array Array to convert
142
- * @param key Callback to get an item's grouping key
143
- * @param value Callback to get an item's value
64
+ * @param key Callback or key to use for grouping
65
+ * @param value Callback or key to use for value, defaulting to the item itself
144
66
  * @returns _Map_ of keyed arrays of values
145
67
  *
146
68
  * @example
@@ -152,74 +74,14 @@ declare namespace toMap {
152
74
  * ); // => Map { 10 => [1, 3], 20 => [2] }
153
75
  * ```
154
76
  */
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>>>;
77
+ declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
156
78
  /**
157
- * Create a _Map_ from an array of items using a callback and value, grouping values into arrays
79
+ * Create a _Map_ from an array of items using a specific key, grouping items into arrays
158
80
  *
159
81
  * _Available as `toMapArrays` and `toMap.arrays`_
160
82
  *
161
83
  * @param array Array to convert
162
- * @param key Callback to get an item's grouping key
163
- * @param value Key to use for value
164
- * @returns _Map_ of keyed arrays of values
165
- *
166
- * @example
167
- * ```typescript
168
- * toMapArrays(
169
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
170
- * item => item.value,
171
- * 'id',
172
- * ); // => Map { 10 => [1, 3], 20 => [2] }
173
- * ```
174
- */
175
- declare function toMapArrays<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Map<ReturnType<KeyCallback>, Item[ItemValue][]>;
176
- /**
177
- * Create a _Map_ from an array of items using a key and callback, grouping values into arrays
178
- *
179
- * _Available as `toMapArrays` and `toMap.arrays`_
180
- *
181
- * @param array Array to convert
182
- * @param key Key to use for grouping
183
- * @param value Callback to get an item's value
184
- * @returns _Map_ of keyed arrays of values
185
- *
186
- * @example
187
- * ```typescript
188
- * toMapArrays(
189
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
190
- * 'value',
191
- * item => item.id,
192
- * ); // => Map { 10 => [1, 3], 20 => [2] }
193
- * ```
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], Array<ReturnType<ValueCallback>>>;
196
- /**
197
- * Create a _Map_ from an array of items using a key and value, grouping values into arrays
198
- *
199
- * _Available as `toMapArrays` and `toMap.arrays`_
200
- *
201
- * @param array Array to convert
202
- * @param key Key to use for grouping
203
- * @param value Key to use for value
204
- * @returns _Map_ of keyed arrays of values
205
- *
206
- * @example
207
- * ```typescript
208
- * toMapArrays(
209
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
210
- * 'value',
211
- * 'id',
212
- * ); // => Map { 10 => [1, 3], 20 => [2] }
213
- * ```
214
- */
215
- declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Map<Item[ItemKey], Item[ItemValue][]>;
216
- /**
217
- * Create a _Map_ from an array of items using a callback, grouping items into arrays
218
- *
219
- * _Available as `toMapArrays` and `toMap.arrays`_
220
- *
221
- * @param array Array to convert
222
- * @param callback Callback to get an item's grouping key
84
+ * @param key Callback or key to use for grouping
223
85
  * @returns _Map_ of keyed arrays of items
224
86
  *
225
87
  * @example
@@ -230,24 +92,6 @@ declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Ite
230
92
  * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
231
93
  * ```
232
94
  */
233
- declare function toMapArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item[]>;
234
- /**
235
- * Create a _Map_ from an array of items using a key, grouping items into arrays
236
- *
237
- * _Available as `toMapArrays` and `toMap.arrays`_
238
- *
239
- * @param array Array to convert
240
- * @param key Key to use for grouping
241
- * @returns _Map_ of keyed arrays of items
242
- *
243
- * @example
244
- * ```typescript
245
- * toMapArrays(
246
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
247
- * 'value',
248
- * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
249
- * ```
250
- */
251
- declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item[]>;
95
+ declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
252
96
  //#endregion
253
97
  export { toMap, toMapArrays };
@@ -1,13 +1,13 @@
1
- import { Key, KeyedValue, PlainObject, Simplify } from "../models.mjs";
1
+ import { Key, KeyOrCallback, KeyOrCallbackKey, KeyOrCallbackValue, Simplify } from "../models.mjs";
2
2
  //#region src/array/to-record.d.ts
3
3
  /**
4
- * Create a record from an array of items using callbacks
4
+ * Create a record from an array of items using a specific key
5
5
  *
6
6
  * If multiple items have the same key, the latest item will be used
7
7
  *
8
8
  * @param array Array to convert
9
- * @param key Callback to get an item's grouping key
10
- * @param value Callback to get an item's value
9
+ * @param key Callback or key to use for grouping
10
+ * @param value Callback or key to use for value, defaulting to the item itself
11
11
  * @returns Record of keyed values
12
12
  *
13
13
  * @example
@@ -19,74 +19,14 @@ import { Key, KeyedValue, PlainObject, Simplify } from "../models.mjs";
19
19
  * ); // => { 10: 3, 20: 2 }
20
20
  * ```
21
21
  */
22
- declare function toRecord<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>>;
22
+ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
23
23
  /**
24
- * Create a record from an array of items using a callback and value
24
+ * Create a record from an array of items using a specific key
25
25
  *
26
26
  * If multiple items have the same key, the latest item will be used
27
27
  *
28
28
  * @param array Array to convert
29
- * @param callback Callback to get an item's grouping key
30
- * @param value Key to use for value
31
- * @returns Record with keys
32
- *
33
- * @example
34
- * ```typescript
35
- * toRecord(
36
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
37
- * item => item.value,
38
- * 'id',
39
- * ); // => { 10: 3, 20: 2 }
40
- * ```
41
- */
42
- declare function toRecord<Item extends PlainObject, Callback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], callback: Callback, value: ItemValue): Record<ReturnType<Callback>, Item[ItemValue]>;
43
- /**
44
- * Create a record from an array of items using a key and callback
45
- *
46
- * If multiple items have the same key, the latest item will be used
47
- *
48
- * @param array Array to convert
49
- * @param key Key to use for grouping
50
- * @param callback Callback to get an item's value
51
- * @returns Record with keys
52
- *
53
- * @example
54
- * ```typescript
55
- * toRecord(
56
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
57
- * 'value',
58
- * item => item.id,
59
- * ); // => { 10: 3, 20: 2 }
60
- * ```
61
- */
62
- declare function toRecord<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>>>;
63
- /**
64
- * Create a record from an array of items using a key and value
65
- *
66
- * If multiple items have the same key, the latest item will be used
67
- *
68
- * @param array Array to convert
69
- * @param key Key to use for grouping
70
- * @param value Key to use for value
71
- * @returns Record of keyed values
72
- *
73
- * @example
74
- * ```typescript
75
- * toRecord(
76
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
77
- * 'value',
78
- * 'id',
79
- * ); // => { 10: 3, 20: 2 }
80
- * ```
81
- */
82
- declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
83
- /**
84
- * Create a record from an array of items using a callback
85
- *
86
- * If multiple items have the same key, the latest item will be used
87
- *
88
- * @param array Array to convert
89
- * @param callback Callback to get an item's grouping key
29
+ * @param key Callback or key to use for grouping
90
30
  * @returns Record of keyed values
91
31
  *
92
32
  * @example
@@ -97,25 +37,7 @@ declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item,
97
37
  * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
98
38
  * ```
99
39
  */
100
- declare function toRecord<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
101
- /**
102
- * Create a record from an array of items using a key
103
- *
104
- * If multiple items have the same key, the latest item will be used
105
- *
106
- * @param array Array to convert
107
- * @param key Key to use for grouping
108
- * @returns Record of keyed values
109
- *
110
- * @example
111
- * ```typescript
112
- * toRecord(
113
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
114
- * 'value',
115
- * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
116
- * ```
117
- */
118
- declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
40
+ declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
119
41
  /**
120
42
  * Create a record from an array of items _(using indices as keys)_
121
43
  *
@@ -134,33 +56,13 @@ declare namespace toRecord {
134
56
  var arrays: typeof toRecordArrays;
135
57
  }
136
58
  /**
137
- * Create a record from an array of items using callbacks, grouping values into arrays
138
- *
139
- * _Available as `toRecordArrays` and `toRecord.arrays`_
140
- *
141
- * @param array Array to convert
142
- * @param key Callback to get an item's grouping key
143
- * @param value Callback to get an item's value
144
- * @returns Record of keyed arrays of values
145
- *
146
- * @example
147
- * ```typescript
148
- * toRecordArrays(
149
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
150
- * item => item.value,
151
- * item => item.id,
152
- * ); // => { 10: [1, 3], 20: [2] }
153
- * ```
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>, Array<ReturnType<ValueCallback>>>;
156
- /**
157
- * Create a record from an array of items using a callback and value, grouping values into arrays
59
+ * Create a record from an array of items using a specific key, grouping values into arrays
158
60
  *
159
61
  * _Available as `toRecordArrays` and `toRecord.arrays`_
160
62
  *
161
63
  * @param array Array to convert
162
- * @param callback Callback to get an item's grouping key
163
- * @param value Key to use for value
64
+ * @param key Callback or key to use for grouping
65
+ * @param value Callback or key to use for value, defaulting to the item itself
164
66
  * @returns Record of keyed arrays of values
165
67
  *
166
68
  * @example
@@ -168,58 +70,18 @@ declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: nu
168
70
  * toRecordArrays(
169
71
  * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
170
72
  * item => item.value,
171
- * 'id',
172
- * ); // => { 10: [1, 3], 20: [2] }
173
- * ```
174
- */
175
- declare function toRecordArrays<Item extends PlainObject, Callback extends (item: Item, index: number, array: Item[]) => Key, ItemValue extends keyof Item>(array: Item[], callback: Callback, value: ItemValue): Record<ReturnType<Callback>, Item[ItemValue][]>;
176
- /**
177
- * Create a record from an array of items using a key and callback, grouping values into arrays
178
- *
179
- * _Available as `toRecordArrays` and `toRecord.arrays`_
180
- *
181
- * @param array Array to convert
182
- * @param key Key to use for grouping
183
- * @param callback Callback to get an item's value
184
- * @returns Record of keyed arrays of values
185
- *
186
- * @example
187
- * ```typescript
188
- * toRecordArrays(
189
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
190
- * 'value',
191
73
  * item => item.id,
192
74
  * ); // => { 10: [1, 3], 20: [2] }
193
75
  * ```
194
76
  */
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>>>>;
77
+ declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
196
78
  /**
197
- * Create a record from an array of items using a key and value, grouping values into arrays
79
+ * Create a record from an array of items using a specific key, grouping items into arrays
198
80
  *
199
81
  * _Available as `toRecordArrays` and `toRecord.arrays`_
200
82
  *
201
83
  * @param array Array to convert
202
- * @param key Key to use for grouping
203
- * @param value Key to use for value
204
- * @returns Record of keyed arrays of values
205
- *
206
- * @example
207
- * ```typescript
208
- * toRecordArrays(
209
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
210
- * 'value',
211
- * 'id',
212
- * ); // => { 10: [1, 3], 20: [2] }
213
- * ```
214
- */
215
- declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue][]>>;
216
- /**
217
- * Create a record from an array of items using a callback, grouping items into arrays
218
- *
219
- * _Available as `toRecordArrays` and `toRecord.arrays`_
220
- *
221
- * @param array Array to convert
222
- * @param callback Callback to get an item's grouping key
84
+ * @param key Callback or key to use for grouping
223
85
  * @returns Record of keyed arrays of items
224
86
  *
225
87
  * @example
@@ -230,24 +92,6 @@ declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof
230
92
  * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
231
93
  * ```
232
94
  */
233
- declare function toRecordArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
234
- /**
235
- * Create a record from an array of items using a key, grouping items into arrays
236
- *
237
- * _Available as `toRecordArrays` and `toRecord.arrays`_
238
- *
239
- * @param array Array to convert
240
- * @param key Key to use for grouping
241
- * @returns Record of keyed arrays of items
242
- *
243
- * @example
244
- * ```typescript
245
- * toRecordArrays(
246
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
247
- * 'value',
248
- * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
249
- * ```
250
- */
251
- declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
95
+ declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
252
96
  //#endregion
253
97
  export { toRecord, toRecordArrays };