@oscarpalmer/atoms 0.184.2 → 0.186.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.
Files changed (156) hide show
  1. package/dist/array/difference.d.mts +29 -0
  2. package/dist/array/exists.d.mts +35 -0
  3. package/dist/array/filter.d.mts +72 -2
  4. package/dist/array/find.d.mts +70 -0
  5. package/dist/array/first.d.mts +77 -2
  6. package/dist/array/flatten.d.mts +6 -0
  7. package/dist/array/flatten.mjs +6 -0
  8. package/dist/array/from.d.mts +36 -0
  9. package/dist/array/get.d.mts +21 -13
  10. package/dist/array/group-by.d.mts +142 -0
  11. package/dist/array/index.d.mts +2 -2
  12. package/dist/array/index.mjs +2 -2
  13. package/dist/array/insert.d.mts +16 -0
  14. package/dist/array/intersection.d.mts +29 -0
  15. package/dist/array/last.d.mts +75 -2
  16. package/dist/array/{position.d.mts → match.d.mts} +168 -36
  17. package/dist/array/{position.mjs → match.mjs} +16 -16
  18. package/dist/array/move.d.mts +78 -8
  19. package/dist/array/move.mjs +11 -1
  20. package/dist/array/partition.d.mts +35 -0
  21. package/dist/array/push.d.mts +8 -0
  22. package/dist/array/push.mjs +8 -0
  23. package/dist/array/reverse.d.mts +1 -0
  24. package/dist/array/reverse.mjs +1 -0
  25. package/dist/array/select.d.mts +94 -8
  26. package/dist/array/single.d.mts +29 -0
  27. package/dist/array/slice.d.mts +106 -16
  28. package/dist/array/sort.d.mts +30 -4
  29. package/dist/array/sort.mjs +1 -1
  30. package/dist/array/splice.d.mts +48 -0
  31. package/dist/array/splice.mjs +2 -1
  32. package/dist/array/swap.d.mts +113 -8
  33. package/dist/array/swap.mjs +2 -1
  34. package/dist/array/to-map.d.mts +124 -0
  35. package/dist/array/to-record.d.mts +124 -0
  36. package/dist/array/to-set.d.mts +24 -0
  37. package/dist/array/toggle.d.mts +38 -3
  38. package/dist/array/union.d.mts +29 -0
  39. package/dist/array/unique.d.mts +24 -0
  40. package/dist/array/update.d.mts +38 -3
  41. package/dist/beacon.d.mts +12 -0
  42. package/dist/beacon.mjs +9 -0
  43. package/dist/color/instance.d.mts +8 -0
  44. package/dist/color/instance.mjs +3 -0
  45. package/dist/color/models.d.mts +30 -0
  46. package/dist/function/assert.d.mts +29 -8
  47. package/dist/function/assert.mjs +29 -8
  48. package/dist/function/memoize.d.mts +3 -0
  49. package/dist/function/memoize.mjs +3 -0
  50. package/dist/function/retry.d.mts +3 -0
  51. package/dist/function/retry.mjs +3 -0
  52. package/dist/function/work.mjs +1 -1
  53. package/dist/index.d.mts +2158 -288
  54. package/dist/index.mjs +294 -181
  55. package/dist/internal/array/chunk.d.mts +6 -0
  56. package/dist/internal/array/chunk.mjs +6 -0
  57. package/dist/internal/array/compact.d.mts +12 -0
  58. package/dist/internal/array/index-of.d.mts +70 -0
  59. package/dist/internal/math/aggregate.d.mts +29 -0
  60. package/dist/internal/value/compare.d.mts +2 -1
  61. package/dist/internal/value/equal.d.mts +5 -0
  62. package/dist/internal/value/get.d.mts +27 -5
  63. package/dist/internal/value/has.d.mts +7 -7
  64. package/dist/internal/value/has.mjs +1 -1
  65. package/dist/internal/value/misc.d.mts +2 -2
  66. package/dist/internal/value/misc.mjs +10 -4
  67. package/dist/logger.d.mts +11 -0
  68. package/dist/logger.mjs +11 -0
  69. package/dist/models.d.mts +14 -1
  70. package/dist/promise/helpers.mjs +1 -1
  71. package/dist/promise/index.d.mts +0 -6
  72. package/dist/promise/models.d.mts +36 -0
  73. package/dist/promise/models.mjs +6 -0
  74. package/dist/queue.d.mts +13 -1
  75. package/dist/queue.mjs +9 -0
  76. package/dist/result/index.d.mts +0 -8
  77. package/dist/result/index.mjs +0 -8
  78. package/dist/result/match.d.mts +4 -4
  79. package/dist/result/work/flow.d.mts +12 -36
  80. package/dist/result/work/pipe.d.mts +11 -33
  81. package/dist/sized/set.d.mts +3 -2
  82. package/dist/sized/set.mjs +3 -2
  83. package/dist/value/collection.d.mts +1 -1
  84. package/dist/value/handle.mjs +1 -1
  85. package/dist/value/merge.d.mts +28 -25
  86. package/dist/value/merge.mjs +29 -18
  87. package/dist/value/shake.d.mts +3 -0
  88. package/dist/value/smush.d.mts +3 -0
  89. package/dist/value/transform.d.mts +10 -1
  90. package/dist/value/unsmush.d.mts +2 -3
  91. package/package.json +5 -5
  92. package/src/array/difference.ts +33 -0
  93. package/src/array/exists.ts +35 -0
  94. package/src/array/filter.ts +72 -2
  95. package/src/array/find.ts +70 -0
  96. package/src/array/first.ts +77 -3
  97. package/src/array/flatten.ts +6 -0
  98. package/src/array/from.ts +40 -0
  99. package/src/array/get.ts +21 -15
  100. package/src/array/group-by.ts +142 -0
  101. package/src/array/index.ts +1 -1
  102. package/src/array/insert.ts +16 -2
  103. package/src/array/intersection.ts +33 -0
  104. package/src/array/last.ts +75 -2
  105. package/src/array/{position.ts → match.ts} +197 -65
  106. package/src/array/move.ts +87 -13
  107. package/src/array/partition.ts +35 -0
  108. package/src/array/push.ts +8 -2
  109. package/src/array/reverse.ts +5 -0
  110. package/src/array/select.ts +96 -13
  111. package/src/array/single.ts +29 -0
  112. package/src/array/slice.ts +114 -24
  113. package/src/array/sort.ts +30 -4
  114. package/src/array/splice.ts +52 -4
  115. package/src/array/swap.ts +122 -13
  116. package/src/array/to-map.ts +124 -0
  117. package/src/array/to-record.ts +124 -0
  118. package/src/array/to-set.ts +24 -0
  119. package/src/array/toggle.ts +42 -3
  120. package/src/array/union.ts +33 -0
  121. package/src/array/unique.ts +24 -0
  122. package/src/array/update.ts +38 -3
  123. package/src/beacon.ts +12 -0
  124. package/src/color/index.ts +0 -3
  125. package/src/color/instance.ts +9 -1
  126. package/src/color/models.ts +30 -0
  127. package/src/function/assert.ts +66 -7
  128. package/src/function/memoize.ts +3 -0
  129. package/src/function/once.ts +5 -1
  130. package/src/function/retry.ts +3 -0
  131. package/src/internal/array/chunk.ts +6 -0
  132. package/src/internal/array/compact.ts +12 -0
  133. package/src/internal/array/index-of.ts +70 -0
  134. package/src/internal/math/aggregate.ts +29 -0
  135. package/src/internal/string.ts +0 -2
  136. package/src/internal/value/compare.ts +2 -1
  137. package/src/internal/value/equal.ts +5 -0
  138. package/src/internal/value/get.ts +27 -5
  139. package/src/internal/value/has.ts +10 -10
  140. package/src/internal/value/misc.ts +24 -13
  141. package/src/logger.ts +11 -0
  142. package/src/models.ts +18 -0
  143. package/src/promise/index.ts +0 -6
  144. package/src/promise/models.ts +36 -0
  145. package/src/queue.ts +13 -1
  146. package/src/result/index.ts +0 -8
  147. package/src/result/match.ts +4 -4
  148. package/src/result/work/flow.ts +12 -36
  149. package/src/result/work/pipe.ts +11 -33
  150. package/src/sized/set.ts +4 -3
  151. package/src/value/collection.ts +1 -1
  152. package/src/value/merge.ts +88 -66
  153. package/src/value/shake.ts +3 -0
  154. package/src/value/smush.ts +3 -0
  155. package/src/value/transform.ts +10 -1
  156. package/src/value/unsmush.ts +2 -8
package/dist/index.d.mts CHANGED
@@ -143,74 +143,157 @@ type ToString<Value> = Value extends string | number ? `${Value}` : never;
143
143
  * A union type of all typed arrays
144
144
  */
145
145
  type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
146
+ /**
147
+ * Converts a union type to an intersection type
148
+ *
149
+ * @example
150
+ * ```typescript
151
+ * type A = {a: string};
152
+ * type B = {b: number};
153
+ * type C = UnionToIntersection<A | B>; // {a: string} & {b: number}
154
+ * ```
155
+ *
156
+ * Thanks, type-fest!
157
+ */
158
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
146
159
  //#endregion
147
160
  //#region src/array/filter.d.ts
148
161
  /**
149
- * Get a filtered array of items that do not match the filter
162
+ * Get a filtered array of items that do not match the value
150
163
  *
151
164
  * Available as `exclude` and `filter.remove`
165
+ *
152
166
  * @param array Array to search in
153
167
  * @param callback Callback to get an item's value for matching
154
168
  * @param value Value to match against
155
169
  * @returns Filtered array of items that do not match the filter
170
+ *
171
+ * @example
172
+ * ```typescript
173
+ * exclude(
174
+ * [{id: 1}, {id: 2}, {id: 3}],
175
+ * item => item.id,
176
+ * 2,
177
+ * ); // => [{id: 1}, {id: 3}]
178
+ * ```
156
179
  */
157
180
  declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
158
181
  /**
159
- * Get a filtered array of items that do not match the filter
182
+ * Get a filtered array of items that do not match the value
160
183
  *
161
184
  * Available as `exclude` and `filter.remove`
185
+ *
162
186
  * @param array Array to search in
163
187
  * @param key Key to get an item's value for matching
164
188
  * @param value Value to match against
165
189
  * @returns Filtered array of items that do not match the filter
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * exclude(
194
+ * [{id: 1}, {id: 2}, {id: 3}],
195
+ * 'id',
196
+ * 2,
197
+ * ); // => [{id: 1}, {id: 3}]
198
+ * ```
166
199
  */
167
200
  declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): unknown[];
168
201
  /**
169
202
  * Get a filtered array of items that do not match the filter
170
203
  *
171
204
  * Available as `exclude` and `filter.remove`
205
+ *
172
206
  * @param array Array to search in
173
207
  * @param filter Filter callback to match items
174
208
  * @returns Filtered array of items that do not match the filter
209
+ *
210
+ * @example
211
+ * ```typescript
212
+ * exclude(
213
+ * [{id: 1}, {id: 2}, {id: 3}],
214
+ * item => item.id === 2,
215
+ * ); // => [{id: 1}, {id: 3}]
216
+ * ```
175
217
  */
176
218
  declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
177
219
  /**
178
220
  * Get a filtered array of items that do not match the given item
179
221
  *
180
222
  * Available as `exclude` and `filter.remove`
223
+ *
181
224
  * @param array Array to search in
182
225
  * @param item Item to match against
183
226
  * @returns Filtered array of items that do not match the given item
227
+ *
228
+ * @example
229
+ * ```typescript
230
+ * exclude([1, 2, 3], 2); // => [1, 3]
231
+ * ```
184
232
  */
185
233
  declare function exclude<Item>(array: Item[], item: Item): unknown[];
186
234
  /**
187
235
  * Get a filtered array of items
236
+ *
188
237
  * @param array Array to search in
189
238
  * @param callback Callback to get an item's value for matching
190
239
  * @param value Value to match against
191
240
  * @returns Filtered array of items
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * filter(
245
+ * [{id: 1}, {id: 2}, {id: 3}],
246
+ * item => item.id,
247
+ * 2,
248
+ * ); // => [{id: 2}]
249
+ * ```
192
250
  */
193
251
  declare function filter<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
194
252
  /**
195
253
  * Get a filtered array of items
254
+ *
196
255
  * @param array Array to search in
197
256
  * @param key Key to get an item's value for matching
198
257
  * @param value Value to match against
199
258
  * @returns Filtered array of items
259
+ *
260
+ * @example
261
+ * ```typescript
262
+ * filter(
263
+ * [{id: 1}, {id: 2}, {id: 3}],
264
+ * 'id',
265
+ * 2,
266
+ * ); // => [{id: 2}]
267
+ * ```
200
268
  */
201
269
  declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
202
270
  /**
203
271
  * Get a filtered array of items matching the filter
272
+ *
204
273
  * @param array Array to search in
205
274
  * @param filter Filter callback to match items
206
275
  * @returns Filtered array of items
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * filter(
280
+ * [{id: 1}, {id: 2}, {id: 3}],
281
+ * item => item.id === 2,
282
+ * ); // => [{id: 2}]
283
+ * ```
207
284
  */
208
285
  declare function filter<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
209
286
  /**
210
287
  * Get a filtered array of items matching the given item
288
+ *
211
289
  * @param array Array to search in
212
290
  * @param item Item to match against
213
291
  * @returns Filtered array of items
292
+ *
293
+ * @example
294
+ * ```typescript
295
+ * filter([1, 2, 3], 2); // => [2]
296
+ * ```
214
297
  */
215
298
  declare function filter<Item>(array: Item[], item: Item): Item[];
216
299
  declare namespace filter {
@@ -220,31 +303,68 @@ declare namespace filter {
220
303
  //#region src/array/first.d.ts
221
304
  /**
222
305
  * Get the first item matching the given value
306
+ *
223
307
  * @param array Array to search in
224
308
  * @param callback Callback to get an item's value for matching
225
309
  * @param value Value to match against
226
310
  * @returns First item that matches the value, or `undefined` if no match is found
311
+ *
312
+ * @example
313
+ * ```typescript
314
+ * first(
315
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
316
+ * item => item.value,
317
+ * 10,
318
+ * ); // => {id: 1, value: 10}
319
+ * ```
227
320
  */
228
321
  declare function first<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
229
322
  /**
230
323
  * Get the first item matching the given value by key
324
+ *
231
325
  * @param array Array to search in
232
326
  * @param key Key to get an item's value for matching
233
327
  * @param value Value to match against
234
328
  * @returns First item that matches the value, or `undefined` if no match is found
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * first(
333
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
334
+ * 'value',
335
+ * 10,
336
+ * ); // => {id: 1, value: 10}
337
+ * ```
235
338
  */
236
339
  declare function first<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
237
340
  /**
238
341
  * Get the first item matching the filter
342
+ *
239
343
  * @param array Array to search in
240
344
  * @param filter Filter callback to match items
241
345
  * @returns First item that matches the filter, or `undefined` if no match is found
346
+ *
347
+ * @example
348
+ * ```typescript
349
+ * first(
350
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
351
+ * item => item.value === 10,
352
+ * ); // => {id: 1, value: 10}
353
+ * ```
242
354
  */
243
355
  declare function first<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
244
356
  /**
245
357
  * Get the first item from an array
358
+ *
246
359
  * @param array Array to get from
247
- * @return First item from the array, or `undefined` if the array is empty
360
+ * @returns First item from the array, or `undefined` if the array is empty
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * first(
365
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
366
+ * ); // => {id: 1, value: 10}
367
+ * ```
248
368
  */
249
369
  declare function first<Item>(array: Item[]): Item | undefined;
250
370
  declare namespace first {
@@ -255,41 +375,79 @@ declare namespace first {
255
375
  * Get the first item matching the given value, or a default value if no match is found
256
376
  *
257
377
  * Available as `firstOrDefault` and `first.default`
378
+ *
258
379
  * @param array Array to search in
259
380
  * @param defaultValue Default value to return if no match is found
260
381
  * @param callback Callback to get an item's value for matching
261
382
  * @param value Value to match against
262
383
  * @returns First item that matches the value, or the default value if no match is found
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * firstOrDefault(
388
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
389
+ * {id: -1, value: 30},
390
+ * item => item.value,
391
+ * 30,
392
+ * ); // => {id: -1, value: 30}
393
+ * ```
263
394
  */
264
395
  declare function firstOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
265
396
  /**
266
397
  * Get the first item matching the given value by key, or a default value if no match is found
267
398
  *
268
399
  * Available as `firstOrDefault` and `first.default`
400
+ *
269
401
  * @param array Array to search in
270
402
  * @param defaultValue Default value to return if no match is found
271
403
  * @param key Key to get an item's value for matching
272
404
  * @param value Value to match against
273
405
  * @returns First item that matches the value, or the default value if no match is found
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * firstOrDefault(
410
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
411
+ * {id: -1, value: 30},
412
+ * 'value',
413
+ * 30,
414
+ * ); // => {id: -1, value: 30}
415
+ * ```
274
416
  */
275
417
  declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
276
418
  /**
277
419
  * Get the first item matching the filter, or a default value if no match is found
278
420
  *
279
421
  * Available as `firstOrDefault` and `first.default`
422
+ *
280
423
  * @param array Array to search in
281
424
  * @param defaultValue Default value to return if no match is found
282
425
  * @param filter Filter callback to match items
283
426
  * @returns First item that matches the filter, or the default value if no match is found
427
+ *
428
+ * @example
429
+ * ```typescript
430
+ * firstOrDefault(
431
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
432
+ * {id: -1, value: 30},
433
+ * item => item.value === 30,
434
+ * ); // => {id: -1, value: 30}
435
+ * ```
284
436
  */
285
437
  declare function firstOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
286
438
  /**
287
439
  * Get the first item from an array, or a default value if the array is empty
288
440
  *
289
441
  * Available as `firstOrDefault` and `first.default`
442
+ *
290
443
  * @param array Array to get from
291
444
  * @param defaultValue Default value to return if the array is empty
292
- * @return First item from the array, or the default value if the array is empty
445
+ * @returns First item from the array, or the default value if the array is empty
446
+ *
447
+ * @example
448
+ * ```typescript
449
+ * firstOrDefault([], {id: -1, value: 30}); // => {id: -1, value: 30}
450
+ * ```
293
451
  */
294
452
  declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
295
453
  //#endregion
@@ -298,64 +456,130 @@ declare function firstOrDefault<Item>(array: Item[], defaultValue: Item): Item;
298
456
  * Create a record from an array of items using a specific key and value
299
457
  *
300
458
  * If multiple items have the same key, the latest item's value will be used
459
+ *
301
460
  * @param array Array to group
302
461
  * @param key Callback to get an item's grouping key
303
462
  * @param value Callback to get an item's value
304
463
  * @returns Record of keyed values
464
+ *
465
+ * @example
466
+ * ```typescript
467
+ * groupBy(
468
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
469
+ * item => item.value,
470
+ * item => item,
471
+ * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
472
+ * ```
305
473
  */
306
474
  declare function groupBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Simplify<Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>>>;
307
475
  /**
308
476
  * Create a record from an array of items using a specific key and value
309
477
  *
310
478
  * If multiple items have the same key, the latest item's value will be used
479
+ *
311
480
  * @param array Array to group
312
481
  * @param key Callback to get an item's grouping key
313
482
  * @param value Key to use for value
314
483
  * @returns Record of keyed values
484
+ *
485
+ * @example
486
+ * ```typescript
487
+ * groupBy(
488
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
489
+ * item => item.value,
490
+ * 'id'
491
+ * ); // => {10: 3, 20: 2}
492
+ * ```
315
493
  */
316
494
  declare function groupBy<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Record<ReturnType<KeyCallback>, Item[ItemValue]>;
317
495
  /**
318
496
  * Create a record from an array of items using a specific key and value
319
497
  *
320
498
  * If multiple items have the same key, the latest item's value will be used
499
+ *
321
500
  * @param array Array to group
322
501
  * @param key Key to use for grouping
323
502
  * @param value Callback to get an item's value
324
503
  * @returns Record of keyed values
504
+ *
505
+ * @example
506
+ * ```typescript
507
+ * groupBy(
508
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
509
+ * 'value',
510
+ * item => item,
511
+ * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
512
+ * ```
325
513
  */
326
514
  declare function groupBy<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>>>;
327
515
  /**
328
516
  * Create a record from an array of items using a specific key and value
329
517
  *
330
518
  * If multiple items have the same key, the latest item's value will be used
519
+ *
331
520
  * @param array Array to group
332
521
  * @param key Key to use for grouping
333
522
  * @param value Key to use for value
334
523
  * @returns Record of keyed values
524
+ *
525
+ * @example
526
+ * ```typescript
527
+ * groupBy(
528
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
529
+ * 'value',
530
+ * 'id'
531
+ * ); // => {10: 3, 20: 2}
532
+ * ```
335
533
  */
336
534
  declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue]>>;
337
535
  /**
338
536
  * Create a record from an array of items using a specific key
339
537
  *
340
538
  * If multiple items have the same key, the latest item will be used
539
+ *
341
540
  * @param array Array to group
342
541
  * @param callback Callback to get an item's grouping key
343
542
  * @returns Record of keyed items
543
+ *
544
+ * @example
545
+ * ```typescript
546
+ * groupBy(
547
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
548
+ * item => item.value,
549
+ * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
550
+ * ```
344
551
  */
345
552
  declare function groupBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
346
553
  /**
347
554
  * Create a record from an array of items using a specific key
348
555
  *
349
556
  * If multiple items have the same key, the latest item will be used
557
+ *
350
558
  * @param array Array to group
351
559
  * @param key Key to use for grouping
352
560
  * @returns Record of keyed items
561
+ *
562
+ * @example
563
+ * ```typescript
564
+ * groupBy(
565
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
566
+ * 'value',
567
+ * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
568
+ * ```
353
569
  */
354
570
  declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
355
571
  /**
356
572
  * Create a record from an array of items _(using indices as keys)_
573
+ *
357
574
  * @param array Array to group
358
575
  * @returns Record of indiced items
576
+ *
577
+ * @example
578
+ * ```typescript
579
+ * groupBy(
580
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
581
+ * ); // => {0: {id: 1, value: 10}, 1: {id: 2, value: 20}, 2: {id: 3, value: 10}}
582
+ * ```
359
583
  */
360
584
  declare function groupBy<Item>(array: Item[]): Record<number, Item>;
361
585
  declare namespace groupBy {
@@ -365,114 +589,243 @@ declare namespace groupBy {
365
589
  * Create a record from an array of items using a specific key and value, grouping values into arrays
366
590
  *
367
591
  * Available as `groupArraysBy` and `groupBy.arrays`
592
+ *
368
593
  * @param array Array to group
369
594
  * @param key Callback to get an item's grouping key
370
595
  * @param value Callback to get an item's value
371
596
  * @returns Record of keyed values
597
+ *
598
+ * @example
599
+ * ```typescript
600
+ * groupArraysBy(
601
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
602
+ * item => item.value,
603
+ * item => item,
604
+ * ); // => {
605
+ * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
606
+ * // 20: [{id: 2, value: 20}],
607
+ * // }
608
+ * ```
372
609
  */
373
610
  declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>[]>;
374
611
  /**
375
612
  * Create a record from an array of items using a specific key and value, grouping values into arrays
376
613
  *
377
614
  * Available as `groupArraysBy` and `groupBy.arrays`
615
+ *
378
616
  * @param array Array to group
379
617
  * @param key Callback to get an item's grouping key
380
618
  * @param value Key to use for value
381
619
  * @returns Record of keyed values
620
+ *
621
+ * @example
622
+ * ```typescript
623
+ * groupArraysBy(
624
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
625
+ * item => item.value,
626
+ * 'id',
627
+ * ); // => {
628
+ * // 10: [1, 3],
629
+ * // 20: [2],
630
+ * // }
631
+ * ```
382
632
  */
383
633
  declare function groupArraysBy<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Record<ReturnType<KeyCallback>, Item[ItemValue][]>;
384
634
  /**
385
635
  * Create a record from an array of items using a specific key and value, grouping values into arrays
386
636
  *
387
637
  * Available as `groupArraysBy` and `groupBy.arrays`
638
+ *
388
639
  * @param array Array to group
389
640
  * @param key Key to use for grouping
390
641
  * @param value Callback to get an item's value
391
642
  * @returns Record of keyed values
643
+ *
644
+ * @example
645
+ * ```typescript
646
+ * groupArraysBy(
647
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
648
+ * 'value',
649
+ * item => item,
650
+ * ); // => {
651
+ * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
652
+ * // 20: [{id: 2, value: 20}],
653
+ * // }
654
+ * ```
392
655
  */
393
656
  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>[]>>;
394
657
  /**
395
658
  * Create a record from an array of items using a specific key and value, grouping values into arrays
396
659
  *
397
660
  * Available as `groupArraysBy` and `groupBy.arrays`
661
+ *
398
662
  * @param array Array to group
399
663
  * @param key Key to use for grouping
400
664
  * @param value Key to use for value
401
665
  * @returns Record of keyed values
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * groupArraysBy(
670
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
671
+ * 'value',
672
+ * 'id',
673
+ * ); // => {
674
+ * // 10: [1, 3],
675
+ * // 20: [2],
676
+ * // }
677
+ * ```
402
678
  */
403
679
  declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ItemValue extends keyof Item>(array: Item[], key: ItemKey, value: ItemValue): Simplify<Record<KeyedValue<Item, ItemKey>, Item[ItemValue][]>>;
404
680
  /**
405
681
  * Create a record from an array of items using a specific key, grouping items into arrays
406
682
  *
407
683
  * Available as `groupArraysBy` and `groupBy.arrays`
684
+ *
408
685
  * @param array Array to group
409
686
  * @param callback Callback to get an item's grouping key
410
687
  * @returns Record of keyed items
688
+ *
689
+ * @example
690
+ * ```typescript
691
+ * groupArraysBy(
692
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
693
+ * item => item.value,
694
+ * ); // => {
695
+ * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
696
+ * // 20: [{id: 2, value: 20}],
697
+ * // }
698
+ * ```
411
699
  */
412
700
  declare function groupArraysBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
413
701
  /**
414
702
  * Create a record from an array of items using a specific key, grouping items into arrays
415
703
  *
416
704
  * Available as `groupArraysBy` and `groupBy.arrays`
705
+ *
417
706
  * @param array Array to group
418
707
  * @param key Key to use for grouping
419
708
  * @returns Record of keyed items
709
+ *
710
+ * @example
711
+ * ```typescript
712
+ * groupArraysBy(
713
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
714
+ * 'value',
715
+ * ); // => {
716
+ * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
717
+ * // 20: [{id: 2, value: 20}],
718
+ * // }
719
+ * ```
420
720
  */
421
721
  declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
422
722
  //#endregion
423
723
  //#region src/internal/array/chunk.d.ts
424
724
  /**
425
725
  * Chunk an array into smaller arrays
726
+ *
426
727
  * @param array Array to chunk
427
728
  * @param size Size of each chunk _(minimum is `1`, maximum is `5000`; defaults to `5000`)_
428
729
  * @returns Array of arrays
730
+ *
731
+ * @example
732
+ * ```typescript
733
+ * chunk([1, 2, 3, 4, 5], 2); // => [[1, 2], [3, 4], [5]]
734
+ * ```
429
735
  */
430
736
  declare function chunk<Item>(array: Item[], size?: number): Item[][];
431
737
  //#endregion
432
738
  //#region src/internal/array/compact.d.ts
433
739
  /**
434
740
  * Compact an array _(removing all false-y values)_
741
+ *
435
742
  * @param array Array to compact
436
743
  * @param strict True to remove all false-y values
437
744
  * @returns Compacted array
745
+ *
746
+ * @example
747
+ * ```typescript
748
+ * compact([0, 1, '', 'hello', false, true, null, undefined]); // => [1, 'hello', true]
749
+ * ```
438
750
  */
439
751
  declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | '' | false | null | undefined>[];
440
752
  /**
441
753
  * Compact an array _(removing all `null` and `undefined` values)_
754
+ *
442
755
  * @param array Array to compact
443
756
  * @returns Compacted array
757
+ *
758
+ * @example
759
+ * ```typescript
760
+ * compact([0, 1, '', 'hello', false, true, null, undefined]); // => [0, 1, '', 'hello', false, true]
761
+ * ```
444
762
  */
445
763
  declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined>[];
446
764
  //#endregion
447
765
  //#region src/internal/array/index-of.d.ts
448
766
  /**
449
767
  * Get the index of the first matching item by callback
768
+ *
450
769
  * @param array Array to search in
451
770
  * @param callback Callback to get an item's value
452
771
  * @param value Value to match against
453
772
  * @returns Index of the first matching item, or `-1` if no match is found
773
+ *
774
+ * @example
775
+ * ```typescript
776
+ * indexOf(
777
+ * [{id: 1}, {id: 2}, {id: 3}],
778
+ * item => item.id,
779
+ * 2,
780
+ * ); // => 1
781
+ * ```
454
782
  */
455
783
  declare function indexOf<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): number;
456
784
  /**
457
785
  * Get the index of the first matching item by key
786
+ *
458
787
  * @param array Array to search in
459
788
  * @param key Key to match items by
460
789
  * @param value Value to match against
461
790
  * @returns Index of the first matching item, or `-1` if no match is found
791
+ *
792
+ * @example
793
+ * ```typescript
794
+ * indexOf(
795
+ * [{id: 1}, {id: 2}, {id: 3}],
796
+ * 'id',
797
+ * 2,
798
+ * ); // => 1
799
+ * ```
462
800
  */
463
801
  declare function indexOf<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
464
802
  /**
465
803
  * Get the index of the first item matching the filter
804
+ *
466
805
  * @param array Array to search in
467
806
  * @param filter Filter callback to match items
468
807
  * @returns Index of the first matching item, or `-1` if no match is found
808
+ *
809
+ * @example
810
+ * ```typescript
811
+ * indexOf(
812
+ * [{id: 1}, {id: 2}, {id: 3}],
813
+ * item => item.id === 2,
814
+ * ); // => 1
815
+ * ```
469
816
  */
470
817
  declare function indexOf<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): number;
471
818
  /**
472
819
  * Get the index of the first item matching the given item
820
+ *
473
821
  * @param array Array to search in
474
822
  * @param item Item to match against
475
823
  * @returns Index of the first matching item, or `-1` if no match is found
824
+ *
825
+ * @example
826
+ * ```typescript
827
+ * indexOf([1, 2, 3, 4, 5], 3); // => 2
828
+ * ```
476
829
  */
477
830
  declare function indexOf<Item>(array: Item[], item: Item): number;
478
831
  declare namespace indexOf {
@@ -482,38 +835,73 @@ declare namespace indexOf {
482
835
  * Get the index of the last matching item by callback
483
836
  *
484
837
  * Available as `lastIndexOf` and `indexOf.last`
838
+ *
485
839
  * @param array Array to search in
486
840
  * @param callback Callback to get an item's value
487
841
  * @param value Value to match against
488
842
  * @returns Index of the last matching item, or `-1` if no match is found
843
+ *
844
+ * @example
845
+ * ```typescript
846
+ * lastIndexOf(
847
+ * [{id: 1}, {id: 2}, {id: 3}, {id: 2}],
848
+ * item => item.id,
849
+ * 2,
850
+ * ); // => 3
851
+ * ```
489
852
  */
490
853
  declare function lastIndexOf<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): number;
491
854
  /**
492
855
  * Get the index of the last matching item by key
493
856
  *
494
857
  * Available as `lastIndexOf` and `indexOf.last`
858
+ *
495
859
  * @param array Array to search in
496
860
  * @param key Key to match items by
497
861
  * @param value Value to match against
498
862
  * @returns Index of the last matching item, or `-1` if no match is found
863
+ *
864
+ * @example
865
+ * ```typescript
866
+ * lastIndexOf(
867
+ * [{id: 1}, {id: 2}, {id: 3}, {id: 2}],
868
+ * 'id',
869
+ * 2,
870
+ * ); // => 3
871
+ * ```
499
872
  */
500
873
  declare function lastIndexOf<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
501
874
  /**
502
875
  * Get the index of the last item matching the filter
503
876
  *
504
877
  * Available as `lastIndexOf` and `indexOf.last`
878
+ *
505
879
  * @param array Array to search in
506
880
  * @param filter Filter callback to match items
507
881
  * @returns Index of the last matching item, or `-1` if no match is found
882
+ *
883
+ * @example
884
+ * ```typescript
885
+ * lastIndexOf(
886
+ * [{id: 1}, {id: 2}, {id: 3}, {id: 2}],
887
+ * item => item.id === 2,
888
+ * ); // => 3
889
+ * ```
508
890
  */
509
891
  declare function lastIndexOf<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): number;
510
892
  /**
511
893
  * Get the index of the last item matching the given item
512
894
  *
513
895
  * Available as `lastIndexOf` and `indexOf.last`
896
+ *
514
897
  * @param array Array to search in
515
898
  * @param item Item to match against
516
899
  * @returns Index of the last matching item, or `-1` if no match is found
900
+ *
901
+ * @example
902
+ * ```typescript
903
+ * lastIndexOf([1, 2, 3, 2, 1], 2); // => 3
904
+ * ```
517
905
  */
518
906
  declare function lastIndexOf<Item>(array: Item[], item: Item): number;
519
907
  //#endregion
@@ -528,89 +916,188 @@ declare function shuffle<Item>(array: Item[]): Item[];
528
916
  //#region src/array/difference.d.ts
529
917
  /**
530
918
  * Get the items from the first array that are not in the second array
919
+ *
531
920
  * @param first First array
532
921
  * @param second Second array
533
922
  * @param callback Callback to get an item's value for comparison
534
923
  * @returns Unique values from the first array
924
+ *
925
+ * @example
926
+ * ```typescript
927
+ * difference(
928
+ * [{id: 1}, {id: 2}, {id: 3}],
929
+ * [{id: 2}, {id: 4}],
930
+ * item => item.id,
931
+ * ); // => [{id: 1}, {id: 3}]
932
+ * ```
535
933
  */
536
934
  declare function difference<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
537
935
  /**
538
936
  * Get the items from the first array that are not in the second array
937
+ *
539
938
  * @param first First array
540
939
  * @param second Second array
541
940
  * @param key Key to get an item's value for comparison
542
941
  * @returns Unique values from the first array
942
+ *
943
+ * @example
944
+ * ```typescript
945
+ * difference(
946
+ * [{id: 1}, {id: 2}, {id: 3}],
947
+ * [{id: 2}, {id: 4}],
948
+ * 'id',
949
+ * ); // => [{id: 1}, {id: 3}]
950
+ * ```
543
951
  */
544
952
  declare function difference<First extends PlainObject, Second extends PlainObject, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
545
953
  /**
546
954
  * Get the items from the first array that are not in the second array
955
+ *
547
956
  * @param first First array
548
957
  * @param second Second array
549
958
  * @returns Unique values from the first array
959
+ *
960
+ * @example
961
+ * ```typescript
962
+ * difference(
963
+ * [1, 2, 3],
964
+ * [2, 4],
965
+ * ); // => [1, 3]
966
+ * ```
550
967
  */
551
968
  declare function difference<First, Second>(first: First[], second: Second[]): First[];
552
969
  //#endregion
553
970
  //#region src/array/exists.d.ts
554
971
  /**
555
972
  * Does an item with a specific value exist in the array?
973
+ *
556
974
  * @param array Array to search in
557
975
  * @param callback Callback to get an item's value for matching
558
976
  * @param value Value to match against
559
977
  * @returns `true` if the item exists in the array, otherwise `false`
978
+ *
979
+ * @example
980
+ * ```typescript
981
+ * exists(
982
+ * [{id: 1}, {id: 2}, {id: 3}],
983
+ * item => item.id,
984
+ * 2,
985
+ * ); // => true
986
+ * ```
560
987
  */
561
988
  declare function exists<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): boolean;
562
989
  /**
563
990
  * Does an item with a specific value exist in the array?
991
+ *
564
992
  * @param array Array to search in
565
993
  * @param key Key to get an item's value for matching
566
994
  * @param value Value to match against
567
995
  * @returns `true` if the item exists in the array, otherwise `false`
996
+ *
997
+ * @example
998
+ * ```typescript
999
+ * exists(
1000
+ * [{id: 1}, {id: 2}, {id: 3}],
1001
+ * 'id',
1002
+ * 2,
1003
+ * ); // => true
1004
+ * ```
568
1005
  */
569
1006
  declare function exists<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): boolean;
570
1007
  /**
571
1008
  * Does an item in the array match the filter?
1009
+ *
572
1010
  * @param array Array to search in
573
1011
  * @param filter Filter callback to match items
574
1012
  * @returns `true` if a matching item exists, otherwise `false`
1013
+ *
1014
+ * @example
1015
+ * ```typescript
1016
+ * exists(
1017
+ * [{id: 1}, {id: 2}, {id: 3}],
1018
+ * item => item.id === 2,
1019
+ * ); // => true
1020
+ * ```
575
1021
  */
576
1022
  declare function exists<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): boolean;
577
1023
  /**
578
1024
  * Does the item exist in the array?
1025
+ *
579
1026
  * @param array Array to search in
580
1027
  * @param item Item to search for
581
1028
  * @returns `true` if the item exists in the array, otherwise `false`
1029
+ *
1030
+ * @example
1031
+ * ```typescript
1032
+ * exists([1, 2, 3], 2); // => true
1033
+ * ```
582
1034
  */
583
1035
  declare function exists<Item>(array: Item[], item: Item): boolean;
584
1036
  //#endregion
585
1037
  //#region src/array/find.d.ts
586
1038
  /**
587
1039
  * Get the first item matching the given value
1040
+ *
588
1041
  * @param array Array to search in
589
1042
  * @param callback Callback to get an item's value for matching
590
1043
  * @param value Value to match against
591
1044
  * @returns First item that matches the value, or `undefined` if no match is found
1045
+ *
1046
+ * @example
1047
+ * ```typescript
1048
+ * find(
1049
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1050
+ * item => item.value,
1051
+ * 10,
1052
+ * ); // => {id: 1, value: 10}
1053
+ * ```
592
1054
  */
593
1055
  declare function find<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
594
1056
  /**
595
1057
  * Get the first item matching the given value by key
1058
+ *
596
1059
  * @param array Array to search in
597
1060
  * @param key Key to get an item's value for matching
598
1061
  * @param value Value to match against
599
1062
  * @returns First item that matches the value, or `undefined` if no match is found
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * find(
1067
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1068
+ * 'value',
1069
+ * 10,
1070
+ * ); // => {id: 1, value: 10}
1071
+ * ```
600
1072
  */
601
1073
  declare function find<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
602
1074
  /**
603
1075
  * Get the first item matching the filter
1076
+ *
604
1077
  * @param array Array to search in
605
1078
  * @param filter Filter callback to match items
606
1079
  * @returns First item that matches the filter, or `undefined` if no match is found
1080
+ *
1081
+ * @example
1082
+ * ```typescript
1083
+ * find(
1084
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1085
+ * item => item.value === 10,
1086
+ * ); // => {id: 1, value: 10}
1087
+ * ```
607
1088
  */
608
1089
  declare function find<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
609
1090
  /**
610
1091
  * Get the first item matching the given value
1092
+ *
611
1093
  * @param array Array to search in
612
1094
  * @param value Value to match against
613
1095
  * @returns First item that matches the value, or `undefined` if no match is found
1096
+ *
1097
+ * @example
1098
+ * ```typescript
1099
+ * find([1, 2, 3, 2, 1], 1); // => 1
1100
+ * ```
614
1101
  */
615
1102
  declare function find<Item>(array: Item[], value: Item): Item | undefined;
616
1103
  declare namespace find {
@@ -620,328 +1107,634 @@ declare namespace find {
620
1107
  * Get the last item matching the given value
621
1108
  *
622
1109
  * Available as `findLast` and `find.last`
1110
+ *
623
1111
  * @param array Array to search in
624
1112
  * @param callback Callback to get an item's value for matching
625
1113
  * @param value Value to match against
626
1114
  * @returns Last item that matches the value, or `undefined` if no match is found
1115
+ *
1116
+ * @example
1117
+ * ```typescript
1118
+ * findLast(
1119
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1120
+ * item => item.value,
1121
+ * 10,
1122
+ * ); // => {id: 3, value: 10}
1123
+ * ```
627
1124
  */
628
1125
  declare function findLast<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
629
1126
  /**
630
1127
  * Get the last item matching the given value by key
631
1128
  *
632
1129
  * Available as `findLast` and `find.last`
1130
+ *
633
1131
  * @param array Array to search in
634
1132
  * @param key Key to get an item's value for matching
635
1133
  * @param value Value to match against
636
1134
  * @returns Last item that matches the value, or `undefined` if no match is found
1135
+ *
1136
+ * @example
1137
+ * ```typescript
1138
+ * findLast(
1139
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1140
+ * 'value',
1141
+ * 10,
1142
+ * ); // => {id: 3, value: 10}
1143
+ * ```
637
1144
  */
638
1145
  declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
639
1146
  /**
640
1147
  * Get the last item matching the filter
641
1148
  *
642
1149
  * Available as `findLast` and `find.last`
1150
+ *
643
1151
  * @param array Array to search in
644
1152
  * @param filter Filter callback to match items
645
1153
  * @returns Last item that matches the filter, or `undefined` if no match is found
1154
+ *
1155
+ * @example
1156
+ * ```typescript
1157
+ * findLast(
1158
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
1159
+ * item => item.value === 10,
1160
+ * ); // => {id: 3, value: 10}
1161
+ * ```
646
1162
  */
647
1163
  declare function findLast<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
648
1164
  /**
649
1165
  * Get the last item matching the given value
650
1166
  *
651
1167
  * Available as `findLast` and `find.last`
1168
+ *
652
1169
  * @param array Array to search in
653
1170
  * @param value Value to match against
654
1171
  * @returns Last item that matches the value, or `undefined` if no match is found
1172
+ *
1173
+ * @example
1174
+ * ```typescript
1175
+ * findLast([1, 2, 3, 2, 1], 1); // => 1
1176
+ * ```
655
1177
  */
656
1178
  declare function findLast<Item>(array: Item[], value: Item): Item | undefined;
657
1179
  //#endregion
658
1180
  //#region src/array/flatten.d.ts
659
1181
  /**
660
1182
  * Flatten an array _(using native `flat` and maximum depth)_
1183
+ *
661
1184
  * @param array Array to flatten
662
1185
  * @returns Flattened array
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
1190
+ * ```
663
1191
  */
664
1192
  declare function flatten<Item>(array: Item[]): NestedArray<Item>[];
665
1193
  //#endregion
666
1194
  //#region src/array/from.d.ts
667
1195
  /**
668
1196
  * Get an array with a specified length, filled with indices
1197
+ *
669
1198
  * @param length Length of the array
670
1199
  * @returns Array of indices
1200
+ *
1201
+ * @example
1202
+ * ```typescript
1203
+ * range(5); // => [0, 1, 2, 3, 4]
1204
+ * ```
671
1205
  */
672
1206
  declare function range(length: number): number[];
673
1207
  /**
674
1208
  * Get an array of numbers in a specified range
1209
+ *
675
1210
  * @param start Starting number _(inclusive)_
676
1211
  * @param end Ending number _(exclusive)_
677
1212
  * @returns Array of numbers in range
1213
+ *
1214
+ * @example
1215
+ * ```typescript
1216
+ * range(2, 5); // => [2, 3, 4]
1217
+ * ```
678
1218
  */
679
1219
  declare function range(start: number, end: number): number[];
680
1220
  /**
681
1221
  * Get an array of numbers in a specified range with a specified step
1222
+ *
682
1223
  * @param start Starting number _(inclusive)_
683
1224
  * @param end Ending number _(exclusive)_
684
1225
  * @param step Step between numbers
685
1226
  * @returns Array of numbers in range
1227
+ *
1228
+ * @example
1229
+ * ```typescript
1230
+ * range(0, 10, 2); // => [0, 2, 4, 6, 8]
1231
+ * ```
686
1232
  */
687
1233
  declare function range(start: number, end: number, step: number): number[];
688
1234
  /**
689
1235
  * Get an array with a specified length, filled with indices
1236
+ *
690
1237
  * @param length Length of the array
691
1238
  * @returns Array of indices
1239
+ *
1240
+ * @example
1241
+ * ```typescript
1242
+ * times(5); // => [0, 1, 2, 3, 4]
1243
+ * ```
692
1244
  */
693
1245
  declare function times(length: number): number[];
694
1246
  /**
695
1247
  * Get an array with a specified length, filled by values from a callback
1248
+ *
696
1249
  * @param length Length of the array
697
1250
  * @param callback Callback function to generate values
698
1251
  * @returns Array of values generated by the callback
1252
+ *
1253
+ * @example
1254
+ * ```typescript
1255
+ * times(5, index => index * 2); // => [0, 2, 4, 6, 8]
1256
+ * ```
699
1257
  */
700
1258
  declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): ReturnType<Callback>[];
701
1259
  /**
702
1260
  * Get an array with a specified length, filled with a specified value
1261
+ *
703
1262
  * @param length Length of the array
704
1263
  * @param value Value to fill the array with
705
1264
  * @returns Array filled with the specified value
1265
+ *
1266
+ * @example
1267
+ * ```typescript
1268
+ * times(5, 'a'); // => ['a', 'a', 'a', 'a', 'a']
1269
+ * ```
706
1270
  */
707
1271
  declare function times<Value>(length: number, value: Value): Value[];
708
1272
  //#endregion
709
1273
  //#region src/array/get.d.ts
710
1274
  /**
711
1275
  * Get an array from an object, where only values with numerical keys will be included
1276
+ *
712
1277
  * @param value Object to convert to an array
713
1278
  * @returns Array holding the values of the object's numerical keys
1279
+ *
1280
+ * @example
1281
+ * ```typescript
1282
+ * getArray({0: 'a', 1: 'b', 2: 'c', d: 'd'}, true); // => ['a', 'b', 'c']
1283
+ * getArray({a: 'a', b: 'b', c: 'c', d: 'd'}, true); // => []
1284
+ * ```
714
1285
  */
715
1286
  declare function getArray<Value extends PlainObject>(value: Value, indiced: true): Value[NumericalKeys<Value>][];
716
1287
  /**
717
1288
  * Get an array from an object
1289
+ *
718
1290
  * @param value Object to convert to an array
719
1291
  * @returns Array holding the values of the object
1292
+ *
1293
+ * @example
1294
+ * ```typescript
1295
+ * getArray({0: 'a', 1: 'b', 2: 'c', d: 'd'}); // => ['a', 'b', 'c', 'd']
1296
+ * getArray({a: 'a', b: 'b', c: 'c', d: 'd'}); // => ['a', 'b', 'c', 'd']
1297
+ * ```
720
1298
  */
721
1299
  declare function getArray<Value extends PlainObject>(value: Value): Value[keyof Value][];
722
1300
  /**
723
- * Get an array
1301
+ * Get an array from a value
1302
+ *
724
1303
  * @param value Original array
725
1304
  * @returns Original array
1305
+ *
1306
+ * @example
1307
+ * ```typescript
1308
+ * getArray(123); // => [123]
1309
+ * ```
726
1310
  */
727
1311
  declare function getArray<Item>(value: Item[]): Item[];
728
- /**
729
- * Get an array from a value
730
- * @param value Value to convert to an array
731
- * @returns Array holding the value
732
- */
733
- declare function getArray<Item>(value: Item): Item[];
734
- /**
735
- * Get an array from an unknown value
736
- * @param value Value to convert to an array
737
- * @returns Array of value
738
- */
739
- declare function getArray(value: unknown): unknown[];
740
1312
  //#endregion
741
1313
  //#region src/array/insert.d.ts
742
1314
  /**
743
1315
  * Insert items into an array at a specified index
1316
+ *
1317
+ * _(Uses chunking to avoid call stack size being exceeded)_
1318
+ *
744
1319
  * @param array Original array
745
1320
  * @param index Index to insert at
746
1321
  * @param items Inserted items
747
1322
  * @returns Updated array
1323
+ *
1324
+ * @example
1325
+ * ```typescript
1326
+ * insert([1, 2, 3], 1, [4, 5]); // => [1, 4, 5, 2, 3]
1327
+ * ```
748
1328
  */
749
1329
  declare function insert<Item>(array: Item[], index: number, items: Item[]): Item[];
750
1330
  /**
751
1331
  * Insert items into an array _(at the end)_
1332
+ *
1333
+ * _(Uses chunking to avoid call stack size being exceeded)_
1334
+ *
752
1335
  * @param array Original array
753
1336
  * @param items Inserted items
754
1337
  * @returns Updated array
1338
+ *
1339
+ * @example
1340
+ * ```typescript
1341
+ * insert([1, 2, 3], [4, 5]); // => [1, 2, 3, 4, 5]
1342
+ * ```
755
1343
  */
756
1344
  declare function insert<Item>(array: Item[], items: Item[]): Item[];
757
1345
  //#endregion
758
1346
  //#region src/array/intersection.d.ts
759
1347
  /**
760
1348
  * Get the common values between two arrays
1349
+ *
761
1350
  * @param first First array
762
1351
  * @param second Second array
763
1352
  * @param callback Callback to get an item's value for comparison
764
1353
  * @returns Common values from both arrays
1354
+ *
1355
+ * @example
1356
+ * ```typescript
1357
+ * intersection(
1358
+ * [{id: 1}, {id: 2}, {id: 3}],
1359
+ * [{id: 2}, {id: 3}, {id: 4}],
1360
+ * item => item.id,
1361
+ * ); // => [{id: 2}, {id: 3}]
1362
+ * ```
765
1363
  */
766
1364
  declare function intersection<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): First[];
767
1365
  /**
768
1366
  * Get the common values between two arrays
1367
+ *
769
1368
  * @param first First array
770
1369
  * @param second Second array
771
1370
  * @param key Key to get an item's value for comparison
772
1371
  * @returns Common values from both arrays
1372
+ *
1373
+ * @example
1374
+ * ```typescript
1375
+ * intersection(
1376
+ * [{id: 1}, {id: 2}, {id: 3}],
1377
+ * [{id: 2}, {id: 3}, {id: 4}],
1378
+ * 'id',
1379
+ * ); // => [{id: 2}, {id: 3}]
1380
+ * ```
773
1381
  */
774
1382
  declare function intersection<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): First[];
775
1383
  /**
776
1384
  * Get the common values between two arrays
1385
+ *
777
1386
  * @param first First array
778
1387
  * @param second Second array
779
1388
  * @returns Common values from both arrays
1389
+ *
1390
+ * @example
1391
+ * ```typescript
1392
+ * intersection(
1393
+ * [1, 2, 3],
1394
+ * [2, 3, 4],
1395
+ * ); // => [2, 3]
1396
+ * ```
780
1397
  */
781
1398
  declare function intersection<First, Second>(first: First[], second: Second[]): First[];
782
1399
  //#endregion
783
1400
  //#region src/array/partition.d.ts
784
1401
  /**
785
1402
  * Get a partitioned array of items
1403
+ *
786
1404
  * @param array Array to search in
787
1405
  * @param callback Callback to get an item's value for matching
788
1406
  * @param value Value to match against
789
1407
  * @returns Partitioned array of items
1408
+ *
1409
+ * @example
1410
+ * ```typescript
1411
+ * partition(
1412
+ * [{id: 1}, {id: 2}, {id: 3}],
1413
+ * item => item.id,
1414
+ * 2,
1415
+ * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1416
+ * ```
790
1417
  */
791
1418
  declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[][];
792
1419
  /**
793
1420
  * Get a partitioned array of items
1421
+ *
794
1422
  * @param array Array to search in
795
1423
  * @param key Key to get an item's value for matching
796
1424
  * @param value Value to match against
797
1425
  * @returns Partitioned array of items
1426
+ *
1427
+ * @example
1428
+ * ```typescript
1429
+ * partition(
1430
+ * [{id: 1}, {id: 2}, {id: 3}],
1431
+ * 'id',
1432
+ * 2,
1433
+ * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1434
+ * ```
798
1435
  */
799
1436
  declare function partition<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[][];
800
1437
  /**
801
1438
  * Get a partitioned array of items
1439
+ *
802
1440
  * @param array Array to search in
803
1441
  * @param filter Filter callback to match items
804
1442
  * @returns Partitioned array of items
1443
+ *
1444
+ * @example
1445
+ * ```typescript
1446
+ * partition(
1447
+ * [{id: 1}, {id: 2}, {id: 3}],
1448
+ * item => item.id === 2,
1449
+ * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1450
+ * ```
805
1451
  */
806
1452
  declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[][];
807
1453
  /**
808
1454
  * Get a partitioned array of items matching the given item
1455
+ *
809
1456
  * @param array Array to search in
810
1457
  * @param item Item to match against
811
1458
  * @returns Partitioned array of items
1459
+ *
1460
+ * @example
1461
+ * ```typescript
1462
+ * partition([1, 2, 3, 4, 5], 3); // => [[3], [1, 2, 4, 5]]
1463
+ * ```
812
1464
  */
813
1465
  declare function partition<Item>(array: Item[], item: Item): Item[][];
814
1466
  //#endregion
815
- //#region src/array/position.d.ts
816
- type ArrayPosition = 'end' | 'inside' | 'invalid' | 'outside' | 'same' | 'start';
1467
+ //#region src/array/match.d.ts
1468
+ /**
1469
+ * Comparison of an array within another array
1470
+ */
1471
+ type ArrayComparison = 'end' | 'inside' | 'invalid' | 'outside' | 'same' | 'start';
817
1472
  /**
818
1473
  * Does the needle array end the haystack array?
819
1474
  * @param haystack Haystack array
820
1475
  * @param needle Needle array
821
- * @param key Key to get an item's value for matching
822
- * @return `true` if the haystack ends with the needle, otherwise `false`
1476
+ * @param callback Callback to get an item's value for matching
1477
+ * @returns `true` if the haystack ends with the needle, otherwise `false`
1478
+ *
1479
+ * @example
1480
+ * ```typescript
1481
+ * endsWithArray(
1482
+ * [{id: 1}, {id: 2}, {id: 3}],
1483
+ * [{id: 2}, {id: 3}],
1484
+ * item => item.id,
1485
+ * ); // => true
1486
+ * ```
823
1487
  */
824
- declare function endsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
1488
+ declare function endsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
825
1489
  /**
826
1490
  * Does the needle array end the haystack array?
1491
+ *
827
1492
  * @param haystack Haystack array
828
1493
  * @param needle Needle array
829
- * @param callback Callback to get an item's value for matching
830
- * @return `true` if the haystack ends with the needle, otherwise `false`
1494
+ * @param key Key to get an item's value for matching
1495
+ * @returns `true` if the haystack ends with the needle, otherwise `false`
1496
+ *
1497
+ * @example
1498
+ * ```typescript
1499
+ * endsWithArray(
1500
+ * [{id: 1}, {id: 2}, {id: 3}],
1501
+ * [{id: 2}, {id: 3}],
1502
+ * 'id',
1503
+ * ); // => true
1504
+ * ```
831
1505
  */
832
- declare function endsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
1506
+ declare function endsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
833
1507
  /**
834
1508
  * Does the needle array end the haystack array?
1509
+ *
835
1510
  * @param haystack Haystack array
836
1511
  * @param needle Needle array
837
- * @return `true` if the haystack ends with the needle, otherwise `false`
1512
+ * @returns `true` if the haystack ends with the needle, otherwise `false`
1513
+ *
1514
+ * @example
1515
+ * ```typescript
1516
+ * endsWithArray([1, 2, 3], [2, 3]); // => true
1517
+ * ```
838
1518
  */
839
1519
  declare function endsWithArray<Item>(haystack: Item[], needle: Item[]): boolean;
840
1520
  /**
841
1521
  * Get the position of an array within another array
1522
+ *
842
1523
  * @param haystack Haystack array
843
1524
  * @param needle Needle array
844
- * @param key Key to get an item's value for matching
1525
+ * @param callback Callback to get an item's value for matching
845
1526
  * @returns Position of the needle within the haystack
1527
+ *
1528
+ * @example
1529
+ * ```typescript
1530
+ * getArrayComparison(
1531
+ * [{id: 1}, {id: 2}, {id: 3}],
1532
+ * [{id: 2}, {id: 3}],
1533
+ * item => item.id,
1534
+ * ); // => 'end'
1535
+ * ```
846
1536
  */
847
- declare function getArrayPosition<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): ArrayPosition;
1537
+ declare function getArrayComparison<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): ArrayComparison;
848
1538
  /**
849
1539
  * Get the position of an array within another array
1540
+ *
850
1541
  * @param haystack Haystack array
851
1542
  * @param needle Needle array
852
- * @param callback Callback to get an item's value for matching
1543
+ * @param key Key to get an item's value for matching
853
1544
  * @returns Position of the needle within the haystack
1545
+ *
1546
+ * @example
1547
+ * ```typescript
1548
+ * getArrayComparison(
1549
+ * [{id: 1}, {id: 2}, {id: 3}],
1550
+ * [{id: 2}, {id: 3}],
1551
+ * 'id',
1552
+ * ); // => 'end'
1553
+ * ```
854
1554
  */
855
- declare function getArrayPosition<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): ArrayPosition;
1555
+ declare function getArrayComparison<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): ArrayComparison;
856
1556
  /**
857
1557
  * Get the position of an array within another array
1558
+ *
858
1559
  * @param haystack Haystack array
859
1560
  * @param needle Needle array
860
1561
  * @returns Position of the needle within the haystack
1562
+ *
1563
+ * @example
1564
+ * ```typescript
1565
+ * getArrayComparison([1, 2, 3], [2, 3]); // => 'end'
1566
+ * ```
861
1567
  */
862
- declare function getArrayPosition<Item>(haystack: Item[], needle: Item[]): ArrayPosition;
1568
+ declare function getArrayComparison<Item>(haystack: Item[], needle: Item[]): ArrayComparison;
863
1569
  /**
864
1570
  * Does the needle array exist within the haystack array?
1571
+ *
865
1572
  * @param haystack Haystack array
866
1573
  * @param needle Needle array
867
- * @param key Key to get an item's value for matching
868
- * @return `true` if the haystack includes the needle, otherwise `false`
1574
+ * @param callback Callback to get an item's value for matching
1575
+ * @returns `true` if the haystack includes the needle, otherwise `false`
1576
+ *
1577
+ * @example
1578
+ * ```typescript
1579
+ * includesArray(
1580
+ * [{id: 1}, {id: 2}, {id: 3}],
1581
+ * [{id: 2}, {id: 3}],
1582
+ * item => item.id,
1583
+ * ); // => true
1584
+ * ```
869
1585
  */
870
- declare function includesArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
1586
+ declare function includesArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
871
1587
  /**
872
1588
  * Does the needle array exist within the haystack array?
1589
+ *
873
1590
  * @param haystack Haystack array
874
1591
  * @param needle Needle array
875
- * @param callback Callback to get an item's value for matching
876
- * @return `true` if the haystack includes the needle, otherwise `false`
1592
+ * @param key Key to get an item's value for matching
1593
+ * @returns `true` if the haystack includes the needle, otherwise `false`
1594
+ *
1595
+ * @example
1596
+ * ```typescript
1597
+ * includesArray(
1598
+ * [{id: 1}, {id: 2}, {id: 3}],
1599
+ * [{id: 2}, {id: 3}],
1600
+ * 'id',
1601
+ * ); // => true
1602
+ * ```
877
1603
  */
878
- declare function includesArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
1604
+ declare function includesArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
879
1605
  /**
880
1606
  * Does the needle array exist within the haystack array?
1607
+ *
881
1608
  * @param haystack Haystack array
882
1609
  * @param needle Needle array
883
- * @return `true` if the haystack includes the needle, otherwise `false`
1610
+ * @returns `true` if the haystack includes the needle, otherwise `false`
1611
+ *
1612
+ * @example
1613
+ * ```typescript
1614
+ * includesArray([1, 2, 3], [2, 3]); // => true
1615
+ * ```
884
1616
  */
885
1617
  declare function includesArray<Item>(haystack: Item[], needle: Item[]): boolean;
886
1618
  /**
887
1619
  * Get the index of an array within another array
1620
+ *
888
1621
  * @param haystack Haystack array
889
1622
  * @param needle Needle array
890
- * @param key Key to get an item's value for matching
891
- * @return Index of the needle's start within the haystack, or `-1` if it is not found
1623
+ * @param callback Callback to get an item's value for matching
1624
+ * @returns Index of the needle's start within the haystack, or `-1` if it is not found
1625
+ *
1626
+ * @example
1627
+ * ```typescript
1628
+ * indexOfArray(
1629
+ * [{id: 1}, {id: 2}, {id: 3}],
1630
+ * [{id: 2}, {id: 3}],
1631
+ * item => item.id,
1632
+ * ); // => 1
1633
+ * ```
892
1634
  */
893
- declare function indexOfArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): number;
1635
+ declare function indexOfArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): number;
894
1636
  /**
895
1637
  * Get the index of an array within another array
1638
+ *
896
1639
  * @param haystack Haystack array
897
1640
  * @param needle Needle array
898
- * @param callback Callback to get an item's value for matching
899
- * @return Index of the needle's start within the haystack, or `-1` if it is not found
1641
+ * @param key Key to get an item's value for matching
1642
+ * @returns Index of the needle's start within the haystack, or `-1` if it is not found
1643
+ *
1644
+ * @example
1645
+ * ```typescript
1646
+ * indexOfArray(
1647
+ * [{id: 1}, {id: 2}, {id: 3}],
1648
+ * [{id: 2}, {id: 3}],
1649
+ * 'id',
1650
+ * ); // => 1
1651
+ * ```
900
1652
  */
901
- declare function indexOfArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): number;
1653
+ declare function indexOfArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): number;
902
1654
  /**
903
1655
  * Get the index of an array within another array
1656
+ *
904
1657
  * @param haystack Haystack array
905
1658
  * @param needle Needle array
906
- * @return Index of the needle's start within the haystack, or `-1` if it is not found
1659
+ * @returns Index of the needle's start within the haystack, or `-1` if it is not found
1660
+ *
1661
+ * @example
1662
+ * ```typescript
1663
+ * indexOfArray([1, 2, 3], [2, 3]); // => 1
1664
+ * ```
907
1665
  */
908
1666
  declare function indexOfArray<Item>(haystack: Item[], needle: Item[]): number;
909
1667
  /**
910
1668
  * Does the needle array start the haystack array?
1669
+ *
911
1670
  * @param haystack Haystack array
912
1671
  * @param needle Needle array
913
- * @param key Key to get an item's value for matching
914
- * @return `true` if the haystack starts with the needle, otherwise `false`
1672
+ * @param callback Callback to get an item's value for matching
1673
+ * @returns `true` if the haystack starts with the needle, otherwise `false`
1674
+ *
1675
+ * @example
1676
+ * ```typescript
1677
+ * startsWithArray(
1678
+ * [{id: 1}, {id: 2}, {id: 3}],
1679
+ * [{id: 1}, {id: 2}],
1680
+ * item => item.id,
1681
+ * ); // => true
1682
+ * ```
915
1683
  */
916
- declare function startsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
1684
+ declare function startsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
917
1685
  /**
918
1686
  * Does the needle array start the haystack array?
1687
+ *
919
1688
  * @param haystack Haystack array
920
1689
  * @param needle Needle array
921
- * @param callback Callback to get an item's value for matching
922
- * @return `true` if the haystack starts with the needle, otherwise `false`
1690
+ * @param key Key to get an item's value for matching
1691
+ * @returns `true` if the haystack starts with the needle, otherwise `false`
1692
+ *
1693
+ * @example
1694
+ * ```typescript
1695
+ * startsWithArray(
1696
+ * [{id: 1}, {id: 2}, {id: 3}],
1697
+ * [{id: 1}, {id: 2}],
1698
+ * 'id',
1699
+ * ); // => true
1700
+ * ```
923
1701
  */
924
- declare function startsWithArray<Item>(haystack: Item[], needle: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): boolean;
1702
+ declare function startsWithArray<Item extends PlainObject>(haystack: Item[], needle: Item[], key: keyof Item): boolean;
925
1703
  /**
926
1704
  * Does the needle array start the haystack array?
1705
+ *
927
1706
  * @param haystack Haystack array
928
1707
  * @param needle Needle array
929
- * @return `true` if the haystack starts with the needle, otherwise `false`
1708
+ * @returns `true` if the haystack starts with the needle, otherwise `false`
1709
+ *
1710
+ * @example
1711
+ * ```typescript
1712
+ * startsWithArray([1, 2, 3], [1, 2]); // => true
1713
+ * ```
930
1714
  */
931
1715
  declare function startsWithArray<Item>(haystack: Item[], needle: Item[]): boolean;
932
1716
  //#endregion
933
1717
  //#region src/array/push.d.ts
934
1718
  /**
935
1719
  * Push items into an array _(at the end)_
1720
+ *
1721
+ * _(Uses chunking to avoid call stack size being exceeded)_
1722
+ *
936
1723
  * @param array Original array
937
1724
  * @param pushed Pushed items
938
1725
  * @returns New length of the array
1726
+ *
1727
+ * @example
1728
+ * ```typescript
1729
+ * push([1, 2, 3], [4, 5]); // => 5 (new length); array becomes [1, 2, 3, 4, 5]
1730
+ * ```
939
1731
  */
940
1732
  declare function push<Item>(array: Item[], pushed: Item[]): number;
941
1733
  //#endregion
942
1734
  //#region src/array/reverse.d.ts
943
1735
  /**
944
1736
  * Reverse the order of items in an array
1737
+ *
945
1738
  * @param array Array to reverse
946
1739
  * @returns Reversed array
947
1740
  */
@@ -950,46 +1743,100 @@ declare function reverse<Item>(array: Item[]): Item[];
950
1743
  //#region src/array/select.d.ts
951
1744
  /**
952
1745
  * Get a filtered and mapped array of items
1746
+ *
953
1747
  * @param array Array to search in
954
1748
  * @param filterCallback Callback to get an item's value for matching
955
1749
  * @param filterValue Value to match against
956
1750
  * @param mapCallback Callback to map the matched items
957
1751
  * @returns Filtered and mapped array of items
1752
+ *
1753
+ * @example
1754
+ * ```typescript
1755
+ * select(
1756
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1757
+ * item => item.id,
1758
+ * 2,
1759
+ * item => item.name,
1760
+ * ); // => ['Bob']
1761
+ * ```
958
1762
  */
959
1763
  declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, mapCallback: MapCallback): Array<ReturnType<MapCallback>>;
960
1764
  /**
961
1765
  * Get a filtered and mapped array of items
1766
+ *
962
1767
  * @param array Array to search in
963
1768
  * @param filterCallback Callback to get an item's value for matching
964
1769
  * @param filterValue Value to match against
965
1770
  * @param mapKey Key to get an item's value for mapping
966
1771
  * @returns Filtered and mapped array of items
1772
+ *
1773
+ * @example
1774
+ * ```typescript
1775
+ * select(
1776
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1777
+ * item => item.id,
1778
+ * 2,
1779
+ * 'name',
1780
+ * ); // => ['Bob']
1781
+ * ```
967
1782
  */
968
1783
  declare function select<Item extends PlainObject, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, MapKey extends keyof Item>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, mapKey: MapKey): Array<Item[MapKey]>;
969
1784
  /**
970
1785
  * Get a filtered and mapped array of items
1786
+ *
971
1787
  * @param array Array to search in
972
1788
  * @param filterKey Key to get an item's value for matching
973
1789
  * @param filterValue Value to match against
974
1790
  * @param mapCallback Callback to map the matched items
975
1791
  * @returns Filtered and mapped array of items
1792
+ *
1793
+ * @example
1794
+ * ```typescript
1795
+ * select(
1796
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1797
+ * 'id',
1798
+ * 2,
1799
+ * item => item.name,
1800
+ * ); // => ['Bob']
1801
+ * ```
976
1802
  */
977
1803
  declare function select<Item extends PlainObject, ItemKey extends keyof Item, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], mapCallback: MapCallback): Array<ReturnType<MapCallback>>;
978
1804
  /**
979
1805
  * Get a filtered and mapped array of items
1806
+ *
980
1807
  * @param array Array to search in
981
1808
  * @param filterKey Key to get an item's value for matching
982
1809
  * @param filterValue Value to match against
983
1810
  * @param mapKey Key to get an item's value for mapping
984
1811
  * @returns Filtered and mapped array of items
1812
+ *
1813
+ * @example
1814
+ * ```typescript
1815
+ * select(
1816
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1817
+ * 'id',
1818
+ * 2,
1819
+ * 'name',
1820
+ * ); // => ['Bob']
1821
+ * ```
985
1822
  */
986
1823
  declare function select<Item extends PlainObject, ItemKey extends keyof Item, MapKey extends keyof Item>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], mapKey: MapKey): Array<Item[MapKey]>;
987
1824
  /**
988
1825
  * Get a filtered and mapped array of items
1826
+ *
989
1827
  * @param array Array to search in
990
1828
  * @param filterCallback Filter callback to match items
991
1829
  * @param mapCallback Callback to map the matched items
992
1830
  * @returns Filtered and mapped array of items
1831
+ *
1832
+ * @example
1833
+ * ```typescript
1834
+ * select(
1835
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1836
+ * item => item.id === 2,
1837
+ * item => item.name,
1838
+ * ); // => ['Bob']
1839
+ * ```
993
1840
  */
994
1841
  declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, mapCallback: MapCallback): Array<ReturnType<MapCallback>>;
995
1842
  /**
@@ -998,336 +1845,717 @@ declare function select<Item, FilterCallback extends (item: Item, index: number,
998
1845
  * @param filterCallback Filter callback to match items
999
1846
  * @param mapKey Key to get an item's value for mapping
1000
1847
  * @returns Filtered and mapped array of items
1848
+ *
1849
+ * @example
1850
+ * ```typescript
1851
+ * select(
1852
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1853
+ * item => item.id,
1854
+ * 2,
1855
+ * 'name'
1856
+ * ); // => ['Bob']
1857
+ * ```
1001
1858
  */
1002
1859
  declare function select<Item extends PlainObject, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, MapKey extends keyof Item>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, mapKey: MapKey): Array<Item[MapKey]>;
1003
1860
  /**
1004
1861
  * Get a filtered and mapped array of items
1862
+ *
1005
1863
  * @param array Array to search in
1006
1864
  * @param filter Filter callback to match items
1007
1865
  * @param map Callback to map the matched items
1008
1866
  * @returns Filtered and mapped array of items
1867
+ *
1868
+ * @example
1869
+ * ```typescript
1870
+ * select(
1871
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1872
+ * item => item.id === 2,
1873
+ * item => item.name,
1874
+ * ); // => ['Bob']
1875
+ * ```
1009
1876
  */
1010
1877
  declare function select<Item, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: MapCallback): Array<ReturnType<MapCallback>>;
1011
1878
  /**
1012
1879
  * Get a filtered and mapped array of items
1880
+ *
1013
1881
  * @param array Array to search in
1014
1882
  * @param filter Filter callback to match items
1015
1883
  * @param map Key to get an item's value for mapping
1016
1884
  * @returns Filtered and mapped array of items
1885
+ *
1886
+ * @example
1887
+ * ```typescript
1888
+ * select(
1889
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1890
+ * item => item.id === 2,
1891
+ * 'name'
1892
+ * ); // => ['Bob']
1893
+ * ```
1017
1894
  */
1018
1895
  declare function select<Item extends PlainObject, MapKey extends keyof Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: MapKey): Array<Item[MapKey]>;
1019
1896
  /**
1020
1897
  * Get a filtered and mapped array of items
1898
+ *
1021
1899
  * @param array Array to search in
1022
1900
  * @param item Item to match against
1023
1901
  * @param map Callback to map the matched items
1024
1902
  * @returns Filtered and mapped array of items
1903
+ *
1904
+ * @example
1905
+ * ```typescript
1906
+ * select(
1907
+ * [1, 2, 3, 2, 1],
1908
+ * 3,
1909
+ * value => value ** 2,
1910
+ * ); // => [9]
1911
+ * ```
1025
1912
  */
1026
1913
  declare function select<Item, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], item: Item, map: MapCallback): Array<ReturnType<MapCallback>>;
1027
- /**
1028
- * Get a filtered and mapped array of items
1029
- * @param array Array to search in
1030
- * @param item Item to match against
1031
- * @param map Key to get an item's value for mapping
1032
- * @returns Filtered and mapped array of items
1033
- */
1034
- declare function select<Item extends PlainObject, MapKey extends keyof Item>(array: Item[], item: Item, map: MapKey): Array<Item[MapKey]>;
1035
1914
  //#endregion
1036
1915
  //#region src/array/single.d.ts
1037
1916
  /**
1038
1917
  * Get the _only_ item matching the given value
1039
1918
  *
1040
1919
  * Throws an error if multiple items match the value
1920
+ *
1041
1921
  * @param array Array to search in
1042
1922
  * @param callback Callback to get an item's value for matching
1043
1923
  * @param value Value to match against
1044
1924
  * @returns Only item that matches the value, or `undefined` if no match is found
1925
+ *
1926
+ * @example
1927
+ * ```typescript
1928
+ * single(
1929
+ * [{id: 1}, {id: 2}, {id: 3}],
1930
+ * item => item.id,
1931
+ * 2
1932
+ * ); // => {id: 2}
1933
+ * ```
1045
1934
  */
1046
1935
  declare function single<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
1047
1936
  /**
1048
1937
  * Get the _only_ item matching the given value by key
1049
1938
  *
1050
1939
  * Throws an error if multiple items match the value
1940
+ *
1051
1941
  * @param array Array to search in
1052
1942
  * @param key Key to get an item's value for matching
1053
1943
  * @param value Value to match against
1054
1944
  * @returns Only item that matches the value, or `undefined` if no match is found
1945
+ *
1946
+ * @example
1947
+ * ```typescript
1948
+ * single(
1949
+ * [{id: 1}, {id: 2}, {id: 3}],
1950
+ * 'id',
1951
+ * 2
1952
+ * ); // => {id: 2}
1953
+ * ```
1055
1954
  */
1056
1955
  declare function single<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
1057
1956
  /**
1058
1957
  * Get the _only_ item matching the filter
1059
1958
  *
1060
1959
  * Throws an error if multiple items match the filter
1960
+ *
1061
1961
  * @param array Array to search in
1062
1962
  * @param filter Filter callback to match items
1063
1963
  * @returns Only item that matches the filter, or `undefined` if no match is found
1964
+ *
1965
+ * @example
1966
+ * ```typescript
1967
+ * single(
1968
+ * [{id: 1}, {id: 2}, {id: 3}],
1969
+ * item => item.id === 2
1970
+ * ); // => {id: 2}
1971
+ * ```
1064
1972
  */
1065
1973
  declare function single<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
1066
1974
  //#endregion
1067
1975
  //#region src/array/slice.d.ts
1068
1976
  /**
1069
1977
  * Drop items from the start of an array until they match a value
1978
+ *
1070
1979
  * @param array Original array
1071
- * @param key Key to get an item's value for matching
1980
+ * @param callback Callback to get an item's value for matching
1072
1981
  * @param value Value to match against
1073
1982
  * @returns New array with items dropped
1983
+ *
1984
+ * @example
1985
+ * ```typescript
1986
+ * drop(
1987
+ * [{id: 1}, {id: 2}, {id: 3}],
1988
+ * item => item.id,
1989
+ * 2,
1990
+ * ); // => [{id: 2}, {id: 3}]
1991
+ * ```
1074
1992
  */
1075
- declare function drop<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
1993
+ declare function drop<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
1076
1994
  /**
1077
1995
  * Drop items from the start of an array until they match a value
1996
+ *
1078
1997
  * @param array Original array
1079
- * @param callback Callback to get an item's value for matching
1998
+ * @param key Key to get an item's value for matching
1080
1999
  * @param value Value to match against
1081
- * @return New array with items dropped
2000
+ * @returns New array with items dropped
2001
+ *
2002
+ * @example
2003
+ * ```typescript
2004
+ * drop(
2005
+ * [{id: 1}, {id: 2}, {id: 3}],
2006
+ * 'id',
2007
+ * 2,
2008
+ * ); // => [{id: 2}, {id: 3}]
2009
+ * ```
1082
2010
  */
1083
- declare function drop<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
2011
+ declare function drop<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
1084
2012
  /**
1085
2013
  * Drop items from the start of an array while they match a filter
2014
+ *
1086
2015
  * @param array Original array
1087
2016
  * @param callback Filter callback to match items
1088
- * @return New array with items dropped
2017
+ * @returns New array with items dropped
2018
+ *
2019
+ * @example
2020
+ * ```typescript
2021
+ * drop(
2022
+ * [{id: 1}, {id: 2}, {id: 3}],
2023
+ * item => item.id === 2,
2024
+ * ); // => [{id: 2}, {id: 3}]
2025
+ * ```
1089
2026
  */
1090
2027
  declare function drop<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
1091
2028
  /**
1092
2029
  * Drop a specified number of items, from the start if `>= 0`, or from the end if `< 0`
2030
+ *
1093
2031
  * @param array Original array
1094
2032
  * @param count Number of items to drop
1095
2033
  * @returns New array with items dropped
2034
+ *
2035
+ * @example
2036
+ * ```typescript
2037
+ * drop([1, 2, 3, 4, 5], 2); // => [3, 4, 5]
2038
+ * drop([1, 2, 3, 4, 5], -2); // => [1, 2, 3]
2039
+ * ```
1096
2040
  */
1097
2041
  declare function drop(array: unknown[], count: number): unknown[];
1098
2042
  /**
1099
2043
  * Slice an array, returning a new array with a specified range of items
2044
+ *
1100
2045
  * @param array Original array
1101
2046
  * @param start Start index _(inclusive)_
1102
2047
  * @param end End index _(exclusive)_
1103
- * @return New array with sliced items
2048
+ * @returns New array with sliced items
2049
+ *
2050
+ * @example
2051
+ * ```typescript
2052
+ * slice([1, 2, 3, 4, 5], 1, 4); // => [2, 3, 4]
2053
+ * ```
1104
2054
  */
1105
2055
  declare function slice<Item>(array: Item[], start: number, end: number): Item[];
1106
2056
  /**
1107
- * Slice an array, returning a new array with a specified number of items
2057
+ * Slice an array, returning a new array with a specified number of items _(from the start)_
2058
+ *
1108
2059
  * @param array Original array
1109
- * @param count Maximum sixe of the new array
1110
- * @return New array with sliced items
2060
+ * @param count Maximum size of the new array
2061
+ * @returns New array with sliced items
2062
+ *
2063
+ * @example
2064
+ * ```typescript
2065
+ * slice([1, 2, 3, 4, 5], 3); // => [1, 2, 3]
2066
+ * ```
1111
2067
  */
1112
2068
  declare function slice<Item>(array: Item[], count: number): Item[];
1113
2069
  /**
1114
2070
  * Slice an array
2071
+ *
1115
2072
  * @param array Array to slice
1116
2073
  * @returns Sliced array
2074
+ *
2075
+ * @example
2076
+ * ```typescript
2077
+ * slice([1, 2, 3]); // => [1, 2, 3]
2078
+ * ```
1117
2079
  */
1118
2080
  declare function slice<Item>(array: Item[]): Item[];
1119
2081
  /**
1120
2082
  * Take items from the start of an array until they match a value
2083
+ *
1121
2084
  * @param array Original array
1122
- * @param key Key to get an item's value for matching
2085
+ * @param callback Callback to get an item's value for matching
1123
2086
  * @param value Value to match against
1124
2087
  * @returns New array with taken items
2088
+ *
2089
+ * @example
2090
+ * ```typescript
2091
+ * take(
2092
+ * [{id: 1}, {id: 2}, {id: 3}],
2093
+ * item => item.id,
2094
+ * 2,
2095
+ * ); // => [{id: 1}]
2096
+ * ```
1125
2097
  */
1126
- declare function take<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
2098
+ declare function take<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
1127
2099
  /**
1128
2100
  * Take items from the start of an array until they match a value
2101
+ *
1129
2102
  * @param array Original array
1130
- * @param callback Callback to get an item's value for matching
2103
+ * @param key Key to get an item's value for matching
1131
2104
  * @param value Value to match against
1132
- * @return New array with taken items
2105
+ * @returns New array with taken items
2106
+ *
2107
+ * @example
2108
+ * ```typescript
2109
+ * take(
2110
+ * [{id: 1}, {id: 2}, {id: 3}],
2111
+ * 'id',
2112
+ * 2,
2113
+ * ); // => [{id: 1}]
2114
+ * ```
1133
2115
  */
1134
- declare function take<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
2116
+ declare function take<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
1135
2117
  /**
1136
2118
  * Take items from the start of an array while they match a filter
2119
+ *
1137
2120
  * @param array Original array
1138
2121
  * @param callback Filter callback to match items
1139
- * @return New array with taken items
2122
+ * @returns New array with taken items
2123
+ *
2124
+ * @example
2125
+ * ```typescript
2126
+ * take(
2127
+ * [{id: 1}, {id: 2}, {id: 3}],
2128
+ * item => item.id === 2,
2129
+ * ); // => [{id: 1}]
2130
+ * ```
1140
2131
  */
1141
2132
  declare function take<Item extends PlainObject>(array: Item[], callback: (item: Item, index: number, array: Item[]) => boolean): Item[];
1142
2133
  /**
1143
2134
  * Take a specified number of items, from the start if `>= 0`, or from the end if `< 0`
2135
+ *
1144
2136
  * @param array Original array
1145
2137
  * @param count Number of items to take
1146
2138
  * @returns New array with taken items
2139
+ *
2140
+ * @example
2141
+ * ```typescript
2142
+ * take([1, 2, 3, 4, 5], 2); // => [1, 2]
2143
+ * take([1, 2, 3, 4, 5], -2); // => [4, 5]
2144
+ * ```
1147
2145
  */
1148
2146
  declare function take(array: unknown[], count: number): unknown[];
1149
2147
  //#endregion
1150
2148
  //#region src/array/splice.d.ts
1151
2149
  /**
1152
2150
  * Adds items into an array at a specific index and removes a specific amount of items
2151
+ *
2152
+ * _(Uses chunking to avoid call stack size being exceeded)_
2153
+ *
1153
2154
  * @param array Original array
1154
2155
  * @param start Index to start splicing from
1155
2156
  * @param amount Number of items to remove
1156
2157
  * @param added Added items
1157
2158
  * @returns Removed items
2159
+ *
2160
+ * @example
2161
+ * ```typescript
2162
+ * splice(
2163
+ * [1, 2, 3, 4, 5],
2164
+ * 2,
2165
+ * 2,
2166
+ * [6, 7]
2167
+ * ); // => [3, 4], array becomes [1, 2, 6, 7, 5]
2168
+ * ```
1158
2169
  */
1159
2170
  declare function splice<Item>(array: Item[], start: number, amount: number, added: Item[]): Item[];
1160
2171
  /**
1161
2172
  * Adds items into an array at a specific index
2173
+ *
2174
+ * _(Uses chunking to avoid call stack size being exceeded)_
2175
+ *
1162
2176
  * @param array Original array
1163
2177
  * @param start Index to start splicing from
1164
2178
  * @param added Added items
1165
2179
  * @returns Removed items
2180
+ *
2181
+ * @example
2182
+ * ```typescript
2183
+ * splice(
2184
+ * [1, 2, 3, 4, 5],
2185
+ * 2,
2186
+ * [6, 7]
2187
+ * ); // => [], array becomes [1, 2, 6, 7, 3, 4, 5]
2188
+ * ```
1166
2189
  */
1167
2190
  declare function splice<Item>(array: Item[], start: number, added: Item[]): Item[];
1168
2191
  /**
1169
2192
  * Removes and returns _(up to)_ a specific amount of items from an array, starting from a specific index
2193
+ *
2194
+ * _(Uses chunking to avoid call stack size being exceeded)_
2195
+ *
1170
2196
  * @param array Original array
1171
2197
  * @param start Index to start splicing from
1172
2198
  * @param amount Number of items to remove
1173
2199
  * @returns Removed items
2200
+ *
2201
+ * @example
2202
+ * ```typescript
2203
+ * splice(
2204
+ * [1, 2, 3, 4, 5],
2205
+ * 2,
2206
+ * 2,
2207
+ * ); // => [3, 4], array becomes [1, 2, 5]
2208
+ * ```
1174
2209
  */
1175
2210
  declare function splice<Item>(array: Item[], start: number, amount: number): Item[];
1176
2211
  /**
1177
2212
  * Removes and returns all items from an array starting from a specific index
2213
+ *
2214
+ * _(Uses chunking to avoid call stack size being exceeded)_
2215
+ *
1178
2216
  * @param array Original array
1179
2217
  * @param start Index to start splicing from
1180
2218
  * @returns Removed items
2219
+ *
2220
+ * @example
2221
+ * ```typescript
2222
+ * splice(
2223
+ * [1, 2, 3, 4, 5],
2224
+ * 2,
2225
+ * ); // => [3, 4, 5], array becomes [1, 2]
2226
+ * ```
1181
2227
  */
1182
2228
  declare function splice<Item>(array: Item[], start: number): Item[];
1183
2229
  //#endregion
1184
2230
  //#region src/array/to-set.d.ts
1185
2231
  /**
1186
2232
  * Create a Set from an array of items using a callback
2233
+ *
1187
2234
  * @param array Array to convert
1188
2235
  * @param callback Callback to get an item's value
1189
2236
  * @returns Set of values
2237
+ *
2238
+ * @example
2239
+ * ```typescript
2240
+ * toSet(
2241
+ * [{id: 1}, {id: 2}, {id: 3}],
2242
+ * item => item.id,
2243
+ * ); // => Set { 1, 2, 3 }
2244
+ * ```
1190
2245
  */
1191
2246
  declare function toSet<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback): Set<ReturnType<Callback>>;
1192
2247
  /**
1193
2248
  * Create a Set from an array of items using a key
2249
+ *
1194
2250
  * @param array Array to convert
1195
2251
  * @param key Key to use for value
1196
2252
  * @returns Set of values
2253
+ *
2254
+ * @example
2255
+ * ```typescript
2256
+ * toSet(
2257
+ * [{id: 1}, {id: 2}, {id: 3}],
2258
+ * 'id',
2259
+ * ); // => Set { 1, 2, 3 }
2260
+ * ```
1197
2261
  */
1198
2262
  declare function toSet<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Set<Item[ItemKey]>;
1199
2263
  /**
1200
2264
  * Create a Set from an array of items
2265
+ *
1201
2266
  * @param array Array to convert
1202
2267
  * @returns Set of items
2268
+ *
2269
+ * @example
2270
+ * ```typescript
2271
+ * toSet([1, 2, 3]); // => Set { 1, 2, 3 }
2272
+ * ```
1203
2273
  */
1204
2274
  declare function toSet<Item>(array: Item[]): Set<Item>;
1205
2275
  //#endregion
1206
2276
  //#region src/array/toggle.d.ts
1207
2277
  /**
1208
- * Toggle an item in an array: if the item exists, it will be removed; if it doesn't, it will be added
2278
+ * Toggle an item in an array
2279
+ *
2280
+ * If the item exists, it will be removed; if it doesn't, it will be added
2281
+ *
1209
2282
  * @param destination Array to toggle within
1210
2283
  * @param toggled Toggled items
1211
2284
  * @param callback Callback to find existing item
1212
2285
  * @returns Original array
2286
+ *
2287
+ * @example
2288
+ * ```typescript
2289
+ * toggle(
2290
+ * [{id: 1}, {id: 2}, {id: 3}],
2291
+ * [{id: 2}, {id: 4}],
2292
+ * item => item.id,
2293
+ * ); // => [{id: 1}, {id: 3}, {id: 4}]
2294
+ * ```
1213
2295
  */
1214
2296
  declare function toggle<Item>(destination: Item[], toggled: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1215
2297
  /**
1216
- * Toggle an item in an array: if the item exists, it will be removed; if it doesn't, it will be added
2298
+ * Toggle an item in an array
2299
+ *
2300
+ * If the item exists, it will be removed; if it doesn't, it will be added
2301
+ *
1217
2302
  * @param destination Array to toggle within
1218
2303
  * @param toggled Toggled items
1219
2304
  * @param key Key to find existing item
1220
2305
  * @returns Original array
2306
+ *
2307
+ * @example
2308
+ * ```typescript
2309
+ * toggle(
2310
+ * [{id: 1}, {id: 2}, {id: 3}],
2311
+ * [{id: 2}, {id: 4}],
2312
+ * 'id',
2313
+ * ); // => [{id: 1}, {id: 3}, {id: 4}]
2314
+ * ```
1221
2315
  */
1222
2316
  declare function toggle<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], toggled: Item[], key: ItemKey): Item[];
1223
2317
  /**
1224
- * Toggle an item in an array: if the item exists, it will be removed; if it doesn't, it will be added
2318
+ * Toggle an item in an array
2319
+ *
2320
+ * If the item exists, it will be removed; if it doesn't, it will be added
2321
+ *
1225
2322
  * @param destination Array to toggle within
1226
2323
  * @param toggled Toggled items
1227
2324
  * @returns Original array
2325
+ *
2326
+ * @example
2327
+ * ```typescript
2328
+ * toggle(
2329
+ * [1, 2, 3],
2330
+ * [2, 4],
2331
+ * ); // => [1, 3, 4]
2332
+ * ```
1228
2333
  */
1229
2334
  declare function toggle<Item>(destination: Item[], toggled: Item[]): Item[];
1230
2335
  //#endregion
1231
2336
  //#region src/array/union.d.ts
1232
2337
  /**
1233
2338
  * Get the combined, unique values from two arrays
2339
+ *
1234
2340
  * @param first First array
1235
2341
  * @param second Second array
1236
2342
  * @param callback Callback to get an item's value for comparison
1237
2343
  * @returns Combined, unique values from both arrays
2344
+ *
2345
+ * @example
2346
+ * ```typescript
2347
+ * union(
2348
+ * [{id: 1}, {id: 2}, {id: 3}],
2349
+ * [{id: 2}, {id: 4}],
2350
+ * item => item.id,
2351
+ * ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
2352
+ * ```
1238
2353
  */
1239
2354
  declare function union<First, Second>(first: First[], second: Second[], callback: (item: First | Second) => unknown): (First | Second)[];
1240
2355
  /**
1241
2356
  * Get the combined, unique values from two arrays
2357
+ *
1242
2358
  * @param first First array
1243
2359
  * @param second Second array
1244
2360
  * @param key Key to get an item's value for comparison
1245
2361
  * @returns Combined, unique values from both arrays
2362
+ *
2363
+ * @example
2364
+ * ```typescript
2365
+ * union(
2366
+ * [{id: 1}, {id: 2}, {id: 3}],
2367
+ * [{id: 2}, {id: 4}],
2368
+ * 'id',
2369
+ * ); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}]
2370
+ * ```
1246
2371
  */
1247
2372
  declare function union<First extends Record<string, unknown>, Second extends Record<string, unknown>, SharedKey extends keyof First & keyof Second>(first: First[], second: Second[], key: SharedKey): (First | Second)[];
1248
2373
  /**
1249
2374
  * Get the combined, unique values from two arrays
2375
+ *
1250
2376
  * @param first First array
1251
2377
  * @param second Second array
1252
2378
  * @returns Combined, unique values from both arrays
2379
+ *
2380
+ * @example
2381
+ * ```typescript
2382
+ * union(
2383
+ * [1, 2, 3],
2384
+ * [2, 4],
2385
+ * ); // => [1, 2, 3, 4]
2386
+ * ```
1253
2387
  */
1254
2388
  declare function union<First, Second>(first: First[], second: Second[]): (First | Second)[];
1255
2389
  //#endregion
1256
2390
  //#region src/array/unique.d.ts
1257
2391
  /**
1258
2392
  * Get an array of unique items
2393
+ *
1259
2394
  * @param array Original array
1260
2395
  * @param callback Callback to get an item's value
1261
2396
  * @returns Array of unique items
2397
+ *
2398
+ * @example
2399
+ * ```typescript
2400
+ * unique(
2401
+ * [{id: 1}, {id: 2}, {id: 3}, {id: 2}],
2402
+ * item => item.id,
2403
+ * ); // => [{id: 1}, {id: 2}, {id: 3}]
2404
+ * ```
1262
2405
  */
1263
2406
  declare function unique<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1264
2407
  /**
1265
2408
  * Get an array of unique items
2409
+ *
1266
2410
  * @param array Original array
1267
2411
  * @param key Key to use for unique value
1268
2412
  * @returns Array of unique items
2413
+ *
2414
+ * @example
2415
+ * ```typescript
2416
+ * unique(
2417
+ * [{id: 1}, {id: 2}, {id: 3}, {id: 2}],
2418
+ * 'id',
2419
+ * ); // => [{id: 1}, {id: 2}, {id: 3}]
2420
+ * ```
1269
2421
  */
1270
2422
  declare function unique<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Item[];
1271
2423
  /**
1272
2424
  * Get an array of unique items
2425
+ *
1273
2426
  * @param array Original array
1274
2427
  * @returns Array of unique items
2428
+ *
2429
+ * @example
2430
+ * ```typescript
2431
+ * unique([1, 2, 3, 2]); // => [1, 2, 3]
2432
+ * ```
1275
2433
  */
1276
2434
  declare function unique<Item>(array: Item[]): Item[];
1277
2435
  //#endregion
1278
2436
  //#region src/array/update.d.ts
1279
2437
  /**
1280
- * Update an item in an array: if the item exists, it will be updated; if it doesn't, it will be added
2438
+ * Update an item in an array
2439
+ *
2440
+ * If the item exists, it will be updated; if it doesn't, it will be added
2441
+ *
1281
2442
  * @param destination Array to update within
1282
2443
  * @param updated Updated items
1283
2444
  * @param callback Callback to find existing item
1284
2445
  * @returns Original array
2446
+ *
2447
+ * @example
2448
+ * ```typescript
2449
+ * update(
2450
+ * [{id: 1}, {id: 2}, {id: 3}],
2451
+ * [{id: 2, name: 'Updated'}, {id: 4, name: 'New'}],
2452
+ * item => item.id,
2453
+ * ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
2454
+ * ```
1285
2455
  */
1286
2456
  declare function update<Item>(destination: Item[], updated: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1287
2457
  /**
1288
- * Update an item in an array: if the item exists, it will be updated; if it doesn't, it will be added
2458
+ * Update an item in an array
2459
+ *
2460
+ * If the item exists, it will be updated; if it doesn't, it will be added
2461
+ *
1289
2462
  * @param destination Array to update within
1290
2463
  * @param updated Updated items
1291
2464
  * @param key Key to find existing item
1292
2465
  * @returns Original array
2466
+ *
2467
+ * @example
2468
+ * ```typescript
2469
+ * update(
2470
+ * [{id: 1}, {id: 2}, {id: 3}],
2471
+ * [{id: 2, name: 'Updated'}, {id: 4, name: 'New'}],
2472
+ * 'id',
2473
+ * ); // => [{id: 1}, {id: 2, name: 'Updated'}, {id: 3}, {id: 4, name: 'New'}]
2474
+ * ```
1293
2475
  */
1294
2476
  declare function update<Item extends PlainObject, ItemKey extends keyof Item>(destination: Item[], updated: Item[], key: ItemKey): Item[];
1295
2477
  /**
1296
- * Update an item in an array: if the item exists, it will be updated; if it doesn't, it will be added
2478
+ * Update an item in an array
2479
+ *
2480
+ * If the item exists, it will be updated; if it doesn't, it will be added
2481
+ *
1297
2482
  * @param destination Array to update within
1298
2483
  * @param updated Updated items
1299
2484
  * @returns Original array
2485
+ *
2486
+ * @example
2487
+ * ```typescript
2488
+ * update(
2489
+ * [1, 2, 3],
2490
+ * [2, 4],
2491
+ * ); // => [1, 2, 3, 4]
2492
+ * ```
1300
2493
  */
1301
2494
  declare function update<Item>(destination: Item[], updated: Item[]): Item[];
1302
2495
  //#endregion
1303
2496
  //#region src/array/last.d.ts
1304
2497
  /**
1305
2498
  * Get the last items matching the given value
2499
+ *
1306
2500
  * @param array Array to search in
1307
2501
  * @param callback Callback to get an item's value for matching
1308
2502
  * @param value Value to match against
1309
2503
  * @returns Last item that matches the value, or `undefined` if no match is found
2504
+ *
2505
+ * @example
2506
+ * ```typescript
2507
+ * last(
2508
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2509
+ * item => item.value,
2510
+ * 10,
2511
+ * ); // => {id: 3, value: 10}
2512
+ * ```
1310
2513
  */
1311
2514
  declare function last<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
1312
2515
  /**
1313
2516
  * Get the first item matching the given value by key
2517
+ *
1314
2518
  * @param array Array to search in
1315
2519
  * @param key Key to get an item's value for matching
1316
2520
  * @param value Value to match against
1317
2521
  * @returns Last item that matches the value, or `undefined` if no match is found
2522
+ *
2523
+ * @example
2524
+ * ```typescript
2525
+ * last(
2526
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2527
+ * 'value',
2528
+ * 10,
2529
+ * ); // => {id: 3, value: 10}
2530
+ * ```
1318
2531
  */
1319
2532
  declare function last<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
1320
2533
  /**
1321
2534
  * Get the last item matching the filter
2535
+ *
1322
2536
  * @param array Array to search in
1323
2537
  * @param filter Filter callback to match items
1324
2538
  * @returns Last item that matches the filter, or `undefined` if no match is found
2539
+ *
2540
+ * @example
2541
+ * ```typescript
2542
+ * last(
2543
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2544
+ * item => item.value === 10,
2545
+ * ); // => {id: 3, value: 10}
2546
+ * ```
1325
2547
  */
1326
2548
  declare function last<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item | undefined;
1327
2549
  /**
1328
2550
  * Get the last item from an array
2551
+ *
1329
2552
  * @param array Array to get from
1330
- * @return Last item from the array, or `undefined` if the array is empty
2553
+ * @returns Last item from the array, or `undefined` if the array is empty
2554
+ *
2555
+ * @example
2556
+ * ```typescript
2557
+ * last([1, 2, 3]); // => 3
2558
+ * ```
1331
2559
  */
1332
2560
  declare function last<Item>(array: Item[]): Item | undefined;
1333
2561
  declare namespace last {
@@ -1338,41 +2566,79 @@ declare namespace last {
1338
2566
  * Get the last item matching the given value
1339
2567
  *
1340
2568
  * Available as `lastOrDefault` and `last.default`
2569
+ *
1341
2570
  * @param array Array to search in
1342
2571
  * @param defaultValue Default value to return if no match is found
1343
2572
  * @param callback Callback to get an item's value for matching
1344
2573
  * @param value Value to match against
1345
2574
  * @returns Last item that matches the value, or the default value if no match is found
2575
+ *
2576
+ * @example
2577
+ * ```typescript
2578
+ * lastOrDefault(
2579
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2580
+ * {id: -1, value: 30},
2581
+ * item => item.value,
2582
+ * 30,
2583
+ * ); // => {id: -1, value: 30}
2584
+ * ```
1346
2585
  */
1347
2586
  declare function lastOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
1348
2587
  /**
1349
2588
  * Get the last item matching the given value by key
1350
2589
  *
1351
2590
  * Available as `lastOrDefault` and `last.default`
2591
+ *
1352
2592
  * @param array Array to search in
1353
2593
  * @param defaultValue Default value to return if no match is found
1354
2594
  * @param key Key to get an item's value for matching
1355
2595
  * @param value Value to match against
1356
2596
  * @returns Last item that matches the value, or the default value if no match is found
2597
+ *
2598
+ * @example
2599
+ * ```typescript
2600
+ * lastOrDefault(
2601
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2602
+ * {id: -1, value: 30},
2603
+ * 'value',
2604
+ * 30,
2605
+ * ); // => {id: -1, value: 30}
2606
+ * ```
1357
2607
  */
1358
2608
  declare function lastOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
1359
2609
  /**
1360
2610
  * Get the last item matching the filter
1361
2611
  *
1362
2612
  * Available as `lastOrDefault` and `last.default`
2613
+ *
1363
2614
  * @param array Array to search in
1364
2615
  * @param defaultValue Default value to return if no match is found
1365
2616
  * @param filter Filter callback to match items
1366
2617
  * @returns Last item that matches the filter, or the default value if no match is found
2618
+ *
2619
+ * @example
2620
+ * ```typescript
2621
+ * lastOrDefault(
2622
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
2623
+ * {id: -1, value: 30},
2624
+ * item => item.value === 30,
2625
+ * ); // => {id: -1, value: 30}
2626
+ * ```
1367
2627
  */
1368
2628
  declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
1369
2629
  /**
1370
2630
  * Get the last item from an array
1371
2631
  *
1372
2632
  * Available as `lastOrDefault` and `last.default`
2633
+ *
1373
2634
  * @param array Array to get from
1374
2635
  * @param defaultValue Default value to return if the array is empty
1375
- * @return Last item from the array, or the default value if the array is empty
2636
+ * @returns Last item from the array, or the default value if the array is empty
2637
+ *
2638
+ * @example
2639
+ * ```typescript
2640
+ * lastOrDefault([], {id: -1, value: 30}); // => {id: -1, value: 30}
2641
+ * ```
1376
2642
  */
1377
2643
  declare function lastOrDefault<Item>(array: Item[], defaultValue: Item): Item;
1378
2644
  //#endregion
@@ -1383,36 +2649,66 @@ declare function lastOrDefault<Item>(array: Item[], defaultValue: Item): Item;
1383
2649
  * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
1384
2650
  *
1385
2651
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
2652
+ *
1386
2653
  * @param array Array to move within
1387
2654
  * @param from Item or items to move
1388
2655
  * @param to Item or items to move to
1389
- * @param key Key to get an item's value for matching
2656
+ * @param callback Callback to get an item's value for matching
1390
2657
  * @returns Original array with items moved _(or unchanged if unable to move)_
2658
+ *
2659
+ * @example
2660
+ * ```typescript
2661
+ * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
2662
+ *
2663
+ * move(array, {id: 1}, {id: 3}, item => item.id); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
2664
+ * move(array, [{id: 2}, {id: 3}], {id: 4}, item => item.id); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
2665
+ * move(array, {id: 5}, {id: 1}, item => item.id); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
2666
+ * ```
1391
2667
  */
1392
- declare function move<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], from: Item | Item[], to: Item | Item[], key: ItemKey): Item[];
2668
+ declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1393
2669
  /**
1394
2670
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
1395
2671
  *
1396
2672
  * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
1397
2673
  *
1398
2674
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
2675
+ *
1399
2676
  * @param array Array to move within
1400
2677
  * @param from Item or items to move
1401
2678
  * @param to Item or items to move to
1402
- * @param callback Callback to get an item's value for matching
2679
+ * @param key Key to get an item's value for matching
1403
2680
  * @returns Original array with items moved _(or unchanged if unable to move)_
2681
+ *
2682
+ * @example
2683
+ * ```typescript
2684
+ * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
2685
+ *
2686
+ * move(array, {id: 1}, {id: 3}, 'id'); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
2687
+ * move(array, [{id: 2}, {id: 3}], {id: 4}, 'id'); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
2688
+ * move(array, {id: 5}, {id: 1}, 'id'); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
2689
+ * ```
1404
2690
  */
1405
- declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
2691
+ declare function move<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], from: Item | Item[], to: Item | Item[], key: ItemKey): Item[];
1406
2692
  /**
1407
2693
  * Move an item _(or array of items)_ to the position of another item _(or array of items)_ within an array
1408
2694
  *
1409
2695
  * When moving to the front of the array, the moved items will be placed __before__ the target item. When moving to the back of the array, the moved items will be placed __after__ the target item.
1410
2696
  *
1411
2697
  * If either of values are not present in the array, or if they overlap, the array will be returned unchanged
2698
+ *
1412
2699
  * @param array Array to move within
1413
2700
  * @param from Item or items to move
1414
2701
  * @param to Item or items to move to
1415
2702
  * @returns Original array with items moved _(or unchanged if unable to move)_
2703
+ *
2704
+ * @example
2705
+ * ```typescript
2706
+ * const array = [1, 2, 3, 4];
2707
+ *
2708
+ * move(array, 1, 3); // => [2, 3, 1, 4]
2709
+ * move(array, [2, 3], 4); // => [1, 4, 2, 3]
2710
+ * move(array, 5, 1); // => [1, 2, 3, 4] (unchanged)
2711
+ * ```
1416
2712
  */
1417
2713
  declare function move<Item>(array: Item[], from: Item | Item[], to: Item | Item[]): Item[];
1418
2714
  declare namespace move {
@@ -1425,10 +2721,20 @@ declare namespace move {
1425
2721
  * If the from index is out of bounds, the array will be returned unchanged
1426
2722
  *
1427
2723
  * Available as `moveIndices` and `move.indices`
2724
+ *
1428
2725
  * @param array Array to move within
1429
2726
  * @param from Index to move from
1430
2727
  * @param to Index to move to
1431
2728
  * @returns Original array with item moved _(or unchanged if unable to move)_
2729
+ *
2730
+ * @example
2731
+ * ```typescript
2732
+ * const array = [1, 2, 3, 4];
2733
+ *
2734
+ * moveIndices(array, 0, 2); // => [2, 3, 1, 4]
2735
+ * moveIndices(array, -1, 0); // => [4, 2, 3, 1]
2736
+ * moveIndices(array, 5, 1); // => [4, 2, 3, 1] (unchanged)
2737
+ * ```
1432
2738
  */
1433
2739
  declare function moveIndices<Item>(array: Item[], from: number, to: number): Item[];
1434
2740
  /**
@@ -1437,36 +2743,66 @@ declare function moveIndices<Item>(array: Item[], from: number, to: number): Ite
1437
2743
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1438
2744
  *
1439
2745
  * Available as `moveToIndex` and `move.toIndex`
2746
+ *
2747
+ * @example
2748
+ * ```typescript
2749
+ * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
2750
+ *
2751
+ * moveToIndex(array, {id: 1}, 2, item => item.id); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
2752
+ * moveToIndex(array, [{id: 2}, {id: 3}], 3, item => item.id); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
2753
+ * moveToIndex(array, {id: 5}, 1, item => item.id); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
2754
+ * ```
2755
+ *
1440
2756
  * @param array Array to move within
1441
2757
  * @param value Item or items to move
1442
2758
  * @param index Index to move to
1443
- * @param key Key to get an item's value for matching
2759
+ * @param callback Callback to get an item's value for matching
1444
2760
  * @returns Original array with items moved _(or unchanged if unable to move)_
1445
2761
  */
1446
- declare function moveToIndex<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], value: Item | Item[], index: number, key: ItemKey): Item[];
2762
+ declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1447
2763
  /**
1448
2764
  * Move an item _(or array of items)_ to an index within an array
1449
2765
  *
1450
2766
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1451
2767
  *
1452
2768
  * Available as `moveToIndex` and `move.toIndex`
2769
+ *
1453
2770
  * @param array Array to move within
1454
2771
  * @param value Item or items to move
1455
2772
  * @param index Index to move to
1456
- * @param callback Callback to get an item's value for matching
2773
+ * @param key Key to get an item's value for matching
1457
2774
  * @returns Original array with items moved _(or unchanged if unable to move)_
2775
+ *
2776
+ * @example
2777
+ * ```typescript
2778
+ * const array = [{id: 1}, {id: 2}, {id: 3}, {id: 4}];
2779
+ *
2780
+ * moveToIndex(array, {id: 1}, 2, 'id'); // => [{id: 2}, {id: 3}, {id: 1}, {id: 4}]
2781
+ * moveToIndex(array, [{id: 2}, {id: 3}], 3, 'id'); // => [{id: 1}, {id: 4}, {id: 2}, {id: 3}]
2782
+ * moveToIndex(array, {id: 5}, 1, 'id'); // => [{id: 1}, {id: 2}, {id: 3}, {id: 4}] (unchanged)
2783
+ * ```
1458
2784
  */
1459
- declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
2785
+ declare function moveToIndex<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], value: Item | Item[], index: number, key: ItemKey): Item[];
1460
2786
  /**
1461
2787
  * Move an item _(or array of items)_ to an index within an array
1462
2788
  *
1463
2789
  * If the value is not present in the array, or if the index is out of bounds, the array will be returned unchanged
1464
2790
  *
1465
2791
  * Available as `moveToIndex` and `move.toIndex`
2792
+ *
1466
2793
  * @param array Array to move within
1467
2794
  * @param value Item or items to move
1468
2795
  * @param index Index to move to
1469
2796
  * @returns Original array with items moved _(or unchanged if unable to move)_
2797
+ *
2798
+ * @example
2799
+ * ```typescript
2800
+ * const array = [1, 2, 3, 4];
2801
+ *
2802
+ * moveToIndex(array, 1, 2); // => [2, 3, 1, 4]
2803
+ * moveToIndex(array, [2, 3], 3); // => [1, 4, 2, 3]
2804
+ * moveToIndex(array, 5, 1); // => [1, 2, 3, 4] (unchanged)
2805
+ * ```
1470
2806
  */
1471
2807
  declare function moveToIndex<Item>(array: Item[], value: Item | Item[], index: number): Item[];
1472
2808
  //#endregion
@@ -1535,9 +2871,15 @@ type ComparisonSorter<Item> = (first: Item, second: Item) => number;
1535
2871
  * Direction to sort by
1536
2872
  */
1537
2873
  type SortDirection = 'ascending' | 'descending';
2874
+ /**
2875
+ * Sorter for an array with predefined sorters
2876
+ *
2877
+ * Can be used to sort an array, get the predicted index for an item, and check if an array is sorted
2878
+ */
1538
2879
  type Sorter<Item> = {
1539
2880
  /**
1540
2881
  * Sort an array of items
2882
+ *
1541
2883
  * @param array Array to sort
1542
2884
  * @returns Sorted array
1543
2885
  */
@@ -1546,6 +2888,7 @@ type Sorter<Item> = {
1546
2888
  * Get the index for an item _(to be inserted into an array of items)_
1547
2889
  *
1548
2890
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
2891
+ *
1549
2892
  * @param array Array to get the index from
1550
2893
  * @param item Item to get the index for
1551
2894
  * @returns Index for item
@@ -1553,6 +2896,7 @@ type Sorter<Item> = {
1553
2896
  index(array: Item[], item: Item): number;
1554
2897
  /**
1555
2898
  * Is the array sorted?
2899
+ *
1556
2900
  * @param array Array to check
1557
2901
  * @returns `true` if sorted, otherwise `false`
1558
2902
  */
@@ -1563,7 +2907,8 @@ type Sorter<Item> = {
1563
2907
  *
1564
2908
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
1565
2909
  *
1566
- * Available as `getSortedIndex` and `sort.index`
2910
+ * Available as `getSortedIndex` and `sort.getIndex`
2911
+ *
1567
2912
  * @param array Array to get the index from
1568
2913
  * @param item Item to get the index for
1569
2914
  * @param sorters Sorters to use to determine sorting
@@ -1576,7 +2921,8 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<
1576
2921
  *
1577
2922
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
1578
2923
  *
1579
- * Available as `getSortedIndex` and `sort.index`
2924
+ * Available as `getSortedIndex` and `sort.getIndex`
2925
+ *
1580
2926
  * @param array Array to get the index from
1581
2927
  * @param item Item to get the index for
1582
2928
  * @param sorter Sorter to use to determine sorting
@@ -1589,7 +2935,8 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySo
1589
2935
  *
1590
2936
  * _(If the array is not sorted, it will be treated as sorted, and the result may be inaccurate)_
1591
2937
  *
1592
- * Available as `getSortedIndex` and `sort.index`
2938
+ * Available as `getSortedIndex` and `sort.getIndex`
2939
+ *
1593
2940
  * @param array Array to get the index from
1594
2941
  * @param item Item to get the index for
1595
2942
  * @param descending Sorted in descending order? _(defaults to `false`)_
@@ -1600,6 +2947,7 @@ declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: bo
1600
2947
  * Initialize a sort handler with sorters _(and an optional default direction)_
1601
2948
  *
1602
2949
  * Available as `initializeSorter` and `sort.initialize`
2950
+ *
1603
2951
  * @param sorters Sorters to use for sorting
1604
2952
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
1605
2953
  * @returns Sort handler
@@ -1609,6 +2957,7 @@ declare function initializeSorter<Item>(sorters: Array<ArraySorter<Item>>, desce
1609
2957
  * Initialize a sort handler with a sorter _(and an optional default direction)_
1610
2958
  *
1611
2959
  * Available as `initializeSorter` and `sort.initialize`
2960
+ *
1612
2961
  * @param sorter Sorter to use for sorting
1613
2962
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
1614
2963
  * @returns Sort handler
@@ -1618,12 +2967,14 @@ declare function initializeSorter<Item>(sorter: ArraySorter<Item>, descending?:
1618
2967
  * Initialize a sort handler _(with an optional default direction)_
1619
2968
  *
1620
2969
  * Available as `initializeSorter` and `sort.initialize`
2970
+ *
1621
2971
  * @param descending Sort in descending order? _(defaults to `false`)_
1622
2972
  * @returns Sort handler
1623
2973
  */
1624
2974
  declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
1625
2975
  /**
1626
2976
  * Is the array sorted according to the sorters _(and the optional default direction)_?
2977
+ *
1627
2978
  * @param array Array to check
1628
2979
  * @param sorters Sorters to determine sorting
1629
2980
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -1632,6 +2983,7 @@ declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
1632
2983
  declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): boolean;
1633
2984
  /**
1634
2985
  * Is the array sorted according to the sorter _(and the optional default direction)_?
2986
+ *
1635
2987
  * @param array Array to check
1636
2988
  * @param sorter Sorter to determine sorting
1637
2989
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
@@ -1642,6 +2994,7 @@ declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descen
1642
2994
  * Is the array sorted?
1643
2995
  *
1644
2996
  * Available as `isSorted` and `sort.is`
2997
+ *
1645
2998
  * @param array Array to check
1646
2999
  * @param descending Sorted in descending order? _(defaults to `false`)_
1647
3000
  * @returns `true` if sorted, otherwise `false`
@@ -1649,10 +3002,19 @@ declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descen
1649
3002
  declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
1650
3003
  /**
1651
3004
  * Sort an array of items using a comparison callback
3005
+ *
1652
3006
  * @param array Array to sort
1653
3007
  * @param comparator Comparator to use for sorting
1654
3008
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
1655
3009
  * @returns Sorted array
3010
+ *
3011
+ * @example
3012
+ * ```typescript
3013
+ * sort(
3014
+ * [{id: 3}, {id: 1}, {id: 2}],
3015
+ * (first, second) => first.id - second.id,
3016
+ * ); // => [{id: 1}, {id: 2}, {id: 3}]
3017
+ * ```
1656
3018
  */
1657
3019
  declare function sort<Item>(array: Item[], comparator: (first: Item, second: Item) => number, descending?: boolean): Item[];
1658
3020
  /**
@@ -1679,7 +3041,7 @@ declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending
1679
3041
  */
1680
3042
  declare function sort<Item>(array: Item[], descending?: boolean): Item[];
1681
3043
  declare namespace sort {
1682
- var index: typeof getSortedIndex;
3044
+ var getIndex: typeof getSortedIndex;
1683
3045
  var initialize: typeof initializeSorter;
1684
3046
  var is: typeof isSorted;
1685
3047
  }
@@ -1691,62 +3053,166 @@ declare const SORT_DIRECTION_DESCENDING: SortDirection;
1691
3053
  * Swap two smaller arrays within a larger array
1692
3054
  *
1693
3055
  * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
3056
+ *
1694
3057
  * @param array Array of items to swap
1695
3058
  * @param first First array
1696
3059
  * @param second Second array
1697
- * @param key Key to get an item's value for matching
3060
+ * @param callback Callback to get an item's value for matching
1698
3061
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3062
+ *
3063
+ * @example
3064
+ * ```typescript
3065
+ * swap(
3066
+ * [
3067
+ * {id: 1, name: 'Alice'},
3068
+ * {id: 2, name: 'Bob'},
3069
+ * {id: 3, name: 'Charlie'},
3070
+ * ],
3071
+ * [
3072
+ * {id: 2, name: 'Bob'},
3073
+ * ],
3074
+ * [
3075
+ * {id: 3, name: 'Charlie'},
3076
+ * ],
3077
+ * item => item.id,
3078
+ * ); // => [
3079
+ * // {id: 1, name: 'Alice'},
3080
+ * // {id: 3, name: 'Charlie'},
3081
+ * // {id: 2, name: 'Bob'},
3082
+ * // ]
3083
+ * ```
1699
3084
  */
1700
- declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item[], second: Item[], key: ItemKey): Item[];
3085
+ declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1701
3086
  /**
1702
3087
  * Swap two smaller arrays within a larger array
1703
3088
  *
1704
3089
  * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
3090
+ *
1705
3091
  * @param array Array of items to swap
1706
3092
  * @param first First array
1707
3093
  * @param second Second array
1708
- * @param callback Callback to get an item's value for matching
3094
+ * @param key Key to get an item's value for matching
1709
3095
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3096
+ *
3097
+ * @example
3098
+ * ```typescript
3099
+ * swap(
3100
+ * [
3101
+ * {id: 1, name: 'Alice'},
3102
+ * {id: 2, name: 'Bob'},
3103
+ * {id: 3, name: 'Charlie'},
3104
+ * ],
3105
+ * [
3106
+ * {id: 2, name: 'Bob'},
3107
+ * ],
3108
+ * [
3109
+ * {id: 3, name: 'Charlie'},
3110
+ * ],
3111
+ * 'id',
3112
+ * ); // => [
3113
+ * // {id: 1, name: 'Alice'},
3114
+ * // {id: 3, name: 'Charlie'},
3115
+ * // {id: 2, name: 'Bob'},
3116
+ * // ]
3117
+ * ```
1710
3118
  */
1711
- declare function swap<Item>(array: Item[], first: Item[], second: Item[], callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
3119
+ declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item[], second: Item[], key: ItemKey): Item[];
1712
3120
  /**
1713
3121
  * Swap two smaller arrays within a larger array
1714
3122
  *
1715
3123
  * If either of the smaller arrays are not present in the larger array, or if they overlap, the larger array will be returned unchanged
3124
+ *
1716
3125
  * @param array Array of items to swap
1717
3126
  * @param first First array
1718
3127
  * @param second Second array
1719
3128
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3129
+ *
3130
+ * @example
3131
+ * ```typescript
3132
+ * swap(
3133
+ * [1, 2, 3, 4, 5, 6],
3134
+ * [1, 2],
3135
+ * [5, 6],
3136
+ * ); // => [5, 6, 3, 4, 1, 2]
3137
+ * ```
1720
3138
  */
1721
3139
  declare function swap<Item>(array: Item[], first: Item[], second: Item[]): Item[];
1722
3140
  /**
1723
3141
  * Swap two indiced items in an array
1724
3142
  *
1725
3143
  * If either of the items are not present in the array, the array will be returned unchanged
3144
+ *
1726
3145
  * @param array Array of items to swap
1727
3146
  * @param first First item
1728
3147
  * @param second Second item
1729
- * @param key Key to get an item's value for matching
3148
+ * @param callback Callback to get an item's value for matching
1730
3149
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3150
+ *
3151
+ * @example
3152
+ * ```typescript
3153
+ * swap(
3154
+ * [
3155
+ * {id: 1, name: 'Alice'},
3156
+ * {id: 2, name: 'Bob'},
3157
+ * {id: 3, name: 'Charlie'},
3158
+ * ],
3159
+ * {id: 2, name: 'Bob'},
3160
+ * {id: 3, name: 'Charlie'},
3161
+ * item => item.id,
3162
+ * ); // => [
3163
+ * // {id: 1, name: 'Alice'},
3164
+ * // {id: 3, name: 'Charlie'},
3165
+ * // {id: 2, name: 'Bob'},
3166
+ * // ]
3167
+ * ```
1731
3168
  */
1732
- declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item, second: Item, key: ItemKey): Item[];
3169
+ declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
1733
3170
  /**
1734
3171
  * Swap two indiced items in an array
1735
3172
  *
1736
3173
  * If either of the items are not present in the array, the array will be returned unchanged
3174
+ *
1737
3175
  * @param array Array of items to swap
1738
3176
  * @param first First item
1739
3177
  * @param second Second item
1740
- * @param callback Callback to get an item's value for matching
3178
+ * @param key Key to get an item's value for matching
1741
3179
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3180
+ *
3181
+ * @example
3182
+ * ```typescript
3183
+ * swap(
3184
+ * [
3185
+ * {id: 1, name: 'Alice'},
3186
+ * {id: 2, name: 'Bob'},
3187
+ * {id: 3, name: 'Charlie'},
3188
+ * ],
3189
+ * {id: 2, name: 'Bob'},
3190
+ * {id: 3, name: 'Charlie'},
3191
+ * 'id',
3192
+ * ); // => [
3193
+ * // {id: 1, name: 'Alice'},
3194
+ * // {id: 3, name: 'Charlie'},
3195
+ * // {id: 2, name: 'Bob'},
3196
+ * // ]
3197
+ * ```
1742
3198
  */
1743
- declare function swap<Item>(array: Item[], first: Item, second: Item, callback: (item: Item, index: number, array: Item[]) => unknown): Item[];
3199
+ declare function swap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], first: Item, second: Item, key: ItemKey): Item[];
1744
3200
  /**
1745
3201
  * Swap two indiced items in an array
3202
+ *
1746
3203
  * @param array Array of items to swap
1747
3204
  * @param first First item
1748
3205
  * @param second Second item
1749
3206
  * @returns Original array with items swapped _(or unchanged if unable to swap)_
3207
+ *
3208
+ * @example
3209
+ * ```typescript
3210
+ * swap(
3211
+ * [1, 2, 3, 4, 5, 6],
3212
+ * 2,
3213
+ * 5,
3214
+ * ); // => [1, 5, 3, 4, 2, 6]
3215
+ * ```
1750
3216
  */
1751
3217
  declare function swap<Item>(array: Item[], first: Item, second: Item): Item[];
1752
3218
  declare namespace swap {
@@ -1758,6 +3224,7 @@ declare namespace swap {
1758
3224
  * If either index is out of bounds, the array will be returned unchanged
1759
3225
  *
1760
3226
  * Available as `swapIndices` and `swap.indices`
3227
+ *
1761
3228
  * @param array Array of items to swap
1762
3229
  * @param first First index _(can be negative to count from the end)_
1763
3230
  * @param second Second index _(can be negative to count from the end)_
@@ -1770,64 +3237,130 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
1770
3237
  * Create a Map from an array of items using callbacks
1771
3238
  *
1772
3239
  * If multiple items have the same key, the latest item's value will be used
3240
+ *
1773
3241
  * @param array Array to convert
1774
3242
  * @param key Callback to get an item's grouping key
1775
3243
  * @param value Callback to get an item's value
1776
3244
  * @returns Map of keyed values
3245
+ *
3246
+ * @example
3247
+ * ```typescript
3248
+ * toMap(
3249
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3250
+ * item => item.value,
3251
+ * item => item.id,
3252
+ * ); // => Map { 10 => 3, 20 => 2 }
3253
+ * ```
1777
3254
  */
1778
3255
  declare function toMap<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback>>;
1779
3256
  /**
1780
3257
  * Create a Map from an array of items using a callback and value
1781
3258
  *
1782
3259
  * If multiple items have the same key, the latest item's value will be used
3260
+ *
1783
3261
  * @param array Array to convert
1784
3262
  * @param key Callback to get an item's grouping key
1785
3263
  * @param value Key to use for value
1786
3264
  * @returns Map of keyed values
3265
+ *
3266
+ * @example
3267
+ * ```typescript
3268
+ * toMap(
3269
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3270
+ * item => item.value,
3271
+ * 'id',
3272
+ * ); // => Map { 10 => 3, 20 => 2 }
3273
+ * ```
1787
3274
  */
1788
3275
  declare function toMap<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Map<ReturnType<KeyCallback>, Item[ItemValue]>;
1789
3276
  /**
1790
3277
  * Create a Map from an array of items using a key and callback
1791
3278
  *
1792
3279
  * If multiple items have the same key, the latest item's value will be used
3280
+ *
1793
3281
  * @param array Array to convert
1794
3282
  * @param key Key to use for grouping
1795
3283
  * @param value Callback to get an item's value
1796
3284
  * @returns Map of keyed values
3285
+ *
3286
+ * @example
3287
+ * ```typescript
3288
+ * toMap(
3289
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3290
+ * 'value',
3291
+ * item => item.id,
3292
+ * ); // => Map { 10 => 3, 20 => 2 }
3293
+ * ```
1797
3294
  */
1798
3295
  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>>;
1799
3296
  /**
1800
3297
  * Create a Map from an array of items using a key and value
1801
3298
  *
1802
3299
  * If multiple items have the same key, the latest item's value will be used
3300
+ *
1803
3301
  * @param array Array to convert
1804
3302
  * @param key Key to use for grouping
1805
3303
  * @param value Key to use for value
1806
3304
  * @returns Map of keyed values
3305
+ *
3306
+ * @example
3307
+ * ```typescript
3308
+ * toMap(
3309
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3310
+ * 'value',
3311
+ * 'id',
3312
+ * ); // => Map { 10 => 3, 20 => 2 }
3313
+ * ```
1807
3314
  */
1808
3315
  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]>;
1809
3316
  /**
1810
3317
  * Create a Map from an array of items using a callback
1811
3318
  *
1812
3319
  * If multiple items have the same key, the latest item will be used
3320
+ *
1813
3321
  * @param array Array to convert
1814
3322
  * @param callback Callback to get an item's grouping key
1815
3323
  * @returns Map of keyed items
3324
+ *
3325
+ * @example
3326
+ * ```typescript
3327
+ * toMap(
3328
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3329
+ * item => item.value,
3330
+ * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
3331
+ * ```
1816
3332
  */
1817
3333
  declare function toMap<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item>;
1818
3334
  /**
1819
3335
  * Create a Map from an array of items using a key
1820
3336
  *
1821
3337
  * If multiple items have the same key, the latest item will be used
3338
+ *
1822
3339
  * @param array Array to convert
1823
3340
  * @param key Key to use for grouping
1824
3341
  * @returns Map of keyed items
3342
+ *
3343
+ * @example
3344
+ * ```typescript
3345
+ * toMap(
3346
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3347
+ * 'value',
3348
+ * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
3349
+ * ```
1825
3350
  */
1826
3351
  declare function toMap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item>;
1827
3352
  /**
1828
3353
  * Create a Map from an array of items _(using indices as keys)_
3354
+ *
1829
3355
  * @param array Array to convert
1830
3356
  * @returns Map of indiced items
3357
+ *
3358
+ * @example
3359
+ * ```typescript
3360
+ * toMap(
3361
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3362
+ * ); // => Map { 0 => {id: 1, value: 10}, 1 => {id: 2, value: 20}, 2 => {id: 3, value: 10} }
3363
+ * ```
1831
3364
  */
1832
3365
  declare function toMap<Item>(array: Item[]): Map<number, Item>;
1833
3366
  declare namespace toMap {
@@ -1837,58 +3370,116 @@ declare namespace toMap {
1837
3370
  * Create a Map from an array of items using callbacks, grouping values into arrays
1838
3371
  *
1839
3372
  * Available as `toMapArrays` and `toMap.arrays`
3373
+ *
1840
3374
  * @param array Array to convert
1841
3375
  * @param key Callback to get an item's grouping key
1842
3376
  * @param value Callback to get an item's value
1843
3377
  * @returns Map of keyed arrays of values
3378
+ *
3379
+ * @example
3380
+ * ```typescript
3381
+ * toMapArrays(
3382
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3383
+ * item => item.value,
3384
+ * item => item.id,
3385
+ * ); // => Map { 10 => [1, 3], 20 => [2] }
3386
+ * ```
1844
3387
  */
1845
3388
  declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback>[]>;
1846
3389
  /**
1847
3390
  * Create a Map from an array of items using a callback and value, grouping values into arrays
1848
3391
  *
1849
3392
  * Available as `toMapArrays` and `toMap.arrays`
3393
+ *
1850
3394
  * @param array Array to convert
1851
3395
  * @param key Callback to get an item's grouping key
1852
3396
  * @param value Key to use for value
1853
3397
  * @returns Map of keyed arrays of values
3398
+ *
3399
+ * @example
3400
+ * ```typescript
3401
+ * toMapArrays(
3402
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3403
+ * item => item.value,
3404
+ * 'id',
3405
+ * ); // => Map { 10 => [1, 3], 20 => [2] }
3406
+ * ```
1854
3407
  */
1855
3408
  declare function toMapArrays<Item extends PlainObject, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], key: KeyCallback, value: ItemValue): Map<ReturnType<KeyCallback>, Item[ItemValue][]>;
1856
3409
  /**
1857
3410
  * Create a Map from an array of items using a key and callback, grouping values into arrays
1858
3411
  *
1859
3412
  * Available as `toMapArrays` and `toMap.arrays`
3413
+ *
1860
3414
  * @param array Array to convert
1861
3415
  * @param key Key to use for grouping
1862
3416
  * @param value Callback to get an item's value
1863
3417
  * @returns Map of keyed arrays of values
3418
+ *
3419
+ * @example
3420
+ * ```typescript
3421
+ * toMapArrays(
3422
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3423
+ * 'value',
3424
+ * item => item.id,
3425
+ * ); // => Map { 10 => [1, 3], 20 => [2] }
3426
+ * ```
1864
3427
  */
1865
3428
  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>[]>;
1866
3429
  /**
1867
3430
  * Create a Map from an array of items using a key and value, grouping values into arrays
1868
3431
  *
1869
3432
  * Available as `toMapArrays` and `toMap.arrays`
3433
+ *
1870
3434
  * @param array Array to convert
1871
3435
  * @param key Key to use for grouping
1872
3436
  * @param value Key to use for value
1873
3437
  * @returns Map of keyed arrays of values
3438
+ *
3439
+ * @example
3440
+ * ```typescript
3441
+ * toMapArrays(
3442
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3443
+ * 'value',
3444
+ * 'id',
3445
+ * ); // => Map { 10 => [1, 3], 20 => [2] }
3446
+ * ```
1874
3447
  */
1875
3448
  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][]>;
1876
3449
  /**
1877
3450
  * Create a Map from an array of items using a callback, grouping items into arrays
1878
3451
  *
1879
3452
  * Available as `toMapArrays` and `toMap.arrays`
3453
+ *
1880
3454
  * @param array Array to convert
1881
3455
  * @param callback Callback to get an item's grouping key
1882
3456
  * @returns Map of keyed arrays of items
3457
+ *
3458
+ * @example
3459
+ * ```typescript
3460
+ * toMapArrays(
3461
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3462
+ * item => item.value,
3463
+ * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
3464
+ * ```
1883
3465
  */
1884
3466
  declare function toMapArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item[]>;
1885
3467
  /**
1886
3468
  * Create a Map from an array of items using a key, grouping items into arrays
1887
3469
  *
1888
3470
  * Available as `toMapArrays` and `toMap.arrays`
3471
+ *
1889
3472
  * @param array Array to convert
1890
3473
  * @param key Key to use for grouping
1891
3474
  * @returns Map of keyed arrays of items
3475
+ *
3476
+ * @example
3477
+ * ```typescript
3478
+ * toMapArrays(
3479
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3480
+ * 'value',
3481
+ * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
3482
+ * ```
1892
3483
  */
1893
3484
  declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item[]>;
1894
3485
  //#endregion
@@ -1897,64 +3488,130 @@ declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Ite
1897
3488
  * Create a record from an array of items using callbacks
1898
3489
  *
1899
3490
  * If multiple items have the same key, the latest item will be used
3491
+ *
1900
3492
  * @param array Array to convert
1901
3493
  * @param key Callback to get an item's grouping key
1902
3494
  * @param value Callback to get an item's value
1903
3495
  * @returns Record of keyed values
3496
+ *
3497
+ * @example
3498
+ * ```typescript
3499
+ * toRecord(
3500
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3501
+ * item => item.value,
3502
+ * item => item.id,
3503
+ * ); // => { 10: 3, 20: 2 }
3504
+ * ```
1904
3505
  */
1905
3506
  declare function toRecord<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>>;
1906
3507
  /**
1907
3508
  * Create a record from an array of items using a callback and value
1908
3509
  *
1909
3510
  * If multiple items have the same key, the latest item will be used
3511
+ *
1910
3512
  * @param array Array to convert
1911
3513
  * @param callback Callback to get an item's grouping key
1912
3514
  * @param value Key to use for value
1913
3515
  * @returns Record with keys
3516
+ *
3517
+ * @example
3518
+ * ```typescript
3519
+ * toRecord(
3520
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3521
+ * item => item.value,
3522
+ * 'id',
3523
+ * ); // => { 10: 3, 20: 2 }
3524
+ * ```
1914
3525
  */
1915
3526
  declare function toRecord<Item extends PlainObject, Callback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], callback: Callback, value: ItemValue): Record<ReturnType<Callback>, Item[ItemValue]>;
1916
3527
  /**
1917
3528
  * Create a record from an array of items using a key and callback
1918
3529
  *
1919
3530
  * If multiple items have the same key, the latest item will be used
3531
+ *
1920
3532
  * @param array Array to convert
1921
3533
  * @param key Key to use for grouping
1922
3534
  * @param callback Callback to get an item's value
1923
3535
  * @returns Record with keys
3536
+ *
3537
+ * @example
3538
+ * ```typescript
3539
+ * toRecord(
3540
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3541
+ * 'value',
3542
+ * item => item.id,
3543
+ * ); // => { 10: 3, 20: 2 }
3544
+ * ```
1924
3545
  */
1925
3546
  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>>>;
1926
3547
  /**
1927
3548
  * Create a record from an array of items using a key and value
1928
3549
  *
1929
3550
  * If multiple items have the same key, the latest item will be used
3551
+ *
1930
3552
  * @param array Array to convert
1931
3553
  * @param key Key to use for grouping
1932
3554
  * @param value Key to use for value
1933
3555
  * @returns Record of keyed values
3556
+ *
3557
+ * @example
3558
+ * ```typescript
3559
+ * toRecord(
3560
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3561
+ * 'value',
3562
+ * 'id',
3563
+ * ); // => { 10: 3, 20: 2 }
3564
+ * ```
1934
3565
  */
1935
3566
  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]>>;
1936
3567
  /**
1937
3568
  * Create a record from an array of items using a callback
1938
3569
  *
1939
3570
  * If multiple items have the same key, the latest item will be used
3571
+ *
1940
3572
  * @param array Array to convert
1941
3573
  * @param callback Callback to get an item's grouping key
1942
3574
  * @returns Record of keyed values
3575
+ *
3576
+ * @example
3577
+ * ```typescript
3578
+ * toRecord(
3579
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3580
+ * item => item.value,
3581
+ * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
3582
+ * ```
1943
3583
  */
1944
3584
  declare function toRecord<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
1945
3585
  /**
1946
3586
  * Create a record from an array of items using a key
1947
3587
  *
1948
3588
  * If multiple items have the same key, the latest item will be used
3589
+ *
1949
3590
  * @param array Array to convert
1950
3591
  * @param key Key to use for grouping
1951
3592
  * @returns Record of keyed values
3593
+ *
3594
+ * @example
3595
+ * ```typescript
3596
+ * toRecord(
3597
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3598
+ * 'value',
3599
+ * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
3600
+ * ```
1952
3601
  */
1953
3602
  declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
1954
3603
  /**
1955
3604
  * Create a record from an array of items _(using indices as keys)_
3605
+ *
1956
3606
  * @param array Array to convert
1957
3607
  * @returns Record of indiced values
3608
+ *
3609
+ * @example
3610
+ * ```typescript
3611
+ * toRecord(
3612
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3613
+ * ); // => { 0: {id: 1, value: 10}, 1: {id: 2, value: 20}, 2: {id: 3, value: 10} }
3614
+ * ```
1958
3615
  */
1959
3616
  declare function toRecord<Item>(array: Item[]): Record<number, Item>;
1960
3617
  declare namespace toRecord {
@@ -1964,68 +3621,134 @@ declare namespace toRecord {
1964
3621
  * Create a record from an array of items using callbacks, grouping values into arrays
1965
3622
  *
1966
3623
  * Available as `toRecordArrays` and `toRecord.arrays`
3624
+ *
1967
3625
  * @param array Array to convert
1968
3626
  * @param key Callback to get an item's grouping key
1969
3627
  * @param value Callback to get an item's value
1970
3628
  * @returns Record of keyed arrays of values
3629
+ *
3630
+ * @example
3631
+ * ```typescript
3632
+ * toRecordArrays(
3633
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3634
+ * item => item.value,
3635
+ * item => item.id,
3636
+ * ); // => { 10: [1, 3], 20: [2] }
3637
+ * ```
1971
3638
  */
1972
3639
  declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback>[]>;
1973
3640
  /**
1974
3641
  * Create a record from an array of items using a callback and value, grouping values into arrays
1975
3642
  *
1976
3643
  * Available as `toRecordArrays` and `toRecord.arrays`
3644
+ *
1977
3645
  * @param array Array to convert
1978
3646
  * @param callback Callback to get an item's grouping key
1979
3647
  * @param value Key to use for value
1980
3648
  * @returns Record of keyed arrays of values
3649
+ *
3650
+ * @example
3651
+ * ```typescript
3652
+ * toRecordArrays(
3653
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3654
+ * item => item.value,
3655
+ * 'id',
3656
+ * ); // => { 10: [1, 3], 20: [2] }
3657
+ * ```
1981
3658
  */
1982
3659
  declare function toRecordArrays<Item extends PlainObject, Callback extends (item: Item, index: number, array: Item[]) => Key$1, ItemValue extends keyof Item>(array: Item[], callback: Callback, value: ItemValue): Record<ReturnType<Callback>, Item[ItemValue][]>;
1983
3660
  /**
1984
3661
  * Create a record from an array of items using a key and callback, grouping values into arrays
1985
3662
  *
1986
3663
  * Available as `toRecordArrays` and `toRecord.arrays`
3664
+ *
1987
3665
  * @param array Array to convert
1988
3666
  * @param key Key to use for grouping
1989
3667
  * @param callback Callback to get an item's value
1990
3668
  * @returns Record of keyed arrays of values
3669
+ *
3670
+ * @example
3671
+ * ```typescript
3672
+ * toRecordArrays(
3673
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3674
+ * 'value',
3675
+ * item => item.id,
3676
+ * ); // => { 10: [1, 3], 20: [2] }
3677
+ * ```
1991
3678
  */
1992
3679
  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>[]>>;
1993
3680
  /**
1994
3681
  * Create a record from an array of items using a key and value, grouping values into arrays
1995
3682
  *
1996
3683
  * Available as `toRecordArrays` and `toRecord.arrays`
3684
+ *
1997
3685
  * @param array Array to convert
1998
3686
  * @param key Key to use for grouping
1999
3687
  * @param value Key to use for value
2000
3688
  * @returns Record of keyed arrays of values
3689
+ *
3690
+ * @example
3691
+ * ```typescript
3692
+ * toRecordArrays(
3693
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3694
+ * 'value',
3695
+ * 'id',
3696
+ * ); // => { 10: [1, 3], 20: [2] }
3697
+ * ```
2001
3698
  */
2002
3699
  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][]>>;
2003
3700
  /**
2004
3701
  * Create a record from an array of items using a callback, grouping items into arrays
2005
3702
  *
2006
3703
  * Available as `toRecordArrays` and `toRecord.arrays`
3704
+ *
2007
3705
  * @param array Array to convert
2008
3706
  * @param callback Callback to get an item's grouping key
2009
3707
  * @returns Record of keyed arrays of items
3708
+ *
3709
+ * @example
3710
+ * ```typescript
3711
+ * toRecordArrays(
3712
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3713
+ * item => item.value,
3714
+ * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
3715
+ * ```
2010
3716
  */
2011
3717
  declare function toRecordArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
2012
3718
  /**
2013
3719
  * Create a record from an array of items using a key, grouping items into arrays
2014
3720
  *
2015
3721
  * Available as `toRecordArrays` and `toRecord.arrays`
3722
+ *
2016
3723
  * @param array Array to convert
2017
3724
  * @param key Key to use for grouping
2018
3725
  * @returns Record of keyed arrays of items
3726
+ *
3727
+ * @example
3728
+ * ```typescript
3729
+ * toRecordArrays(
3730
+ * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3731
+ * 'value',
3732
+ * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
3733
+ * ```
2019
3734
  */
2020
3735
  declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
2021
3736
  //#endregion
2022
3737
  //#region src/function/assert.d.ts
3738
+ /**
3739
+ * Asserter for a nested property of a value
3740
+ */
3741
+ type AssertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted extends NestedPick<Value, Path> = NestedPick<Value, Path>> = Asserter<Asserted>;
3742
+ /**
3743
+ * A function that asserts a value is of a specific type, throwing an error if it is not
3744
+ */
2023
3745
  type Asserter<Value> = (value: unknown) => asserts value is Value;
3746
+ type NestedPick<Value, Path extends string> = Value extends PlainObject ? Path extends `${infer Head}.${infer Rest}` ? Head extends keyof Value ? { [Key in Head]: NestedPick<Value[Key], Rest> } : never : Path extends keyof Value ? { [Key in Path]: Value[Key] } : never : never;
2024
3747
  /**
2025
3748
  * Asserts that a condition is true, throwing an error if it is not
2026
3749
  * @param condition Condition to assert
2027
3750
  * @param message Error message
2028
- * @param error Error constructor
3751
+ * @param error Error constructor _(defaults to `Error`)_
2029
3752
  */
2030
3753
  declare function assert<Condition extends () => boolean>(condition: Condition, message: string, error?: ErrorConstructor): asserts condition;
2031
3754
  declare namespace assert {
@@ -2033,6 +3756,7 @@ declare namespace assert {
2033
3756
  var defined: typeof assertDefined;
2034
3757
  var instanceOf: typeof assertInstanceOf;
2035
3758
  var is: typeof assertIs;
3759
+ var property: typeof assertProperty;
2036
3760
  }
2037
3761
  /**
2038
3762
  * Creates an asserter that asserts a condition is true, throwing an error if it is not
@@ -2040,25 +3764,26 @@ declare namespace assert {
2040
3764
  * Available as `assertCondition` and `assert.condition`
2041
3765
  * @param condition Condition to assert
2042
3766
  * @param message Error message
2043
- * @param error Error constructor
3767
+ * @param error Error constructor _(defaults to `Error`)_
2044
3768
  * @returns Asserter
2045
3769
  */
2046
3770
  declare function assertCondition<Value>(condition: (value: unknown) => boolean, message: string, error?: ErrorConstructor): Asserter<Value>;
2047
3771
  /**
2048
- * Asserts that a value is defined throwing an error if it is not
3772
+ * Asserts that a value is defined, throwing an error if it is not
2049
3773
  *
2050
3774
  * Available as `assertDefined` and `assert.defined`
2051
3775
  * @param value Value to assert
2052
3776
  * @param message Error message
3777
+ * @param error Error constructor _(defaults to `Error`)_
2053
3778
  */
2054
- declare function assertDefined<Value>(value: unknown, message?: string): asserts value is Exclude<Value, null | undefined>;
3779
+ declare function assertDefined<Value>(value: unknown, message?: string, error?: ErrorConstructor): asserts value is Exclude<Value, null | undefined>;
2055
3780
  /**
2056
3781
  * Creates an asserter that asserts a value is an instance of a constructor, throwing an error if it is not
2057
3782
  *
2058
3783
  * Available as `assertInstanceOf` and `assert.instanceOf`
2059
3784
  * @param constructor Constructor to check against
2060
3785
  * @param message Error message
2061
- * @param error Error constructor
3786
+ * @param error Error constructor _(defaults to `Error`)_
2062
3787
  * @returns Asserter
2063
3788
  */
2064
3789
  declare function assertInstanceOf<Value>(constructor: Constructor<Value>, message: string, error?: ErrorConstructor): Asserter<Value>;
@@ -2068,10 +3793,21 @@ declare function assertInstanceOf<Value>(constructor: Constructor<Value>, messag
2068
3793
  * Available as `assertIs` and `assert.is`
2069
3794
  * @param condition Type guard function to check the value
2070
3795
  * @param message Error message
2071
- * @param error Error constructor
3796
+ * @param error Error constructor _(defaults to `Error`)_
2072
3797
  * @returns Asserter
2073
3798
  */
2074
3799
  declare function assertIs<Value>(condition: (value: unknown) => value is Value, message: string, error?: ErrorConstructor): Asserter<Value>;
3800
+ /**
3801
+ * Creates an asserter that asserts a property of a value exists and satisfies a condition, throwing an error if it does not
3802
+ *
3803
+ * Available as `assertProperty` and `assert.property`
3804
+ * @param path Path to the property to check, e.g., `foo.bar.baz` for a nested property
3805
+ * @param condition Condition to assert for the property
3806
+ * @param message Error message
3807
+ * @param error Error constructor _(defaults to `Error`)_
3808
+ * @returns Asserter
3809
+ */
3810
+ declare function assertProperty<Value extends PlainObject, Path extends NestedKeys<Value>, Asserted = NestedPick<Value, Path>>(path: Path, condition: (value: NestedValue<Value, Path>) => boolean, message: string, error?: ErrorConstructor): Asserter<Asserted>;
2075
3811
  //#endregion
2076
3812
  //#region src/internal/function/misc.d.ts
2077
3813
  /**
@@ -2080,6 +3816,9 @@ declare function assertIs<Value>(condition: (value: unknown) => value is Value,
2080
3816
  declare function noop(): void;
2081
3817
  //#endregion
2082
3818
  //#region src/function/memoize.d.ts
3819
+ /**
3820
+ * A memoized function, caching and retrieving results based on the its parameters _(or a custom cache key)_
3821
+ */
2083
3822
  declare class Memoized<Callback extends GenericCallback> {
2084
3823
  #private;
2085
3824
  /**
@@ -2219,6 +3958,9 @@ declare namespace once {
2219
3958
  }
2220
3959
  //#endregion
2221
3960
  //#region src/function/retry.d.ts
3961
+ /**
3962
+ * An error thrown when a retry fails
3963
+ */
2222
3964
  declare class RetryError extends Error {
2223
3965
  readonly original: unknown;
2224
3966
  constructor(message: string, original: unknown);
@@ -2672,6 +4414,7 @@ declare function tryEncode(value: boolean | number | string): unknown;
2672
4414
  declare function words(value: string): string[];
2673
4415
  //#endregion
2674
4416
  //#region src/internal/value/compare.d.ts
4417
+ type Comparator<Value = any> = (first: Value, second: Value) => number;
2675
4418
  /**
2676
4419
  * Compare two values _(for sorting purposes)_
2677
4420
  * @param first First value
@@ -2702,7 +4445,7 @@ declare function deregisterComparator<Instance>(constructor: Constructor<Instanc
2702
4445
  * @param constructor Class constructor
2703
4446
  * @param handler Method name or comparison function _(defaults to `compare`)_
2704
4447
  */
2705
- declare function registerComparator<Instance>(constructor: Constructor<Instance>, handler?: string | ((first: Instance, second: Instance) => number)): void;
4448
+ declare function registerComparator<Instance>(constructor: Constructor<Instance>, handler?: string | Comparator<Instance>): void;
2706
4449
  //#endregion
2707
4450
  //#region src/internal/value/equal.d.ts
2708
4451
  /**
@@ -2722,6 +4465,11 @@ type EqualOptions = {
2722
4465
  */
2723
4466
  relaxedNullish?: boolean;
2724
4467
  };
4468
+ /**
4469
+ * An equalizer function for comparing values for equality, with predefined options
4470
+ *
4471
+ * Can be used to compare values, and register or deregister equality comparison handlers for specific classes
4472
+ */
2725
4473
  type Equalizer = {
2726
4474
  /**
2727
4475
  * Are two strings equal?
@@ -2803,16 +4551,38 @@ declare function registerEqualizer<Instance>(constructor: Constructor<Instance>,
2803
4551
  //#region src/internal/value/get.d.ts
2804
4552
  /**
2805
4553
  * Get the value from an object using a known path
4554
+ *
4555
+ * @example
4556
+ * ```typescript
4557
+ * const data = {foo: {bar: {baz: 42}}};
4558
+ *
4559
+ * getValue(data, 'foo'); // {bar: {baz: 42}}
4560
+ * getValue(data, 'foo.bar'); // {baz: 42}
4561
+ * getValue(data, 'foo.bar.baz'); // 42
4562
+ * getValue(data, 'foo.nope'); // undefined
4563
+ * ```
4564
+ *
2806
4565
  * @param data Object to get value from
2807
- * @param path Path for value, e.g., `foo.bar.baz`
4566
+ * @param path Path for value
2808
4567
  * @returns Found value, or `undefined`
2809
4568
  */
2810
- declare function getValue<Data extends PlainObject, Path extends NestedKeys<Data>>(data: Data, path: Path): NestedValue<Data, ToString<Path>>;
4569
+ declare function getValue<Data extends PlainObject, Path extends NestedKeys<Data>>(data: Data, path: Path): NestedValue<Data, Path>;
2811
4570
  /**
2812
4571
  * Get the value from an object using an unknown path
4572
+ *
4573
+ * @example
4574
+ * ```typescript
4575
+ * const data = {foo: {bar: {baz: 42}}};
4576
+ *
4577
+ * getValue(data, 'foo'); // {bar: {baz: 42}}
4578
+ * getValue(data, 'foo.bar'); // {baz: 42}
4579
+ * getValue(data, 'Foo.Bar.Baz', true); // 42
4580
+ * getValue(data, 'foo.nope'); // undefined
4581
+ * ```
4582
+ *
2813
4583
  * @param data Object to get value from
2814
- * @param path Path for value, e.g., `foo.bar.baz`
2815
- * @param ignoreCase If `true`, the path matching is case-insensitive
4584
+ * @param path Path for value
4585
+ * @param ignoreCase If `true`, path matching is case-insensitive
2816
4586
  * @returns Found value, or `undefined`
2817
4587
  */
2818
4588
  declare function getValue<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): unknown;
@@ -2822,7 +4592,7 @@ declare function getValue<Data extends PlainObject>(data: Data, path: string, ig
2822
4592
  * Check if a nested property is defined in an object
2823
4593
  * @param data Object to check in
2824
4594
  * @param path Path for property
2825
- * @return `true` if the property exists, `false` otherwise
4595
+ * @returns `true` if the property exists, `false` otherwise
2826
4596
  */
2827
4597
  declare function hasValue<Data extends PlainObject, Path extends NestedKeys<Data>>(data: Data, path: Path): boolean;
2828
4598
  /**
@@ -2830,7 +4600,7 @@ declare function hasValue<Data extends PlainObject, Path extends NestedKeys<Data
2830
4600
  * @param data Object to check in
2831
4601
  * @param path Path for property
2832
4602
  * @param ignoreCase If `true`, the path matching is case-insensitive
2833
- * @return `true` if the property exists, `false` otherwise
4603
+ * @returns `true` if the property exists, `false` otherwise
2834
4604
  */
2835
4605
  declare function hasValue<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): boolean;
2836
4606
  declare namespace hasValue {
@@ -2843,9 +4613,9 @@ declare namespace hasValue {
2843
4613
  * @param data Object to check in
2844
4614
  * @param path Path for property
2845
4615
  * @param ignoreCase If `true`, the path matching is case-insensitive
2846
- * @return Result object
4616
+ * @returns Result object
2847
4617
  */
2848
- declare function hasValueResult<Data extends PlainObject, Path extends NestedKeys<Data>>(data: Data, path: Path, ignoreCase?: boolean): Result<NestedValue<Data, ToString<Path>>, undefined>;
4618
+ declare function hasValueResult<Data extends PlainObject, Path extends NestedKeys<Data>>(data: Data, path: Path, ignoreCase?: boolean): Result<NestedValue<Data, ToString<Path>>, string>;
2849
4619
  /**
2850
4620
  * Check if a nested property is defined in an object, and get its value if it is
2851
4621
  *
@@ -2853,9 +4623,9 @@ declare function hasValueResult<Data extends PlainObject, Path extends NestedKey
2853
4623
  * @param data Object to check in
2854
4624
  * @param path Path for property
2855
4625
  * @param ignoreCase If `true`, the path matching is case-insensitive
2856
- * @return Result object
4626
+ * @returns Result object
2857
4627
  */
2858
- declare function hasValueResult<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): Result<unknown, undefined>;
4628
+ declare function hasValueResult<Data extends PlainObject>(data: Data, path: string, ignoreCase?: boolean): Result<unknown, string>;
2859
4629
  //#endregion
2860
4630
  //#region src/internal/value/set.d.ts
2861
4631
  /**
@@ -3317,7 +5087,7 @@ declare function inMap<Value>(map: Map<unknown, Value>, value: Value): boolean;
3317
5087
  * @param map Map to check in
3318
5088
  * @param value Value to check for
3319
5089
  * @param key To return the key for the value
3320
- * @return The key for the value if it exists, otherwise `undefined`
5090
+ * @returns The key for the value if it exists, otherwise `undefined`
3321
5091
  */
3322
5092
  declare function inMap<Key, Value>(map: Map<Key, Value>, value: Value, key: true): Key;
3323
5093
  /**
@@ -3431,6 +5201,9 @@ declare function omit<Value extends PlainObject, ValueKey extends keyof Value>(v
3431
5201
  declare function pick<Value extends PlainObject, ValueKey extends keyof Value>(value: Value, keys: ValueKey[]): Pick<Value, ValueKey>;
3432
5202
  //#endregion
3433
5203
  //#region src/value/shake.d.ts
5204
+ /**
5205
+ * A shaken object, without any `undefined` values
5206
+ */
3434
5207
  type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Key] extends undefined ? never : Value[Key] };
3435
5208
  /**
3436
5209
  * Shake an object, removing all keys with `undefined` values
@@ -3440,6 +5213,9 @@ type Shaken<Value extends PlainObject> = { [Key in keyof Value]: Value[Key] exte
3440
5213
  declare function shake<Value extends PlainObject>(value: Value): Shaken<Value>;
3441
5214
  //#endregion
3442
5215
  //#region src/value/smush.d.ts
5216
+ /**
5217
+ * A smushed object, with all nested objects flattened into a single level, using dot notation keys
5218
+ */
3443
5219
  type Smushed<Value extends PlainObject> = Simplify<{ [NestedKey in NestedKeys<Value>]: NestedValue<Value, ToString<NestedKey>> }>;
3444
5220
  /**
3445
5221
  * Smush an object into a flat object that uses dot notation keys
@@ -3454,9 +5230,8 @@ declare function smush<Value extends PlainObject>(value: Value): Smushed<Value>;
3454
5230
  */
3455
5231
  type KeysOfUnion<ObjectType> = keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
3456
5232
  /**
3457
- * Thanks, type-fest!
5233
+ * An unsmushed object, with all dot notation keys turned into nested keys
3458
5234
  */
3459
- type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
3460
5235
  type Unsmushed<Value extends PlainObject> = Simplify<Omit<{ [UnionKey in KeysOfUnion<Value>]: Value[UnionKey] }, `${string}.${string}`>>;
3461
5236
  /**
3462
5237
  * Unsmush a smushed object _(turning dot notation keys into nested keys)_
@@ -3470,13 +5245,16 @@ declare function unsmush<Value extends PlainObject>(value: Value): Unsmushed<Val
3470
5245
  * Options for assigning values
3471
5246
  */
3472
5247
  type AssignOptions = Omit<MergeOptions, 'assignValues'>;
3473
- /**
3474
- * Assign values from multiple arrays or objects to the first one
3475
- * @param to Value to assign to
3476
- * @param from Values to assign
3477
- * @returns Assigned value
3478
- */
3479
- type Assigner<Model extends ArrayOrPlainObject = ArrayOrPlainObject> = (to: NestedPartial<Model>, from: NestedPartial<Model>[]) => Model;
5248
+ type Assigner = {
5249
+ /**
5250
+ * Assign values from one or more objects to the first one
5251
+ *
5252
+ * @param to Value to assign to
5253
+ * @param from Values to assign
5254
+ * @returns Assigned value
5255
+ */
5256
+ <To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From]): To & UnionToIntersection<From[number]>;
5257
+ };
3480
5258
  /**
3481
5259
  * Options for merging values
3482
5260
  */
@@ -3510,20 +5288,24 @@ type MergeOptions = {
3510
5288
  */
3511
5289
  skipNullableInArrays?: boolean;
3512
5290
  };
5291
+ type Merger = {
5292
+ /**
5293
+ * Merge multiple arrays or objects into a single one
5294
+ *
5295
+ * @param values Values to merge
5296
+ * @returns Merged value
5297
+ */
5298
+ <Values extends ArrayOrPlainObject[]>(values: NestedPartial<Values[number]>[]): UnionToIntersection<Values[number]>;
5299
+ };
3513
5300
  /**
3514
- * Merge multiple arrays or objects into a single one
3515
- * @param values Values to merge
3516
- * @returns Merged value
3517
- */
3518
- type Merger<Model extends ArrayOrPlainObject = ArrayOrPlainObject> = (values: NestedPartial<Model>[]) => Model;
3519
- /**
3520
- * Assign values from multiple arrays or objects to the first one
5301
+ * Assign values from one or more objects to the first one
5302
+ *
3521
5303
  * @param to Value to assign to
3522
5304
  * @param from Values to assign
3523
5305
  * @param options Assigning options
3524
5306
  * @returns Assigned value
3525
5307
  */
3526
- declare function assign<Model extends ArrayOrPlainObject>(to: NestedPartial<Model>, from: NestedPartial<Model>[], options?: AssignOptions): Model;
5308
+ declare function assign<To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From], options?: AssignOptions): To & UnionToIntersection<From[number]>;
3527
5309
  declare namespace assign {
3528
5310
  var initialize: typeof initializeAssigner;
3529
5311
  }
@@ -3531,39 +5313,44 @@ declare namespace assign {
3531
5313
  * Create an assigner with predefined options
3532
5314
  *
3533
5315
  * Available as `initializeAssigner` and `assign.initialize`
5316
+ *
3534
5317
  * @param options Assigning options
3535
5318
  * @returns Assigner function
3536
5319
  */
3537
- declare function initializeAssigner<Model extends ArrayOrPlainObject>(options?: AssignOptions): Assigner<Model>;
5320
+ declare function initializeAssigner(options?: AssignOptions): Assigner;
3538
5321
  /**
3539
5322
  * Create a merger with predefined options
3540
5323
  *
3541
5324
  * Available as `initializeMerger` and `merge.initialize`
5325
+ *
3542
5326
  * @param options Merging options
3543
5327
  * @returns Merger function
3544
5328
  */
3545
5329
  declare function initializeMerger(options?: MergeOptions): Merger;
3546
5330
  /**
3547
5331
  * Merge multiple arrays or objects into a single one
5332
+ *
3548
5333
  * @param values Values to merge
3549
5334
  * @param options Merging options
3550
5335
  * @returns Merged value
3551
5336
  */
3552
- declare function merge<Model extends ArrayOrPlainObject>(values: NestedPartial<Model>[], options?: MergeOptions): Model;
3553
- /**
3554
- * Merge multiple arrays or objects into a single one
3555
- * @param values Values to merge
3556
- * @param options Merging options
3557
- * @returns Merged value
3558
- */
3559
- declare function merge(values: NestedPartial<ArrayOrPlainObject>[], options?: MergeOptions): ArrayOrPlainObject;
5337
+ declare function merge<Values extends ArrayOrPlainObject[]>(values: [...Values], options?: MergeOptions): UnionToIntersection<Values[number]>;
3560
5338
  declare namespace merge {
3561
5339
  var initialize: typeof initializeMerger;
3562
5340
  }
3563
5341
  //#endregion
3564
5342
  //#region src/value/transform.d.ts
5343
+ /**
5344
+ * A callback transform an object's properties
5345
+ */
3565
5346
  type TransformCallback<Value extends PlainObject, Key extends keyof Value> = (key: Key, value: Value[Key]) => Value[Key];
5347
+ /**
5348
+ * A collection of keyed callbacks to transform an object's properties
5349
+ */
3566
5350
  type TransformCallbacks<Value extends PlainObject> = Partial<{ [Key in keyof Value]: (value: Value[Key]) => Value[Key] }>;
5351
+ /**
5352
+ * A transformer function for an object, with predefined callbacks for transforming its properties
5353
+ */
3567
5354
  type Transformer<Value extends PlainObject> = {
3568
5355
  (value: Value): Value;
3569
5356
  };
@@ -3580,7 +5367,7 @@ declare function initializeTransformer<Value extends PlainObject>(transform: Tra
3580
5367
  *
3581
5368
  * Available as `initializeTransformer` and `transform.initialize`
3582
5369
  * @param transformers Keyed transformer functions
3583
- * @return Transformer
5370
+ * @returns Transformer
3584
5371
  */
3585
5372
  declare function initializeTransformer<Value extends PlainObject>(transformers: TransformCallbacks<Value>): Transformer<Value>;
3586
5373
  /**
@@ -3602,6 +5389,9 @@ declare namespace transform {
3602
5389
  }
3603
5390
  //#endregion
3604
5391
  //#region src/beacon.d.ts
5392
+ /**
5393
+ * A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
5394
+ */
3605
5395
  declare class Beacon<Value> {
3606
5396
  #private;
3607
5397
  /**
@@ -3651,6 +5441,9 @@ type BeaconOptions<Value> = {
3651
5441
  */
3652
5442
  equal?: (first: Value, second: Value) => boolean;
3653
5443
  };
5444
+ /**
5445
+ * An observable holds a value and allows observers to subscribe to changes in that value
5446
+ */
3654
5447
  declare class Observable<Value> {
3655
5448
  #private;
3656
5449
  constructor(instance: Beacon<Value>, observers: Map<Subscription<Value>, Observer<Value>>);
@@ -3678,6 +5471,9 @@ type ObservableState<Value> = {
3678
5471
  closed: boolean;
3679
5472
  observers: Map<Subscription<Value>, Observer<Value>>;
3680
5473
  };
5474
+ /**
5475
+ * An observer receives notifications from an observable
5476
+ */
3681
5477
  type Observer<Value> = {
3682
5478
  /**
3683
5479
  * Callback for when the observable is completed
@@ -3692,6 +5488,9 @@ type Observer<Value> = {
3692
5488
  */
3693
5489
  next?: (value: Value) => void;
3694
5490
  };
5491
+ /**
5492
+ * A subscription represents an active subscription to an observable, holding its state and allowing it to be destroyed or unsubscribed from
5493
+ */
3695
5494
  declare class Subscription<Value> {
3696
5495
  #private;
3697
5496
  constructor(state: ObservableState<Value>);
@@ -3720,22 +5519,60 @@ declare function beacon<Value>(value: Value, options?: BeaconOptions<Value>): Be
3720
5519
  type ColorWithAlpha = {
3721
5520
  alpha: number;
3722
5521
  };
5522
+ /**
5523
+ * An _HSL_-color with an alpha channel
5524
+ */
3723
5525
  type HSLAColor = HSLColor & ColorWithAlpha;
5526
+ /**
5527
+ * An _HSL_-color
5528
+ */
3724
5529
  type HSLColor = {
5530
+ /**
5531
+ * Hue of the color _(in degrees; 0-360)_
5532
+ */
3725
5533
  hue: number;
5534
+ /**
5535
+ * Lightness of the color _(in percentage; 0-100)_
5536
+ */
3726
5537
  lightness: number;
5538
+ /**
5539
+ * Saturation of the color _(in percentage; 0-100)_
5540
+ */
3727
5541
  saturation: number;
3728
5542
  };
5543
+ /**
5544
+ * An _RGB_-color with an alpha channel
5545
+ */
3729
5546
  type RGBAColor = RGBColor & ColorWithAlpha;
5547
+ /**
5548
+ * An _RGB_-color
5549
+ */
3730
5550
  type RGBColor = {
5551
+ /**
5552
+ * Blue channel of the color _(in hexadecimal; 0-255)_
5553
+ */
3731
5554
  blue: number;
5555
+ /**
5556
+ * Green channel of the color _(in hexadecimal; 0-255)_
5557
+ */
3732
5558
  green: number;
5559
+ /**
5560
+ * Red channel of the color _(in hexadecimal; 0-255)_
5561
+ */
3733
5562
  red: number;
3734
5563
  };
3735
5564
  //#endregion
3736
5565
  //#region src/color/instance.d.ts
5566
+ /**
5567
+ * A color that is represented in multiple color formats
5568
+ */
3737
5569
  declare class Color {
3738
5570
  #private;
5571
+ /**
5572
+ * A property to identify this as a Color instance, used for type checking
5573
+ *
5574
+ * @internal
5575
+ */
3739
5576
  private readonly $color;
3740
5577
  /**
3741
5578
  * Get the alpha channel
@@ -4135,6 +5972,11 @@ declare function isNumerical(value: unknown): value is number | `${number}`;
4135
5972
  declare function isObject(value: unknown): value is object;
4136
5973
  //#endregion
4137
5974
  //#region src/logger.d.ts
5975
+ /**
5976
+ * A logger that can be used to log messages to the console
5977
+ *
5978
+ * _(Logging can be enabled or disabled by setting the `enabled` property)_
5979
+ */
4138
5980
  declare class Logger {
4139
5981
  /**
4140
5982
  * Log any number of values at the "debug" log level
@@ -4183,8 +6025,14 @@ declare class Logger {
4183
6025
  */
4184
6026
  time(label: string): Time;
4185
6027
  }
6028
+ /**
6029
+ * A named timer that can be used to log durations to the console
6030
+ */
4186
6031
  declare class Time {
4187
6032
  #private;
6033
+ /**
6034
+ * Is the timer active? _(i.e. has it been started and not stopped, and is logging enabled?)_
6035
+ */
4188
6036
  get active(): boolean;
4189
6037
  /**
4190
6038
  * Log the current duration of the timer _(ignored if logging is disabled)_
@@ -4203,6 +6051,17 @@ declare const logger: Logger;
4203
6051
  //#region src/internal/math/aggregate.d.ts
4204
6052
  /**
4205
6053
  * Get the maximum value from a list of items
6054
+ *
6055
+ * @example
6056
+ * ```typescript
6057
+ * max(
6058
+ * [{id: 1, value: 10}, {id: 2, value: 20}],
6059
+ * item => item.value,
6060
+ * ); // 20
6061
+ *
6062
+ * max([], item => item.value); // Number.NaN
6063
+ * ```
6064
+ *
4206
6065
  * @param items List of items
4207
6066
  * @param callback Callback to get an item's value
4208
6067
  * @returns Maximum value, or `NaN` if no maximum can be found
@@ -4210,6 +6069,17 @@ declare const logger: Logger;
4210
6069
  declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
4211
6070
  /**
4212
6071
  * Get the maximum value from a list of items
6072
+ *
6073
+ * @example
6074
+ * ```typescript
6075
+ * max(
6076
+ * [{id: 1, value: 10}, {id: 2, value: 20}],
6077
+ * 'value',
6078
+ * ); // 20
6079
+ *
6080
+ * max([], 'value'); // Number.NaN
6081
+ * ```
6082
+ *
4213
6083
  * @param items List of items
4214
6084
  * @param key Key to use for value
4215
6085
  * @returns Maximum value, or `NaN` if no maximum can be found
@@ -4217,6 +6087,13 @@ declare function max<Item>(items: Item[], callback: (item: Item, index: number,
4217
6087
  declare function max<Item extends PlainObject, ItemKey extends keyof NumericalValues<Item>>(items: Item[], key: ItemKey): number;
4218
6088
  /**
4219
6089
  * Get the maximum value from a list of numbers
6090
+ *
6091
+ * @example
6092
+ * ```typescript
6093
+ * max([10, 20]); // 20
6094
+ * max([]); // Number.NaN
6095
+ * ```
6096
+ *
4220
6097
  * @param values List of numbers
4221
6098
  * @returns Maximum value, or `NaN` if no maximum can be found
4222
6099
  */
@@ -4373,6 +6250,9 @@ declare function clamp(value: number, minimum: number, maximum: number, loop?: b
4373
6250
  declare function getNumber(value: unknown): number;
4374
6251
  //#endregion
4375
6252
  //#region src/promise/models.d.ts
6253
+ /**
6254
+ * A promise that can be canceled
6255
+ */
4376
6256
  declare class CancelablePromise<Value = void> extends Promise<Value> {
4377
6257
  #private;
4378
6258
  constructor(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void);
@@ -4382,8 +6262,17 @@ declare class CancelablePromise<Value = void> extends Promise<Value> {
4382
6262
  */
4383
6263
  cancel(reason?: unknown): void;
4384
6264
  }
6265
+ /**
6266
+ * A promise that was fulfilled
6267
+ */
4385
6268
  type FulfilledPromise<Value> = {
6269
+ /**
6270
+ * Status of the promise
6271
+ */
4386
6272
  status: typeof PROMISE_TYPE_FULFILLED;
6273
+ /**
6274
+ * Value of the promise
6275
+ */
4387
6276
  value: Awaited<Value>;
4388
6277
  };
4389
6278
  type PromiseData = {
@@ -4394,6 +6283,9 @@ type PromiseHandlers = {
4394
6283
  resolve: (value: unknown[]) => void;
4395
6284
  reject: (reason: unknown) => void;
4396
6285
  };
6286
+ /**
6287
+ * Options for a promise-handling function
6288
+ */
4397
6289
  type PromiseOptions = {
4398
6290
  /**
4399
6291
  * AbortSignal for aborting the promise; when aborted, the promise will reject with the reason of the signal
@@ -4422,20 +6314,41 @@ type PromiseParameters = {
4422
6314
  * - Returns an array of values
4423
6315
  */
4424
6316
  type PromiseStrategy = 'complete' | 'first';
6317
+ /**
6318
+ * An error thrown when a promise times out
6319
+ */
4425
6320
  declare class PromiseTimeoutError extends Error {
4426
6321
  constructor();
4427
6322
  }
4428
6323
  type PromisesItems<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]> };
6324
+ /**
6325
+ * Options for handling multiple promises
6326
+ */
4429
6327
  type PromisesOptions = {
6328
+ /**
6329
+ * AbortSignal for aborting the promises; when aborted, the promises will reject with the reason of the signal
6330
+ */
4430
6331
  signal?: AbortSignal;
6332
+ /**
6333
+ * Strategy for handling the promises; defaults to `complete`
6334
+ */
4431
6335
  strategy?: PromiseStrategy;
4432
6336
  };
4433
6337
  type PromisesResult<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never };
4434
6338
  type PromisesUnwrapped<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never };
4435
6339
  type PromisesValue<Value> = FulfilledPromise<Value> | RejectedPromise;
4436
6340
  type PromisesValues<Items extends unknown[]> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never : Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never };
6341
+ /**
6342
+ * A promise that was rejected
6343
+ */
4437
6344
  type RejectedPromise = {
6345
+ /**
6346
+ * Status of the promise
6347
+ */
4438
6348
  status: typeof PROMISE_TYPE_REJECTED;
6349
+ /**
6350
+ * Reason for the rejection
6351
+ */
4439
6352
  reason: unknown;
4440
6353
  };
4441
6354
  declare const PROMISE_ABORT_EVENT = "abort";
@@ -4469,8 +6382,6 @@ declare function delay(time?: number): Promise<void>;
4469
6382
  //#region src/promise/index.d.ts
4470
6383
  /**
4471
6384
  * Wrap a promise with safety handlers, with optional abort capabilities and timeout
4472
- *
4473
- * Available as `attemptPromise` and `attempt.promise`
4474
6385
  * @param promise Promise to wrap
4475
6386
  * @param options Options for the promise
4476
6387
  * @returns Wrapped promise
@@ -4478,8 +6389,6 @@ declare function delay(time?: number): Promise<void>;
4478
6389
  declare function attemptPromise<Value>(promise: Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
4479
6390
  /**
4480
6391
  * Wrap a promise-returning callback with safety handlers, with optional abort capabilities and timeout
4481
- *
4482
- * Available as `attemptPromise` and `attempt.promise`
4483
6392
  * @param callback Callback to wrap
4484
6393
  * @param options Options for the promise
4485
6394
  * @returns Promise-wrapped callback
@@ -4487,8 +6396,6 @@ declare function attemptPromise<Value>(promise: Promise<Value>, options?: Promis
4487
6396
  declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
4488
6397
  /**
4489
6398
  * Wrap a callback with a promise and safety handlers, with optional abort capabilities and timeout
4490
- *
4491
- * Available as `attemptPromise` and `attempt.promise`
4492
6399
  * @param callback Callback to wrap
4493
6400
  * @param options Options for the promise
4494
6401
  * @returns Promise-wrapped callback
@@ -4728,6 +6635,9 @@ declare function fromQuery(query: string): PlainObject;
4728
6635
  declare function toQuery(parameters: PlainObject): string;
4729
6636
  //#endregion
4730
6637
  //#region src/queue.d.ts
6638
+ /**
6639
+ * A queue that can be used to manage (a)synchronous tasks with a specific key
6640
+ */
4731
6641
  declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallback>, CallbackResult> {
4732
6642
  #private;
4733
6643
  /**
@@ -4818,6 +6728,9 @@ declare class KeyedQueue<CallbackParameters extends Parameters<GenericAsyncCallb
4818
6728
  */
4819
6729
  resume(key?: string): void;
4820
6730
  }
6731
+ /**
6732
+ * A queue that can be used to manage (a)synchronous tasks
6733
+ */
4821
6734
  declare class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>, CallbackResult> {
4822
6735
  #private;
4823
6736
  /**
@@ -4881,6 +6794,9 @@ declare class Queue<CallbackParameters extends Parameters<GenericAsyncCallback>,
4881
6794
  */
4882
6795
  resume(): void;
4883
6796
  }
6797
+ /**
6798
+ * An error thrown by the Queue when an operation fails
6799
+ */
4884
6800
  declare class QueueError extends Error {
4885
6801
  constructor(message: string);
4886
6802
  }
@@ -4898,9 +6814,12 @@ type QueueOptions = {
4898
6814
  */
4899
6815
  maximum?: number;
4900
6816
  };
6817
+ /**
6818
+ * A queued item
6819
+ */
4901
6820
  type Queued<Value> = {
4902
6821
  /**
4903
- * ID of the queued promise _(can be used to remove it from the queue)_
6822
+ * ID of the queued item _(can be used to remove it from the queue)_
4904
6823
  */
4905
6824
  readonly id: number;
4906
6825
  /**
@@ -4998,15 +6917,71 @@ declare function getRandomItems<Value>(array: Value[], amount: number): Value[];
4998
6917
  */
4999
6918
  declare function getRandomItems<Value>(array: Value[]): Value[];
5000
6919
  //#endregion
6920
+ //#region src/result/index.d.ts
6921
+ /**
6922
+ * Executes a promise, catching any errors, and returns a result
6923
+ *
6924
+ * Available as `asyncAttempt` and `attempt.async`
6925
+ * @param promise Promise to execute
6926
+ * @param error Error value
6927
+ * @returns Callback result
6928
+ */
6929
+ declare function asyncAttempt<Value, E>(promise: Promise<Value>, error: E): Promise<ExtendedResult<Awaited<Value>, E>>;
6930
+ /**
6931
+ * Executes a callback asynchronously, catching any errors, and returns a result
6932
+ *
6933
+ * Available as `asyncAttempt` and `attempt.async`
6934
+ * @param callback Callback to execute
6935
+ * @param error Error value
6936
+ * @returns Callback result
6937
+ */
6938
+ declare function asyncAttempt<Value, E>(callback: () => Promise<Value>, error: E): Promise<ExtendedResult<Awaited<Value>, E>>;
6939
+ /**
6940
+ * Executes a promise, catching any errors, and returns a result
6941
+ *
6942
+ * Available as `asyncAttempt` and `attempt.async`
6943
+ * @param promise Promise to execute
6944
+ * @returns Callback result
6945
+ */
6946
+ declare function asyncAttempt<Value>(promise: Promise<Value>): Promise<Result<Awaited<Value>>>;
6947
+ /**
6948
+ * Executes a callback asynchronously, catching any errors, and returns a result
6949
+ *
6950
+ * Available as `asyncAttempt` and `attempt.async`
6951
+ * @param callback Callback to execute
6952
+ * @returns Callback result
6953
+ */
6954
+ declare function asyncAttempt<Value>(callback: () => Promise<Value>): Promise<Result<Awaited<Value>>>;
6955
+ /**
6956
+ * Executes a callback, catching any errors, and returns a result
6957
+ * @param callback Callback to execute
6958
+ * @param error Error value
6959
+ * @returns Callback result
6960
+ */
6961
+ declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedResult<Value, E>;
6962
+ /**
6963
+ * Executes a callback, catching any errors, and returns a result
6964
+ * @param callback Callback to execute
6965
+ * @returns Callback result
6966
+ */
6967
+ declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
6968
+ declare namespace attempt {
6969
+ var async: typeof asyncAttempt;
6970
+ }
6971
+ //#endregion
5001
6972
  //#region src/result/match.d.ts
5002
6973
  /**
5003
6974
  * Handles a result with match callbacks
6975
+ *
6976
+ * Available as `asyncMatchResult` and `matchResult.async`
5004
6977
  * @param result Result to handle
5005
6978
  * @param handler Match callbacks
5006
6979
  */
5007
6980
  declare function asyncMatchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | Promise<AnyResult<Value, E>> | (() => Promise<AnyResult<Value, E>>), handler: ResultMatch<Value, Returned, E>): Promise<Returned>;
5008
6981
  /**
5009
6982
  * Handles a result with match callbacks
6983
+ *
6984
+ * Available as `asyncMatchResult` and `matchResult.async`
5010
6985
  * @param result Result to handle
5011
6986
  * @param ok Ok callback
5012
6987
  * @param error Error callback
@@ -5014,16 +6989,12 @@ declare function asyncMatchResult<Value, Returned, E = Error>(result: AnyResult<
5014
6989
  declare function asyncMatchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | Promise<AnyResult<Value, E>> | (() => Promise<AnyResult<Value, E>>), ok: ResultMatch<Value, Returned, E>['ok'], error: ResultMatch<Value, Returned, E>['error']): Promise<Returned>;
5015
6990
  /**
5016
6991
  * Handles a result with match callbacks
5017
- *
5018
- * Available as `matchResult` and `attempt.match`
5019
6992
  * @param result Result to handle
5020
6993
  * @param handler Match callbacks
5021
6994
  */
5022
6995
  declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | (() => AnyResult<Value, E>), handler: ResultMatch<Value, Returned, E>): Returned;
5023
6996
  /**
5024
6997
  * Handles a result with match callbacks
5025
- *
5026
- * Available as `matchResult` and `attempt.match`
5027
6998
  * @param result Result to handle
5028
6999
  * @param ok Ok callback
5029
7000
  * @param error Error callback
@@ -5045,168 +7016,144 @@ type AttemptFlowPromise<Callback extends GenericCallback, Value> = (...args: Par
5045
7016
  /**
5046
7017
  * Create an asynchronous Flow, a function that attempts to pipe a value through a series of functions
5047
7018
  *
5048
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7019
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5049
7020
  * @returns Flow function
5050
7021
  */
5051
7022
  declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn): AttemptFlowPromise<Fn, ReturnType<Fn>>;
5052
7023
  /**
5053
7024
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5054
7025
  *
5055
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7026
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5056
7027
  * @returns Flow function
5057
7028
  */
5058
7029
  declare function attemptAsyncFlow<First extends GenericCallback, Second>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second): AttemptFlowPromise<First, Second>;
5059
7030
  /**
5060
7031
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5061
7032
  *
5062
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7033
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5063
7034
  * @returns Flow function
5064
7035
  */
5065
7036
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third): AttemptFlowPromise<First, Third>;
5066
7037
  /**
5067
7038
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5068
7039
  *
5069
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7040
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5070
7041
  * @returns Flow function
5071
7042
  */
5072
7043
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth): AttemptFlowPromise<First, Fourth>;
5073
7044
  /**
5074
7045
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5075
7046
  *
5076
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7047
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5077
7048
  * @returns Flow function
5078
7049
  */
5079
7050
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth): AttemptFlowPromise<First, Fifth>;
5080
7051
  /**
5081
7052
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5082
7053
  *
5083
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7054
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5084
7055
  * @returns Flow function
5085
7056
  */
5086
7057
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth): AttemptFlowPromise<First, Sixth>;
5087
7058
  /**
5088
7059
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5089
7060
  *
5090
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7061
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5091
7062
  * @returns Flow function
5092
7063
  */
5093
7064
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh): AttemptFlowPromise<First, Seventh>;
5094
7065
  /**
5095
7066
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5096
7067
  *
5097
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7068
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5098
7069
  * @returns Flow function
5099
7070
  */
5100
7071
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth): AttemptFlowPromise<First, Eighth>;
5101
7072
  /**
5102
7073
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5103
7074
  *
5104
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7075
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5105
7076
  * @returns Flow function
5106
7077
  */
5107
7078
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth): AttemptFlowPromise<First, Ninth>;
5108
7079
  /**
5109
7080
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5110
7081
  *
5111
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7082
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5112
7083
  * @returns Flow function
5113
7084
  */
5114
7085
  declare function attemptAsyncFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: Awaited<UnwrapValue<ReturnType<First>>>) => Second, third: (value: Awaited<UnwrapValue<Second>>) => Third, fourth: (value: Awaited<UnwrapValue<Third>>) => Fourth, fifth: (value: Awaited<UnwrapValue<Fourth>>) => Fifth, sixth: (value: Awaited<UnwrapValue<Fifth>>) => Sixth, seventh: (value: Awaited<UnwrapValue<Sixth>>) => Seventh, eighth: (value: Awaited<UnwrapValue<Seventh>>) => Eighth, ninth: (value: Awaited<UnwrapValue<Eighth>>) => Ninth, tenth: (value: Awaited<UnwrapValue<Ninth>>) => Tenth): AttemptFlowPromise<First, Tenth>;
5115
7086
  /**
5116
7087
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5117
7088
  *
5118
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7089
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5119
7090
  * @returns Flow function
5120
7091
  */
5121
7092
  declare function attemptAsyncFlow<Fn extends GenericCallback>(fn: Fn, ...fns: Array<(value: Awaited<UnwrapValue<ReturnType<Fn>>>) => unknown>): AttemptFlowPromise<Fn, ReturnType<Fn>>;
5122
7093
  /**
5123
7094
  * Create an asynchronous Flow, a function that pipes values through a series of functions
5124
7095
  *
5125
- * Available as `attemptAsyncFlow` and `attempt.flow.async`
7096
+ * Available as `attemptAsyncFlow` and `attemptFlow.async`
5126
7097
  * @returns Flow function
5127
7098
  */
5128
7099
  declare function attemptAsyncFlow(...fns: GenericCallback[]): (...args: unknown[]) => Promise<Result<unknown>>;
5129
7100
  /**
5130
7101
  * Create a Flow, a function that attempts to pipe values through a function
5131
- *
5132
- * Available as `attemptFlow` and `attempt.flow`
5133
7102
  * @returns Flow function
5134
7103
  */
5135
7104
  declare function attemptFlow<Fn extends GenericCallback>(fn: Fn): AttemptFlow<Fn, ReturnType<Fn>>;
5136
7105
  /**
5137
7106
  * Create a Flow, a function that attempts to pipe values through a series of functions
5138
- *
5139
- * Available as `attemptFlow` and `attempt.flow`
5140
7107
  * @returns Flow function
5141
7108
  */
5142
7109
  declare function attemptFlow<First extends GenericCallback, Second>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second): AttemptFlow<First, Second>;
5143
7110
  /**
5144
7111
  * Create a Flow, a function that attempts to pipe values through a series of functions
5145
- *
5146
- * Available as `attemptFlow` and `attempt.flow`
5147
7112
  * @returns Flow function
5148
7113
  */
5149
7114
  declare function attemptFlow<First extends GenericCallback, Second, Third>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third): AttemptFlow<First, Third>;
5150
7115
  /**
5151
7116
  * Create a Flow, a function that attempts to pipe values through a series of functions
5152
- *
5153
- * Available as `attemptFlow` and `attempt.flow`
5154
7117
  * @returns Flow function
5155
7118
  */
5156
7119
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): AttemptFlow<First, Fourth>;
5157
7120
  /**
5158
7121
  * Create a Flow, a function that attempts to pipe values through a series of functions
5159
- *
5160
- * Available as `attemptFlow` and `attempt.flow`
5161
7122
  * @returns Flow function
5162
7123
  */
5163
7124
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): AttemptFlow<First, Fifth>;
5164
7125
  /**
5165
7126
  * Create a Flow, a function that attempts to pipe values through a series of functions
5166
- *
5167
- * Available as `attemptFlow` and `attempt.flow`
5168
7127
  * @returns Flow function
5169
7128
  */
5170
7129
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): AttemptFlow<First, Sixth>;
5171
7130
  /**
5172
7131
  * Create a Flow, a function that attempts to pipe values through a series of functions
5173
- *
5174
- * Available as `attemptFlow` and `attempt.flow`
5175
7132
  * @returns Flow function
5176
7133
  */
5177
7134
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): AttemptFlow<First, Seventh>;
5178
7135
  /**
5179
7136
  * Create a Flow, a function that attempts to pipe values through a series of functions
5180
- *
5181
- * Available as `attemptFlow` and `attempt.flow`
5182
7137
  * @returns Flow function
5183
7138
  */
5184
7139
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): AttemptFlow<First, Eighth>;
5185
7140
  /**
5186
7141
  * Create a Flow, a function that attempts to pipe values through a series of functions
5187
- *
5188
- * Available as `attemptFlow` and `attempt.flow`
5189
7142
  * @returns Flow function
5190
7143
  */
5191
7144
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): AttemptFlow<First, Ninth>;
5192
7145
  /**
5193
7146
  * Create a Flow, a function that attempts to pipe values through a series of functions
5194
- *
5195
- * Available as `attemptFlow` and `attempt.flow`
5196
7147
  * @returns Flow function
5197
7148
  */
5198
7149
  declare function attemptFlow<First extends GenericCallback, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(first: First, second: (value: UnwrapValue<ReturnType<First>>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): AttemptFlow<First, Tenth>;
5199
7150
  /**
5200
7151
  * Create a Flow, a function that attempts to pipe values through a series of functions
5201
- *
5202
- * Available as `attemptFlow` and `attempt.flow`
5203
7152
  * @returns Flow function
5204
7153
  */
5205
7154
  declare function attemptFlow<First extends GenericCallback>(first: First, ...fns: Array<(value: UnwrapValue<ReturnType<First>>) => unknown>): AttemptFlow<First, ReturnType<First>>;
5206
7155
  /**
5207
7156
  * Create a Flow, a function that attempts to pipe values through a series of functions
5208
- *
5209
- * Available as `attemptFlow` and `attempt.flow`
5210
7157
  * @returns Flow function
5211
7158
  */
5212
7159
  declare function attemptFlow(...fns: GenericCallback[]): (...args: unknown[]) => Result<unknown>;
@@ -5219,7 +7166,7 @@ type WrapValue<Value> = Result<UnwrapValue<Value>>;
5219
7166
  /**
5220
7167
  * Attempt to pipe a value through a function
5221
7168
  *
5222
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7169
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5223
7170
  * @param initial Initial value
5224
7171
  * @returns Piped result
5225
7172
  */
@@ -5227,7 +7174,7 @@ declare function attemptAsyncPipe<Initial, Piped>(initial: GenericCallback | Ini
5227
7174
  /**
5228
7175
  * Attempt to pipe a value through a series of functions
5229
7176
  *
5230
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7177
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5231
7178
  * @param initial Initial value
5232
7179
  * @returns Piped result
5233
7180
  */
@@ -5235,7 +7182,7 @@ declare function attemptAsyncPipe<Initial, First, Second>(initial: GenericCallba
5235
7182
  /**
5236
7183
  * Attempt to pipe a value through a series of functions
5237
7184
  *
5238
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7185
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5239
7186
  * @param initial Initial value
5240
7187
  * @returns Piped result
5241
7188
  */
@@ -5243,7 +7190,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third>(initial: Generi
5243
7190
  /**
5244
7191
  * Attempt to pipe a value through a series of functions
5245
7192
  *
5246
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7193
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5247
7194
  * @param initial Initial value
5248
7195
  * @returns Piped result
5249
7196
  */
@@ -5251,7 +7198,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial
5251
7198
  /**
5252
7199
  * Attempt to pipe a value through a series of functions
5253
7200
  *
5254
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7201
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5255
7202
  * @param initial Initial value
5256
7203
  * @returns Piped result
5257
7204
  */
@@ -5259,7 +7206,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(
5259
7206
  /**
5260
7207
  * Attempt to pipe a value through a series of functions
5261
7208
  *
5262
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7209
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5263
7210
  * @param initial Initial value
5264
7211
  * @returns Piped result
5265
7212
  */
@@ -5267,7 +7214,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth,
5267
7214
  /**
5268
7215
  * Attempt to pipe a value through a series of functions
5269
7216
  *
5270
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7217
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5271
7218
  * @param initial Initial value
5272
7219
  * @returns Piped result
5273
7220
  */
@@ -5275,7 +7222,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth,
5275
7222
  /**
5276
7223
  * Attempt to pipe a value through a series of functions
5277
7224
  *
5278
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7225
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5279
7226
  * @param initial Initial value
5280
7227
  * @returns Piped result
5281
7228
  */
@@ -5283,7 +7230,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth,
5283
7230
  /**
5284
7231
  * Attempt to pipe a value through a series of functions
5285
7232
  *
5286
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7233
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5287
7234
  * @param initial Initial value
5288
7235
  * @returns Piped result
5289
7236
  */
@@ -5291,7 +7238,7 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth,
5291
7238
  /**
5292
7239
  * Attempt to pipe a value through a series of functions
5293
7240
  *
5294
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7241
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5295
7242
  * @param initial Initial value
5296
7243
  * @returns Piped result
5297
7244
  */
@@ -5299,95 +7246,73 @@ declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth,
5299
7246
  /**
5300
7247
  * Attempt to pipe a result through a series of functions
5301
7248
  *
5302
- * Available as `attemptAsyncPipe` and `attempt.pipe.async`
7249
+ * Available as `attemptAsyncPipe` and `attemptPipe.async`
5303
7250
  * @param initial Initial result
5304
7251
  * @returns Piped result
5305
7252
  */
5306
7253
  declare function attemptAsyncPipe<Initial>(initial: GenericCallback | Initial | Promise<Initial> | Result<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): Promise<WrapValue<Initial>>;
5307
7254
  /**
5308
7255
  * Attempt to pipe a value through a function
5309
- *
5310
- * Available as `attemptPipe` and `attempt.pipe`
5311
7256
  * @param initial Initial value
5312
7257
  * @returns Piped result
5313
7258
  */
5314
7259
  declare function attemptPipe<Initial, Pipe>(initial: GenericCallback | Initial | Result<Initial>, pipe: (value: UnwrapValue<Initial>) => Pipe): WrapValue<Pipe>;
5315
7260
  /**
5316
7261
  * Attempt to pipe a value through a series of functions
5317
- *
5318
- * Available as `attemptPipe` and `attempt.pipe`
5319
7262
  * @param initial Initial value
5320
7263
  * @returns Piped result
5321
7264
  */
5322
7265
  declare function attemptPipe<Initial, First, Second>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): WrapValue<Second>;
5323
7266
  /**
5324
7267
  * Attempt to pipe a value through a series of functions
5325
- *
5326
- * Available as `attemptPipe` and `attempt.pipe`
5327
7268
  * @param initial Initial value
5328
7269
  * @returns Piped result
5329
7270
  */
5330
7271
  declare function attemptPipe<Initial, First, Second, Third>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): WrapValue<Third>;
5331
7272
  /**
5332
7273
  * Attempt to pipe a value through a series of functions
5333
- *
5334
- * Available as `attemptPipe` and `attempt.pipe`
5335
7274
  * @param initial Initial value
5336
7275
  * @returns Piped result
5337
7276
  */
5338
7277
  declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): WrapValue<Fourth>;
5339
7278
  /**
5340
7279
  * Attempt to pipe a value through a series of functions
5341
- *
5342
- * Available as `attemptPipe` and `attempt.pipe`
5343
7280
  * @param initial Initial value
5344
7281
  * @returns Piped result
5345
7282
  */
5346
7283
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): WrapValue<Fifth>;
5347
7284
  /**
5348
7285
  * Attempt to pipe a value through a series of functions
5349
- *
5350
- * Available as `attemptPipe` and `attempt.pipe`
5351
7286
  * @param initial Initial value
5352
7287
  * @returns Piped result
5353
7288
  */
5354
7289
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): WrapValue<Sixth>;
5355
7290
  /**
5356
7291
  * Attempt to pipe a value through a series of functions
5357
- *
5358
- * Available as `attemptPipe` and `attempt.pipe`
5359
7292
  * @param initial Initial value
5360
7293
  * @returns Piped result
5361
7294
  */
5362
7295
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): WrapValue<Seventh>;
5363
7296
  /**
5364
7297
  * Attempt to pipe a value through a series of functions
5365
- *
5366
- * Available as `attemptPipe` and `attempt.pipe`
5367
7298
  * @param initial Initial value
5368
7299
  * @returns Piped result
5369
7300
  */
5370
7301
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): WrapValue<Eighth>;
5371
7302
  /**
5372
7303
  * Attempt to pipe a value through a series of functions
5373
- *
5374
- * Available as `attemptPipe` and `attempt.pipe`
5375
7304
  * @param initial Initial value
5376
7305
  * @returns Piped result
5377
7306
  */
5378
7307
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): WrapValue<Ninth>;
5379
7308
  /**
5380
7309
  * Attempt to pipe a value through a series of functions
5381
- *
5382
- * Available as `attemptPipe` and `attempt.pipe`
5383
7310
  * @param initial Initial value
5384
7311
  * @returns Piped result
5385
7312
  */
5386
7313
  declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: GenericCallback | Initial | Result<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): WrapValue<Tenth>;
5387
7314
  /**
5388
7315
  * Attempt to pipe a result through a series of functions
5389
- *
5390
- * Available as `attemptPipe` and `attempt.pipe`
5391
7316
  * @param initial Initial result
5392
7317
  * @returns Piped result
5393
7318
  */
@@ -5396,62 +7321,6 @@ declare namespace attemptPipe {
5396
7321
  var async: typeof attemptAsyncPipe;
5397
7322
  }
5398
7323
  //#endregion
5399
- //#region src/result/index.d.ts
5400
- /**
5401
- * Executes a promise, catching any errors, and returns a result
5402
- *
5403
- * Available as `asyncAttempt` and `attempt.async`
5404
- * @param promise Promise to execute
5405
- * @param error Error value
5406
- * @returns Callback result
5407
- */
5408
- declare function asyncAttempt<Value, E>(promise: Promise<Value>, error: E): Promise<ExtendedResult<Awaited<Value>, E>>;
5409
- /**
5410
- * Executes a callback asynchronously, catching any errors, and returns a result
5411
- *
5412
- * Available as `asyncAttempt` and `attempt.async`
5413
- * @param callback Callback to execute
5414
- * @param error Error value
5415
- * @returns Callback result
5416
- */
5417
- declare function asyncAttempt<Value, E>(callback: () => Promise<Value>, error: E): Promise<ExtendedResult<Awaited<Value>, E>>;
5418
- /**
5419
- * Executes a promise, catching any errors, and returns a result
5420
- *
5421
- * Available as `asyncAttempt` and `attempt.async`
5422
- * @param promise Promise to execute
5423
- * @returns Callback result
5424
- */
5425
- declare function asyncAttempt<Value>(promise: Promise<Value>): Promise<Result<Awaited<Value>>>;
5426
- /**
5427
- * Executes a callback asynchronously, catching any errors, and returns a result
5428
- *
5429
- * Available as `asyncAttempt` and `attempt.async`
5430
- * @param callback Callback to execute
5431
- * @returns Callback result
5432
- */
5433
- declare function asyncAttempt<Value>(callback: () => Promise<Value>): Promise<Result<Awaited<Value>>>;
5434
- /**
5435
- * Executes a callback, catching any errors, and returns a result
5436
- * @param callback Callback to execute
5437
- * @param error Error value
5438
- * @returns Callback result
5439
- */
5440
- declare function attempt<Value, E>(callback: () => Value, error: E): ExtendedResult<Value, E>;
5441
- /**
5442
- * Executes a callback, catching any errors, and returns a result
5443
- * @param callback Callback to execute
5444
- * @returns Callback result
5445
- */
5446
- declare function attempt<Value>(callback: () => Value): Result<Value, Error>;
5447
- declare namespace attempt {
5448
- var async: typeof asyncAttempt;
5449
- var flow: typeof attemptFlow;
5450
- var match: typeof matchResult;
5451
- var pipe: typeof attemptPipe;
5452
- var promise: typeof attemptPromise;
5453
- }
5454
- //#endregion
5455
7324
  //#region src/sized/map.d.ts
5456
7325
  /**
5457
7326
  * A Map with a maximum size
@@ -5499,8 +7368,9 @@ declare class SizedMap<SizedKey = unknown, SizedValue = unknown> extends Map<Siz
5499
7368
  //#endregion
5500
7369
  //#region src/sized/set.d.ts
5501
7370
  /**
5502
- * - A Set with a maximum size
5503
- * - Behavior is similar to a _LRU_-cache, where the oldest values are removed
7371
+ * A Set with a maximum size
7372
+ *
7373
+ * Behavior is similar to a _LRU_-cache, where the oldest values are removed
5504
7374
  */
5505
7375
  declare class SizedSet<Value = unknown> extends Set<Value> {
5506
7376
  #private;
@@ -5541,4 +7411,4 @@ declare class SizedSet<Value = unknown> extends Set<Value> {
5541
7411
  get(value: Value, update?: boolean): Value | undefined;
5542
7412
  }
5543
7413
  //#endregion
5544
- export { AnyResult, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArrayPosition, ArrayValueSorter, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, type Events, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type Kalas, Key$1 as Key, type KeyedQueue, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, type Observable, type Observer, Ok, OnceAsyncCallback, OnceCallback, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, type Queue, type QueueError, type QueueOptions, type Queued, type QueuedResult, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, Shaken, Simplify, SizedMap, SizedSet, Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type Time, ToString, Transformer, TypedArray, Unsmushed, Unsubscriber, UnwrapValue, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, 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, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayPosition, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isSorted, isTypedArray, join, kalas, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, logger, 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, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, 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 };
7414
+ export { AnyResult, ArrayComparison, ArrayComparisonSorter, ArrayKeySorter, ArrayOrPlainObject, ArrayValueSorter, AssertProperty, Asserter, AssignOptions, Assigner, AsyncCancelableCallback, AttemptFlow, AttemptFlowPromise, type Beacon, type BeaconOptions, BuiltIns, CancelableCallback, CancelablePromise, type Color, Constructor, DiffOptions, DiffResult, DiffValue, EqualOptions, Err, EventPosition, type Events, ExtendedErr, ExtendedResult, Flow, FlowPromise, Frozen, FulfilledPromise, FuzzyConfiguration, FuzzyOptions, FuzzyResult, FuzzySearchOptions, GenericAsyncCallback, GenericCallback, type HSLAColor, type HSLColor, type Kalas, Key$1 as Key, type KeyedQueue, KeyedValue, type Logger, type Memoized, type MemoizedOptions, MergeOptions, Merger, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NormalizeOptions, Normalizer, NumericalKeys, NumericalValues, type Observable, type Observer, Ok, OnceAsyncCallback, OnceCallback, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED, PlainObject, Primitive, PromiseData, PromiseHandlers, PromiseOptions, PromiseParameters, PromiseStrategy, PromiseTimeoutError, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValue, PromisesValues, type Queue, type QueueError, type QueueOptions, type Queued, type QueuedResult, type RGBAColor, type RGBColor, RejectedPromise, RequiredKeys, Result, ResultMatch, RetryError, RetryOptions, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, Shaken, Simplify, SizedMap, SizedSet, Smushed, SortDirection, Sorter, type Subscription, TemplateOptions, type Time, ToString, Transformer, TypedArray, UnionToIntersection, Unsmushed, Unsubscriber, UnwrapValue, 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, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, filter, find, findLast, first, firstOrDefault, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getError, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getNormalizedHex, getNumber, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, hexToHsl, hexToHsla, hexToRgb, hexToRgba, hslToHex, hslToRgb, hslToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, intersection, isArrayOrPlainObject, isColor, isConstructor, isEmpty, isError, isFulfilled, isHexColor, isHslColor, isHslLike, isHslaColor, isInstanceOf, isKey, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isOk, isPlainObject, isPrimitive, isRejected, isResult, isRgbColor, isRgbLike, isRgbaColor, isSorted, isTypedArray, join, kalas, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, logger, 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, round, select, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, 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 };