@oscarpalmer/atoms 0.218.0 → 0.219.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 (50) hide show
  1. package/dist/array/filter.d.mts +38 -4
  2. package/dist/array/find.d.mts +34 -0
  3. package/dist/array/first.d.mts +40 -4
  4. package/dist/array/last.d.mts +46 -10
  5. package/dist/array/partition.d.mts +24 -8
  6. package/dist/array/reverse.d.mts +6 -0
  7. package/dist/array/reverse.mjs +6 -0
  8. package/dist/array/select.d.mts +97 -116
  9. package/dist/array/select.mjs +19 -15
  10. package/dist/array/single.d.mts +22 -0
  11. package/dist/array/single.mjs +1 -1
  12. package/dist/array/sort.d.mts +54 -0
  13. package/dist/color/space/hex.d.mts +8 -0
  14. package/dist/color/space/hex.mjs +8 -0
  15. package/dist/index.d.mts +716 -170
  16. package/dist/index.mjs +293 -68
  17. package/dist/internal/array/callbacks.mjs +1 -1
  18. package/dist/internal/array/find.d.mts +3 -3
  19. package/dist/internal/array/find.mjs +71 -52
  20. package/dist/internal/array/shuffle.d.mts +5 -0
  21. package/dist/internal/array/shuffle.mjs +5 -0
  22. package/dist/internal/math/aggregate.d.mts +69 -21
  23. package/dist/internal/math/misc.d.mts +14 -0
  24. package/dist/internal/math/misc.mjs +14 -0
  25. package/dist/internal/number.d.mts +18 -0
  26. package/dist/internal/number.mjs +18 -0
  27. package/dist/internal/string/case.d.mts +63 -0
  28. package/dist/internal/string/case.mjs +63 -0
  29. package/dist/internal/string/misc.d.mts +20 -0
  30. package/dist/internal/string/misc.mjs +20 -0
  31. package/dist/logger.d.mts +12 -0
  32. package/dist/logger.mjs +12 -0
  33. package/dist/math.d.mts +90 -0
  34. package/dist/math.mjs +7 -0
  35. package/dist/models/array/array.find.model.d.mts +26 -0
  36. package/dist/models/array/array.misc.model.d.mts +2 -4
  37. package/dist/models/index.d.mts +1 -1
  38. package/dist/models/value/value.merge.model.d.mts +3 -3
  39. package/dist/promise/misc.d.mts +6 -0
  40. package/dist/promise/misc.mjs +6 -0
  41. package/dist/promise/timed.d.mts +3 -0
  42. package/dist/promise/timed.mjs +3 -0
  43. package/dist/queue.d.mts +0 -1
  44. package/dist/queue.mjs +1 -1
  45. package/dist/string/index.d.mts +15 -1
  46. package/dist/string/index.mjs +15 -1
  47. package/dist/string/match.d.mts +24 -0
  48. package/dist/string/match.mjs +24 -0
  49. package/dist/string/template.d.mts +4 -0
  50. package/package.json +1 -1
package/dist/index.d.mts CHANGED
@@ -49,7 +49,7 @@ export type KeyOrCallbackValue<Item, Arg extends KeyOrCallback<Item>> = Arg exte
49
49
  /**
50
50
  * A nested array
51
51
  */
52
- export type NestedArray<Value> = Value extends Array<infer NestedValue> ? NestedArray<NestedValue> : Value;
52
+ export type NestedArray<Value> = Value extends ReadonlyArray<infer NestedValue> ? NestedArray<NestedValue> : Value;
53
53
  /**
54
54
  * All nested keys of an object as dot notation strings _(up to 5 levels deep)_
55
55
  */
@@ -145,7 +145,7 @@ export type Unsubscriber = () => void;
145
145
  * ); // => [{id: 1}, {id: 3}]
146
146
  * ```
147
147
  */
148
- export declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): unknown[];
148
+ export declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
149
149
  /**
150
150
  * Get a filtered array of items that do not match the value
151
151
  *
@@ -165,7 +165,25 @@ export declare function exclude<Item, Callback extends (item: Item, index: numbe
165
165
  * ); // => [{id: 1}, {id: 3}]
166
166
  * ```
167
167
  */
168
- export declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): unknown[];
168
+ export declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
169
+ /**
170
+ * Get a narrowed array of items that do not match the filter
171
+ *
172
+ * _Available as `exclude` and `filter.remove`_
173
+ *
174
+ * @param array Array to search in
175
+ * @param filter Type guard to exclude and narrow down the items
176
+ * @returns Narrowed array of items that do not match the filter
177
+ *
178
+ * @example
179
+ * ```typescript
180
+ * exclude(
181
+ * [1, 'a', 2, 'b'],
182
+ * (item): item is string => typeof item === 'string',
183
+ * ); // => [1, 2]
184
+ * ```
185
+ */
186
+ export declare function exclude<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Array<Exclude<Item, Narrowed>>;
169
187
  /**
170
188
  * Get a filtered array of items that do not match the filter
171
189
  *
@@ -183,7 +201,7 @@ export declare function exclude<Item extends PlainObject, ItemKey extends keyof
183
201
  * ); // => [{id: 1}, {id: 3}]
184
202
  * ```
185
203
  */
186
- export declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): unknown[];
204
+ export declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
187
205
  /**
188
206
  * Get a filtered array of items that do not match the given item
189
207
  *
@@ -198,7 +216,7 @@ export declare function exclude<Item>(array: Item[], filter: (item: Item, index:
198
216
  * exclude([1, 2, 3], 2); // => [1, 3]
199
217
  * ```
200
218
  */
201
- export declare function exclude<Item>(array: Item[], item: Item): unknown[];
219
+ export declare function exclude<Item>(array: Item[], item: Item): Item[];
202
220
  /**
203
221
  * Get a filtered array of items
204
222
  *
@@ -235,6 +253,22 @@ export declare function filter<Item, Callback extends (item: Item, index: number
235
253
  * ```
236
254
  */
237
255
  export declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
256
+ /**
257
+ * Get a narrowed array of items matching the filter
258
+ *
259
+ * @param array Array to search in
260
+ * @param filter Type guard to match and narrow down the items
261
+ * @returns Narrowed array of items
262
+ *
263
+ * @example
264
+ * ```typescript
265
+ * filter(
266
+ * [{id: 1, tags: ['a', 'b']}, {id: 2}, {id: 3, tags: ['c']}],
267
+ * (item): item is {id: number; tags: string[]} => item.tags != null,
268
+ * ); // => [{id: 1, tags: ['a', 'b']}, {id: 3, tags: ['c']}]
269
+ * ```
270
+ */
271
+ export declare function filter<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed[];
238
272
  /**
239
273
  * Get a filtered array of items matching the filter
240
274
  *
@@ -305,6 +339,22 @@ export declare function find<Item, Callback extends (item: Item, index: number,
305
339
  * ```
306
340
  */
307
341
  export declare function find<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
342
+ /**
343
+ * Get the first narrowed item matching the filter
344
+ *
345
+ * @param array Array to search in
346
+ * @param filter Type guard to match and narrow down the items
347
+ * @returns First narrowed item that matches the filter, or `undefined` if no match is found
348
+ *
349
+ * @example
350
+ * ```typescript
351
+ * find(
352
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
353
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
354
+ * ); // => {id: 2, value: 'a'}
355
+ * ```
356
+ */
357
+ export declare function find<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
308
358
  /**
309
359
  * Get the first item matching the filter
310
360
  *
@@ -374,6 +424,24 @@ export declare function findLast<Item, Callback extends (item: Item, index: numb
374
424
  * ```
375
425
  */
376
426
  export declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
427
+ /**
428
+ * Get the last narrowed item matching the filter
429
+ *
430
+ * _Available as `findLast` and `find.last`_
431
+ *
432
+ * @param array Array to search in
433
+ * @param filter Type guard to match and narrow down the items
434
+ * @returns Last narrowed item that matches the filter, or `undefined` if no match is found
435
+ *
436
+ * @example
437
+ * ```typescript
438
+ * findLast(
439
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
440
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
441
+ * ); // => {id: 3, value: 'b'}
442
+ * ```
443
+ */
444
+ export declare function findLast<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
377
445
  /**
378
446
  * Get the last item matching the filter
379
447
  *
@@ -448,6 +516,22 @@ export declare function first<Item, Callback extends (item: Item, index: number,
448
516
  * ```
449
517
  */
450
518
  export declare function first<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
519
+ /**
520
+ * Get the first narrowed item matching the filter
521
+ *
522
+ * @param array Array to search in
523
+ * @param filter Type guard to match and narrow down the items
524
+ * @returns First narrowed item that matches the filter, or `undefined` if no match is found
525
+ *
526
+ * @example
527
+ * ```typescript
528
+ * first(
529
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
530
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
531
+ * ); // => {id: 2, value: 'a'}
532
+ * ```
533
+ */
534
+ export declare function first<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
451
535
  /**
452
536
  * Get the first item matching the filter
453
537
  *
@@ -481,7 +565,7 @@ export declare function first<Item>(array: Item[]): Item | undefined;
481
565
  /**
482
566
  * Get the first item matching the given value, or a default value if no match is found
483
567
  *
484
- * _Available as `firstOrDefault` and `first.default`_
568
+ * _Available as `firstOrDefault` and `first.defaulted`_
485
569
  *
486
570
  * @param array Array to search in
487
571
  * @param defaultValue Default value to return if no match is found
@@ -503,7 +587,7 @@ export declare function firstOrDefault<Item, Callback extends (item: Item, index
503
587
  /**
504
588
  * Get the first item matching the given value by key, or a default value if no match is found
505
589
  *
506
- * _Available as `firstOrDefault` and `first.default`_
590
+ * _Available as `firstOrDefault` and `first.defaulted`_
507
591
  *
508
592
  * @param array Array to search in
509
593
  * @param defaultValue Default value to return if no match is found
@@ -522,10 +606,30 @@ export declare function firstOrDefault<Item, Callback extends (item: Item, index
522
606
  * ```
523
607
  */
524
608
  export declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
609
+ /**
610
+ * Get the first narrowed item matching the filter, or a default value if no match is found
611
+ *
612
+ * _Available as `firstOrDefault` and `first.defaulted`_
613
+ *
614
+ * @param array Array to search in
615
+ * @param defaultValue Default value to return if no match is found
616
+ * @param filter Type guard to match and narrow down the items
617
+ * @returns First narrowed item that matches the filter, or the default value if no match is found
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * firstOrDefault(
622
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
623
+ * {id: -1, value: 'c'},
624
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
625
+ * ); // => {id: 2, value: 'a'}
626
+ * ```
627
+ */
628
+ export declare function firstOrDefault<Item, Narrowed extends Item, Default>(array: Item[], defaultValue: Default, filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | Default;
525
629
  /**
526
630
  * Get the first item matching the filter, or a default value if no match is found
527
631
  *
528
- * _Available as `firstOrDefault` and `first.default`_
632
+ * _Available as `firstOrDefault` and `first.defaulted`_
529
633
  *
530
634
  * @param array Array to search in
531
635
  * @param defaultValue Default value to return if no match is found
@@ -545,7 +649,7 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item,
545
649
  /**
546
650
  * Get the first item from an array, or a default value if the array is empty
547
651
  *
548
- * _Available as `firstOrDefault` and `first.default`_
652
+ * _Available as `firstOrDefault` and `first.defaulted`_
549
653
  *
550
654
  * @param array Array to get from
551
655
  * @param defaultValue Default value to return if the array is empty
@@ -787,9 +891,7 @@ export declare function getArray<Value>(value: Value): Value[];
787
891
  * Comparison of an array within another array
788
892
  */
789
893
  type ArrayComparison = "end" | "inside" | "invalid" | "outside" | "same" | "start";
790
- type ArrayMapKeyOrCallback<Item> = ((item: Item, index: number, array: Item[]) => unknown) | (Item extends PlainObject ? keyof Item : never);
791
- type ArrayMapped<Item, Map extends ArrayMapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
792
- type ArrayObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
894
+ type ArrayFlattened<Value> = Value extends ReadonlyArray<infer Inner> ? Inner : Value;
793
895
  //#endregion
794
896
  //#region src/internal/array/match.d.ts
795
897
  /**
@@ -1044,6 +1146,11 @@ export declare function startsWithArray<Item>(haystack: Item[], needle: Item[]):
1044
1146
  *
1045
1147
  * @param array Original array
1046
1148
  * @returns Shuffled array
1149
+ *
1150
+ * @example
1151
+ * ```typescript
1152
+ * shuffle([1, 2, 3]); // => [3, 1, 2] (maybe? it's random, you know)
1153
+ * ```
1047
1154
  */
1048
1155
  export declare function shuffle<Item>(array: Item[]): Item[];
1049
1156
  //#endregion
@@ -1355,7 +1462,7 @@ export declare function intersection<First, Second>(first: First[], second: Seco
1355
1462
  * @param array Array to search in
1356
1463
  * @param callback Callback to get an item's value for matching
1357
1464
  * @param value Value to match against
1358
- * @returns Partitioned array of items
1465
+ * @returns Tuple of matching and non-matching items
1359
1466
  *
1360
1467
  * @example
1361
1468
  * ```typescript
@@ -1366,14 +1473,14 @@ export declare function intersection<First, Second>(first: First[], second: Seco
1366
1473
  * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1367
1474
  * ```
1368
1475
  */
1369
- export declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[][];
1476
+ export declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): [Item[], Item[]];
1370
1477
  /**
1371
1478
  * Get a partitioned array of items
1372
1479
  *
1373
1480
  * @param array Array to search in
1374
1481
  * @param key Key to get an item's value for matching
1375
1482
  * @param value Value to match against
1376
- * @returns Partitioned array of items
1483
+ * @returns Tuple of matching and non-matching items
1377
1484
  *
1378
1485
  * @example
1379
1486
  * ```typescript
@@ -1384,13 +1491,29 @@ export declare function partition<Item, Callback extends (item: Item, index: num
1384
1491
  * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1385
1492
  * ```
1386
1493
  */
1387
- export declare function partition<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[][];
1494
+ export declare function partition<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): [Item[], Item[]];
1495
+ /**
1496
+ * Get a partitioned array of items
1497
+ *
1498
+ * @param array Array to search in
1499
+ * @param filter Type guard to match and narrow down the items
1500
+ * @returns Tuple of matching and non-matching items
1501
+ *
1502
+ * @example
1503
+ * ```typescript
1504
+ * partition(
1505
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
1506
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
1507
+ * ); // => [[{id: 2, value: 'a'}, {id: 3, value: 'b'}], [{id: 1, value: 10}]]
1508
+ * ```
1509
+ */
1510
+ export declare function partition<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): [Narrowed[], Array<Exclude<Item, Narrowed>>];
1388
1511
  /**
1389
1512
  * Get a partitioned array of items
1390
1513
  *
1391
1514
  * @param array Array to search in
1392
1515
  * @param filter Filter callback to match items
1393
- * @returns Partitioned array of items
1516
+ * @returns Tuple of matching and non-matching items
1394
1517
  *
1395
1518
  * @example
1396
1519
  * ```typescript
@@ -1400,20 +1523,20 @@ export declare function partition<Item extends PlainObject, ItemKey extends keyo
1400
1523
  * ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
1401
1524
  * ```
1402
1525
  */
1403
- export declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[][];
1526
+ export declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): [Item[], Item[]];
1404
1527
  /**
1405
1528
  * Get a partitioned array of items matching the given item
1406
1529
  *
1407
1530
  * @param array Array to search in
1408
1531
  * @param item Item to match against
1409
- * @returns Partitioned array of items
1532
+ * @returns Tuple of matching and non-matching items
1410
1533
  *
1411
1534
  * @example
1412
1535
  * ```typescript
1413
1536
  * partition([1, 2, 3, 4, 5], 3); // => [[3], [1, 2, 4, 5]]
1414
1537
  * ```
1415
1538
  */
1416
- export declare function partition<Item>(array: Item[], item: Item): Item[][];
1539
+ export declare function partition<Item>(array: Item[], item: Item): [Item[], Item[]];
1417
1540
  //#endregion
1418
1541
  //#region src/array/push.d.ts
1419
1542
  /**
@@ -1438,6 +1561,12 @@ export declare function push<Item>(array: Item[], pushed: Item[]): number;
1438
1561
  *
1439
1562
  * @param array Array to reverse
1440
1563
  * @returns Reversed array
1564
+ *
1565
+ * @example
1566
+ * ```typescript
1567
+ * reverse([1, 2, 3]); // => [3, 2, 1]
1568
+ * reverse(['a', 'b', 'c']); // => ['c', 'b', 'a']
1569
+ * ```
1441
1570
  */
1442
1571
  export declare function reverse<Item>(array: Item[]): Item[];
1443
1572
  //#endregion
@@ -1482,6 +1611,28 @@ export declare function single<Item, Callback extends (item: Item, index: number
1482
1611
  * ```
1483
1612
  */
1484
1613
  export declare function single<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
1614
+ /**
1615
+ * Get the _only_ narrowed item matching the filter
1616
+ *
1617
+ * _Throws an error if multiple items match the filter_
1618
+ *
1619
+ * @param array Array to search in
1620
+ * @param filter Type guard to match and narrow down the items
1621
+ * @returns Only narrowed item that matches the filter, or `undefined` if no match is found
1622
+ *
1623
+ * @example
1624
+ * ```typescript
1625
+ * single(
1626
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
1627
+ * (item): item is {id: number; value: number} => typeof item.value === 'number',
1628
+ * ); // => {id: 1, value: 10}
1629
+ * single(
1630
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
1631
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
1632
+ * ); // => throws an error as there are two matches
1633
+ * ```
1634
+ */
1635
+ export declare function single<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
1485
1636
  /**
1486
1637
  * Get the _only_ item matching the filter
1487
1638
  *
@@ -2024,7 +2175,7 @@ export declare function update<Item>(destination: Item[], updated: Item[]): Item
2024
2175
  //#endregion
2025
2176
  //#region src/array/last.d.ts
2026
2177
  /**
2027
- * Get the last items matching the given value
2178
+ * Get the last item matching the given value
2028
2179
  *
2029
2180
  * @param array Array to search in
2030
2181
  * @param callback Callback to get an item's value for matching
@@ -2042,7 +2193,7 @@ export declare function update<Item>(destination: Item[], updated: Item[]): Item
2042
2193
  */
2043
2194
  export declare function last<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
2044
2195
  /**
2045
- * Get the first item matching the given value by key
2196
+ * Get the last item matching the given value by key
2046
2197
  *
2047
2198
  * @param array Array to search in
2048
2199
  * @param key Key to get an item's value for matching
@@ -2059,6 +2210,22 @@ export declare function last<Item, Callback extends (item: Item, index: number,
2059
2210
  * ```
2060
2211
  */
2061
2212
  export declare function last<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
2213
+ /**
2214
+ * Get the last narrowed item matching the filter
2215
+ *
2216
+ * @param array Array to search in
2217
+ * @param filter Type guard to match and narrow down the items
2218
+ * @returns Last narrowed item that matches the filter, or `undefined` if no match is found
2219
+ *
2220
+ * @example
2221
+ * ```typescript
2222
+ * last(
2223
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
2224
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
2225
+ * ); // => {id: 3, value: 'b'}
2226
+ * ```
2227
+ */
2228
+ export declare function last<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
2062
2229
  /**
2063
2230
  * Get the last item matching the filter
2064
2231
  *
@@ -2088,9 +2255,9 @@ export declare function last<Item>(array: Item[], filter: (item: Item, index: nu
2088
2255
  */
2089
2256
  export declare function last<Item>(array: Item[]): Item | undefined;
2090
2257
  /**
2091
- * Get the last item matching the given value
2258
+ * Get the last item matching the given value, or a default value if no match is found
2092
2259
  *
2093
- * _Available as `lastOrDefault` and `last.default`_
2260
+ * _Available as `lastOrDefault` and `last.defaulted`_
2094
2261
  *
2095
2262
  * @param array Array to search in
2096
2263
  * @param defaultValue Default value to return if no match is found
@@ -2110,9 +2277,9 @@ export declare function last<Item>(array: Item[]): Item | undefined;
2110
2277
  */
2111
2278
  export declare function lastOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
2112
2279
  /**
2113
- * Get the last item matching the given value by key
2280
+ * Get the last item matching the given value by key, or a default value if no match is found
2114
2281
  *
2115
- * _Available as `lastOrDefault` and `last.default`_
2282
+ * _Available as `lastOrDefault` and `last.defaulted`_
2116
2283
  *
2117
2284
  * @param array Array to search in
2118
2285
  * @param defaultValue Default value to return if no match is found
@@ -2132,9 +2299,29 @@ export declare function lastOrDefault<Item, Callback extends (item: Item, index:
2132
2299
  */
2133
2300
  export declare function lastOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
2134
2301
  /**
2135
- * Get the last item matching the filter
2302
+ * Get the last narrowed item matching the filter, or a default value if no match is found
2136
2303
  *
2137
- * _Available as `lastOrDefault` and `last.default`_
2304
+ * _Available as `lastOrDefault` and `last.defaulted`_
2305
+ *
2306
+ * @param array Array to search in
2307
+ * @param defaultValue Default value to return if no match is found
2308
+ * @param filter Type guard to match and narrow down the items
2309
+ * @returns Last narrowed item that matches the filter, or the default value if no match is found
2310
+ *
2311
+ * @example
2312
+ * ```typescript
2313
+ * lastOrDefault(
2314
+ * [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
2315
+ * {id: -1, value: 'c'},
2316
+ * (item): item is {id: number; value: string} => typeof item.value === 'string',
2317
+ * ); // => {id: 3, value: 'b'}
2318
+ * ```
2319
+ */
2320
+ export declare function lastOrDefault<Item, Narrowed extends Item, Default>(array: Item[], defaultValue: Default, filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | Default;
2321
+ /**
2322
+ * Get the last item matching the filter, or a default value if no match is found
2323
+ *
2324
+ * _Available as `lastOrDefault` and `last.defaulted`_
2138
2325
  *
2139
2326
  * @param array Array to search in
2140
2327
  * @param defaultValue Default value to return if no match is found
@@ -2152,9 +2339,9 @@ export declare function lastOrDefault<Item extends PlainObject, ItemKey extends
2152
2339
  */
2153
2340
  export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
2154
2341
  /**
2155
- * Get the last item from an array
2342
+ * Get the last item from an array, or a default value if the array is empty
2156
2343
  *
2157
- * _Available as `lastOrDefault` and `last.default`_
2344
+ * _Available as `lastOrDefault` and `last.defaulted`_
2158
2345
  *
2159
2346
  * @param array Array to get from
2160
2347
  * @param defaultValue Default value to return if the array is empty
@@ -2336,190 +2523,172 @@ export declare namespace move {
2336
2523
  //#endregion
2337
2524
  //#region src/array/select.d.ts
2338
2525
  /**
2339
- * Get a filtered and mapped array of items
2526
+ * Get a narrowed, mapped, and flattened array of items
2340
2527
  *
2341
- * @param array Array to search in
2342
- * @param filterCallback Callback to get an item's value for matching
2343
- * @param filterValue Value to match against
2344
- * @param map Callback or key to map the matched items
2345
- * @returns Filtered and mapped array of items
2346
- *
2347
- * @example
2348
- * ```typescript
2349
- * select(
2350
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2351
- * item => item.id,
2352
- * 2,
2353
- * item => item.name,
2354
- * ); // => ['Bob']
2355
- * ```
2356
- */
2357
- export declare function filterAndMap<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<ArrayMapped<Item, Map>>;
2358
- /**
2359
- * Get a filtered and mapped array of items
2528
+ * _Available as `filterAndFlatMap`, `filterAndMap.flat`, and `select.flat`_
2360
2529
  *
2361
- * @param array Array to search in
2362
- * @param filterKey Key to get an item's value for matching
2363
- * @param filterValue Value to match against
2364
- * @param map Callback or key to map the matched items
2365
- * @returns Filtered and mapped array of items
2530
+ * @param array Array to select from
2531
+ * @param filter Type guard to filter and narrow down the items
2532
+ * @param mapper Callback to map and flatten the narrowed items
2533
+ * @returns Narrowed, mapped, and flattened array of items
2366
2534
  *
2367
2535
  * @example
2368
2536
  * ```typescript
2369
- * select(
2370
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2371
- * 'id',
2372
- * 2,
2373
- * 'name',
2374
- * ); // => ['Bob']
2537
+ * filterAndFlatMap(
2538
+ * [{id: 1, tags: ['a', 'b']}, {id: 2}, {id: 3, tags: ['c']}],
2539
+ * (item): item is {id: number; tags: string[]} => item.tags != null,
2540
+ * item => item.tags,
2541
+ * ); // => ['a', 'b', 'c']
2375
2542
  * ```
2376
2543
  */
2377
- export declare function filterAndMap<Item extends PlainObject, ItemKey extends keyof Item, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<ArrayMapped<Item, Map>>;
2544
+ export declare function filterAndFlatMap<Item, Narrowed extends Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed, mapper: (item: Narrowed, index: number, array: Item[]) => Mapped): Array<ArrayFlattened<Mapped>>;
2378
2545
  /**
2379
- * Get a filtered and mapped array of items
2546
+ * Get a filtered, mapped, and flattened array of items
2380
2547
  *
2381
- * @param array Array to search in
2382
- * @param filter Filter callback to match items
2383
- * @param map Callback or key to map the matched items
2384
- * @returns Filtered and mapped array of items
2548
+ * _Available as `filterAndFlatMap`, `filterAndMap.flat`, and `select.flat`_
2549
+ *
2550
+ * @param array Array to select from
2551
+ * @param filter Callback to filter the items
2552
+ * @param mapper Callback to map and flatten the filtered items
2553
+ * @returns Filtered, mapped, and flattened array of items
2385
2554
  *
2386
2555
  * @example
2387
2556
  * ```typescript
2388
- * select(
2389
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2390
- * item => item.id === 2,
2391
- * item => item.name,
2392
- * ); // => ['Bob']
2557
+ * filterAndFlatMap(
2558
+ * [{id: 1, tags: ['a', 'b']}, {id: 2, tags: ['c']}, {id: 3, tags: ['d', 'e']}],
2559
+ * item => item.id !== 2,
2560
+ * item => item.tags,
2561
+ * ); // => ['a', 'b', 'd', 'e']
2393
2562
  * ```
2394
2563
  */
2395
- export declare function filterAndMap<Item, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<ArrayMapped<Item, Map>>;
2564
+ export declare function filterAndFlatMap<Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, mapper: (item: Item, index: number, array: Item[]) => Mapped): Array<ArrayFlattened<Mapped>>;
2396
2565
  /**
2397
- * Get a filtered and mapped array of items
2566
+ * Get a narrowed and mapped array of items
2398
2567
  *
2399
- * @param array Array to search in
2400
- * @param item Item to match against
2401
- * @param map Callback or key to map the matched items
2402
- * @returns Filtered and mapped array of items
2568
+ * _Available as `filterAndMap` and `select`_
2569
+ *
2570
+ * @param array Array to select from
2571
+ * @param filter Type guard to filter and narrow down the items
2572
+ * @param mapper Callback to map the narrowed items
2573
+ * @returns Narrowed and mapped array of items
2403
2574
  *
2404
2575
  * @example
2405
2576
  * ```typescript
2406
- * select(
2407
- * [1, 2, 3, 2, 1],
2408
- * 3,
2409
- * value => value ** 2,
2410
- * ); // => [9]
2577
+ * filterAndMap(
2578
+ * [{id: 1, name: 'Alice'}, {id: 2}, {id: 3, name: 'Charlie'}],
2579
+ * (item): item is {id: number; name: string} => item.name != null,
2580
+ * item => item.name.toUpperCase(),
2581
+ * ); // => ['ALICE', 'CHARLIE']
2411
2582
  * ```
2412
2583
  */
2413
- export declare function filterAndMap<Item, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<ArrayMapped<Item, Map>>;
2584
+ export declare function filterAndMap<Item, Narrowed extends Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed, mapper: (item: Narrowed, index: number, array: Item[]) => Mapped): Mapped[];
2414
2585
  /**
2415
- * Get a mapped and filtered array of items
2586
+ * Get a filtered and mapped array of items
2416
2587
  *
2417
- * _Available as `reverseSelect`_ and `select.reverse`_
2588
+ * _Available as `filterAndMap` and `select`_
2418
2589
  *
2419
- * @param array Array to search in
2420
- * @param map Callback or key to map the items
2421
- * @param filterCallback Callback to get a mapped value's value for matching
2422
- * @param filterValue Value to match against
2423
- * @returns Mapped and filtered array of items
2590
+ * @param array Array to select from
2591
+ * @param filter Callback to filter the items
2592
+ * @param mapper Callback to map the filtered items
2593
+ * @returns Filtered and mapped array of items
2424
2594
  *
2425
2595
  * @example
2426
2596
  * ```typescript
2427
- * reverseSelect(
2597
+ * filterAndMap(
2428
2598
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2599
+ * item => item.id === 2,
2429
2600
  * item => item.name,
2430
- * value => value.length,
2431
- * 3,
2432
2601
  * ); // => ['Bob']
2433
2602
  * ```
2434
2603
  */
2435
- export declare function mapAndFilter<Item, Map extends ArrayMapKeyOrCallback<Item>, FilterCallback extends (item: ArrayMapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<ArrayMapped<Item, Map>>;
2604
+ export declare function filterAndMap<Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, mapper: (item: Item, index: number, array: Item[]) => Mapped): Mapped[];
2436
2605
  /**
2437
- * Get a mapped and filtered array of items
2606
+ * Get a mapped, flattened, and narrowed array of items
2438
2607
  *
2439
- * _Available as `reverseSelect`_ and `select.reverse`_
2608
+ * _Available as `flatMapAndFilter`, `mapAndFilter.flat`, and `reverseSelect.flat`_
2440
2609
  *
2441
- * @param array Array to search in
2442
- * @param map Callback to map the items
2443
- * @param filterKey Key to get a mapped value's value for matching
2444
- * @param filterValue Value to match against
2445
- * @returns Mapped and filtered array of items
2610
+ * @param array Array to select from
2611
+ * @param mapper Callback to map and flatten the items
2612
+ * @param filter Type guard to filter and narrow down the flattened items
2613
+ * @returns Mapped, flattened, and narrowed array of items
2446
2614
  *
2447
2615
  * @example
2448
2616
  * ```typescript
2449
- * reverseSelect(
2450
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2451
- * item => ({label: item.name}),
2452
- * 'label',
2453
- * 'Bob',
2454
- * ); // => [{label: 'Bob'}]
2617
+ * flatMapAndFilter(
2618
+ * [{id: 1, values: [1, 'a']}, {id: 2, values: ['b', 2]}],
2619
+ * item => item.values,
2620
+ * (value): value is number => typeof value === 'number',
2621
+ * ); // => [1, 2]
2455
2622
  * ```
2456
2623
  */
2457
- export declare function mapAndFilter<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
2624
+ export declare function flatMapAndFilter<Item, Mapped, Narrowed extends ArrayFlattened<Mapped>>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: ArrayFlattened<Mapped>, index: number, array: Item[]) => item is Narrowed): Narrowed[];
2458
2625
  /**
2459
- * Get a mapped and filtered array of items
2626
+ * Get a mapped, flattened, and filtered array of items
2460
2627
  *
2461
- * _Available as `reverseSelect`_ and `select.reverse`_
2628
+ * _Available as `flatMapAndFilter`, `mapAndFilter.flat`, and `reverseSelect.flat`_
2462
2629
  *
2463
- * @param array Array to search in
2464
- * @param map Key to map the items
2465
- * @param filterKey Key to get a mapped value's value for matching
2466
- * @param filterValue Value to match against
2467
- * @returns Mapped and filtered array of items
2630
+ * @param array Array to select from
2631
+ * @param mapper Callback to map and flatten the items
2632
+ * @param filter Callback to filter the flattened items
2633
+ * @returns Mapped, flattened, and filtered array of items
2468
2634
  *
2469
2635
  * @example
2470
2636
  * ```typescript
2471
- * reverseSelect(
2472
- * [{meta: {tag: 'a'}}, {meta: {tag: 'b'}}],
2473
- * 'meta',
2474
- * 'tag',
2475
- * 'b',
2476
- * ); // => [{tag: 'b'}]
2637
+ * flatMapAndFilter(
2638
+ * [{id: 1, tags: ['a', 'b']}, {id: 2, tags: ['c']}, {id: 3, tags: ['b', 'd']}],
2639
+ * item => item.tags,
2640
+ * tag => tag !== 'b',
2641
+ * ); // => ['a', 'c', 'd']
2477
2642
  * ```
2478
2643
  */
2479
- export declare function mapAndFilter<Item, MapKey extends ArrayObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
2644
+ export declare function flatMapAndFilter<Item, Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: ArrayFlattened<Mapped>, index: number, array: Item[]) => boolean): Array<ArrayFlattened<Mapped>>;
2480
2645
  /**
2481
- * Get a mapped and filtered array of items
2646
+ * Get a mapped and narrowed array of items
2482
2647
  *
2483
- * _Available as `reverseSelect`_ and `select.reverse`_
2648
+ * _Available as `mapAndFilter`, `reverseSelect`, `filterAndMap.reverse`, and `select.reverse`_
2484
2649
  *
2485
- * @param array Array to search in
2486
- * @param map Callback or key to map the items
2487
- * @param filter Filter callback to match mapped values
2488
- * @returns Mapped and filtered array of items
2650
+ * @param array Array to select from
2651
+ * @param mapper Callback to map the items
2652
+ * @param filter Type guard to filter and narrow down the mapped items
2653
+ * @returns Mapped and narrowed array of items
2489
2654
  *
2490
2655
  * @example
2491
2656
  * ```typescript
2492
- * reverseSelect(
2493
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2657
+ * mapAndFilter(
2658
+ * [{id: 1, name: 'Alice'}, {id: 2}, {id: 3, name: 'Charlie'}],
2494
2659
  * item => item.name,
2495
- * value => value.startsWith('B'),
2496
- * ); // => ['Bob']
2660
+ * (name): name is string => name != null,
2661
+ * ); // => ['Alice', 'Charlie']
2497
2662
  * ```
2498
2663
  */
2499
- export declare function mapAndFilter<Item, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: ArrayMapped<Item, Map>, index: number, array: Item[]) => boolean): Array<ArrayMapped<Item, Map>>;
2664
+ export declare function mapAndFilter<Item, Mapped, Narrowed extends Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: Mapped, index: number, array: Item[]) => item is Narrowed): Narrowed[];
2500
2665
  /**
2501
2666
  * Get a mapped and filtered array of items
2502
2667
  *
2503
- * _Available as `reverseSelect`_ and `select.reverse`_
2668
+ * _Available as `mapAndFilter`, `reverseSelect`, `filterAndMap.reverse`, and `select.reverse`_
2504
2669
  *
2505
- * @param array Array to search in
2506
- * @param map Callback or key to map the items
2507
- * @param value Mapped value to match against
2670
+ * @param array Array to select from
2671
+ * @param mapper Callback to map the items
2672
+ * @param filter Callback to filter the mapped items
2508
2673
  * @returns Mapped and filtered array of items
2509
2674
  *
2510
2675
  * @example
2511
2676
  * ```typescript
2512
- * reverseSelect(
2513
- * [1, 2, 3, 2, 1],
2514
- * value => value ** 2,
2515
- * 4,
2516
- * ); // => [4, 4]
2677
+ * mapAndFilter(
2678
+ * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
2679
+ * item => item.name,
2680
+ * name => name.length > 3,
2681
+ * ); // => ['Alice', 'Charlie']
2517
2682
  * ```
2518
2683
  */
2519
- export declare function mapAndFilter<Item, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], map: Map, value: ArrayMapped<Item, Map>): Array<ArrayMapped<Item, Map>>;
2684
+ export declare function mapAndFilter<Item, Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: Mapped, index: number, array: Item[]) => boolean): Mapped[];
2520
2685
  export declare namespace filterAndMap {
2686
+ export var flat: typeof filterAndFlatMap;
2521
2687
  export var reverse: typeof mapAndFilter;
2522
2688
  }
2689
+ export declare namespace mapAndFilter {
2690
+ export var flat: typeof flatMapAndFilter;
2691
+ }
2523
2692
  //#endregion
2524
2693
  //#region src/models/array/array.sort.model.d.ts
2525
2694
  /**
@@ -2649,6 +2818,11 @@ declare function Sorter(this: any, sorters: SortHandler[]): void;
2649
2818
  * @param sorters Sorters to use to determine sorting
2650
2819
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
2651
2820
  * @returns Index for item
2821
+ *
2822
+ * @example
2823
+ * ```typescript
2824
+ * getSortedIndex([1, 3, 2], 2, [{key: 'value', direction: 'asc'}]); // => 1
2825
+ * ```
2652
2826
  */
2653
2827
  export declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<ArraySorter<Item>>, descending?: boolean): number;
2654
2828
  /**
@@ -2663,6 +2837,11 @@ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorters:
2663
2837
  * @param sorter Sorter to use to determine sorting
2664
2838
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
2665
2839
  * @returns Index for item
2840
+ *
2841
+ * @example
2842
+ * ```typescript
2843
+ * getSortedIndex([1, 3, 2], 2, {key: 'value', direction: 'asc'}); // => 1
2844
+ * ```
2666
2845
  */
2667
2846
  export declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySorter<Item>, descending?: boolean): number;
2668
2847
  /**
@@ -2676,6 +2855,11 @@ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorter:
2676
2855
  * @param item Item to get the index for
2677
2856
  * @param descending Sorted in descending order? _(defaults to `false`)_
2678
2857
  * @returns Index for item
2858
+ *
2859
+ * @example
2860
+ * ```typescript
2861
+ * getSortedIndex([1, 3, 2], 2); // => 1
2862
+ * ```
2679
2863
  */
2680
2864
  export declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: boolean): number;
2681
2865
  /**
@@ -2716,6 +2900,12 @@ export declare function initializeSorter<Item>(descending?: boolean): Sorter<Ite
2716
2900
  * @param sorters Sorters to determine sorting
2717
2901
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
2718
2902
  * @returns `true` if sorted, otherwise `false`
2903
+ *
2904
+ * @example
2905
+ * ```typescript
2906
+ * isSorted([1, 2, 3], [{key: 'value', direction: 'asc'}]); // => true
2907
+ * isSorted([3, 2, 1], [{key: 'value', direction: 'asc'}]); // => false
2908
+ * ```
2719
2909
  */
2720
2910
  export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): boolean;
2721
2911
  /**
@@ -2727,6 +2917,12 @@ export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter
2727
2917
  * @param sorter Sorter to determine sorting
2728
2918
  * @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
2729
2919
  * @returns `true` if sorted, otherwise `false`
2920
+ *
2921
+ * @example
2922
+ * ```typescript
2923
+ * isSorted([1, 2, 3], {key: 'value', direction: 'asc'}); // => true
2924
+ * isSorted([3, 2, 1], {key: 'value', direction: 'asc'}); // => false
2925
+ * ```
2730
2926
  */
2731
2927
  export declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): boolean;
2732
2928
  /**
@@ -2737,6 +2933,12 @@ export declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>,
2737
2933
  * @param array Array to check
2738
2934
  * @param descending Sorted in descending order? _(defaults to `false`)_
2739
2935
  * @returns `true` if sorted, otherwise `false`
2936
+ *
2937
+ * @example
2938
+ * ```typescript
2939
+ * isSorted([1, 2, 3]); // => true
2940
+ * isSorted([3, 2, 1]); // => false
2941
+ * ```
2740
2942
  */
2741
2943
  export declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
2742
2944
  /**
@@ -2763,6 +2965,14 @@ export declare function sort<Item>(array: Item[], comparator: (first: Item, seco
2763
2965
  * @param sorters Sorters to use for sorting
2764
2966
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
2765
2967
  * @returns Sorted array
2968
+ *
2969
+ * @example
2970
+ * ```typescript
2971
+ * sort(
2972
+ * [{id: 3}, {id: 1}, {id: 2}],
2973
+ * [{key: 'id', direction: 'asc'}],
2974
+ * ); // => [{id: 1}, {id: 2}, {id: 3}]
2975
+ * ```
2766
2976
  */
2767
2977
  export declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
2768
2978
  /**
@@ -2772,6 +2982,14 @@ export declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Ite
2772
2982
  * @param sorter Sorter to use for sorting
2773
2983
  * @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
2774
2984
  * @returns Sorted array
2985
+ *
2986
+ * @example
2987
+ * ```typescript
2988
+ * sort(
2989
+ * [{id: 3}, {id: 1}, {id: 2}],
2990
+ * {key: 'id', direction: 'asc'},
2991
+ * ); // => [{id: 1}, {id: 2}, {id: 3}]
2992
+ * ```
2775
2993
  */
2776
2994
  export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
2777
2995
  /**
@@ -2780,6 +2998,11 @@ export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, des
2780
2998
  * @param array Array to sort
2781
2999
  * @param descending Sort in descending order? _(defaults to `false`)_
2782
3000
  * @returns Sorted array
3001
+ *
3002
+ * @example
3003
+ * ```typescript
3004
+ * sort([3, 1, 2]); // => [1, 2, 3]
3005
+ * ```
2783
3006
  */
2784
3007
  export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
2785
3008
  export declare namespace sort {
@@ -4200,6 +4423,14 @@ export declare namespace pipe {
4200
4423
  *
4201
4424
  * @param value String to convert
4202
4425
  * @returns Camel-cased string
4426
+ *
4427
+ * @example
4428
+ * ```typescript
4429
+ * camelCase('this is camel case'); // => 'thisIsCamelCase'
4430
+ * camelCase('ThisIsCamelCase'); // => 'thisIsCamelCase'
4431
+ * camelCase('this-is-camel-case'); // => 'thisIsCamelCase'
4432
+ * camelCase('this_is_camel_case'); // => 'thisIsCamelCase'
4433
+ * ```
4203
4434
  */
4204
4435
  export declare function camelCase(value: string): string;
4205
4436
  /**
@@ -4207,6 +4438,14 @@ export declare function camelCase(value: string): string;
4207
4438
  *
4208
4439
  * @param value String to capitalize
4209
4440
  * @returns Capitalized string
4441
+ *
4442
+ * @example
4443
+ * ```typescript
4444
+ * capitalize('this is a test'); // => 'This is a test'
4445
+ * capitalize('This Is A Test'); // => 'This is a test'
4446
+ * capitalize('t'); // => 'T'
4447
+ * capitalize(''); // => ''
4448
+ * ```
4210
4449
  */
4211
4450
  export declare function capitalize(value: string): string;
4212
4451
  /**
@@ -4214,6 +4453,14 @@ export declare function capitalize(value: string): string;
4214
4453
  *
4215
4454
  * @param value String to convert
4216
4455
  * @returns Kebab-cased string
4456
+ *
4457
+ * @example
4458
+ * ```typescript
4459
+ * kebabCase('this is kebab case'); // => 'this-is-kebab-case'
4460
+ * kebabCase('ThisIsKebabCase'); // => 'this-is-kebab-case'
4461
+ * kebabCase('this-is-kebab-case'); // => 'this-is-kebab-case'
4462
+ * kebabCase('this_is_kebab_case'); // => 'this-is-kebab-case'
4463
+ * ```
4217
4464
  */
4218
4465
  export declare function kebabCase(value: string): string;
4219
4466
  /**
@@ -4221,6 +4468,13 @@ export declare function kebabCase(value: string): string;
4221
4468
  *
4222
4469
  * @param value String to convert
4223
4470
  * @returns Lower-cased string
4471
+ *
4472
+ * @example
4473
+ * ```typescript
4474
+ * lowerCase('THIS IS A TEST'); // => 'this is a test'
4475
+ * lowerCase('this is a test'); // => 'this is a test'
4476
+ * lowerCase('t'); // => 't'
4477
+ * ```
4224
4478
  */
4225
4479
  export declare function lowerCase(value: string): string;
4226
4480
  /**
@@ -4228,6 +4482,14 @@ export declare function lowerCase(value: string): string;
4228
4482
  *
4229
4483
  * @param value String to convert
4230
4484
  * @returns Pascal-cased string
4485
+ *
4486
+ * @example
4487
+ * ```typescript
4488
+ * pascalCase('this is pascal case'); // => 'ThisIsPascalCase'
4489
+ * pascalCase('ThisIsPascalCase'); // => 'ThisIsPascalCase'
4490
+ * pascalCase('this-is-pascal-case'); // => 'ThisIsPascalCase'
4491
+ * pascalCase('this_is_pascal_case'); // => 'ThisIsPascalCase'
4492
+ * ```
4231
4493
  */
4232
4494
  export declare function pascalCase(value: string): string;
4233
4495
  /**
@@ -4235,6 +4497,14 @@ export declare function pascalCase(value: string): string;
4235
4497
  *
4236
4498
  * @param value String to convert
4237
4499
  * @returns Snake-cased string
4500
+ *
4501
+ * @example
4502
+ * ```typescript
4503
+ * snakeCase('this is snake case'); // => 'this_is_snake_case'
4504
+ * snakeCase('ThisIsSnakeCase'); // => 'this_is_snake_case'
4505
+ * snakeCase('this-is-snake-case'); // => 'this_is_snake_case'
4506
+ * snakeCase('this_is_snake_case'); // => 'this_is_snake_case'
4507
+ * ```
4238
4508
  */
4239
4509
  export declare function snakeCase(value: string): string;
4240
4510
  /**
@@ -4242,6 +4512,14 @@ export declare function snakeCase(value: string): string;
4242
4512
  *
4243
4513
  * @param value String to convert
4244
4514
  * @returns Title-cased string
4515
+ *
4516
+ * @example
4517
+ * ```typescript
4518
+ * titleCase('this is a test'); // => 'This Is A Test'
4519
+ * titleCase('This Is A Test'); // => 'This Is A Test'
4520
+ * titleCase('t'); // => 'T'
4521
+ * titleCase(''); // => ''
4522
+ * ```
4245
4523
  */
4246
4524
  export declare function titleCase(value: string): string;
4247
4525
  /**
@@ -4249,6 +4527,14 @@ export declare function titleCase(value: string): string;
4249
4527
  *
4250
4528
  * @param value String to convert
4251
4529
  * @returns Upper-cased string
4530
+ *
4531
+ * @example
4532
+ * ```typescript
4533
+ * upperCase('this is a test'); // => 'THIS IS A TEST'
4534
+ * upperCase('This Is A Test'); // => 'THIS IS A TEST'
4535
+ * upperCase('t'); // => 'T'
4536
+ * upperCase(''); // => ''
4537
+ * ```
4252
4538
  */
4253
4539
  export declare function upperCase(value: string): string;
4254
4540
  //#endregion
@@ -4271,7 +4557,13 @@ export declare function upperCase(value: string): string;
4271
4557
  * ```
4272
4558
  */
4273
4559
  export declare function getString(value: unknown): string;
4560
+ /**
4561
+ * @internal
4562
+ */
4274
4563
  export declare function ignoreKey(key: string): boolean;
4564
+ /**
4565
+ * @internal
4566
+ */
4275
4567
  export declare function interpolate(strings: TemplateStringsArray, values: unknown[]): string;
4276
4568
  /**
4277
4569
  * Join an array of values into a string _(while ignoring empty values)_
@@ -4281,9 +4573,23 @@ export declare function interpolate(strings: TemplateStringsArray, values: unkno
4281
4573
  * @param array Array of values
4282
4574
  * @param delimiter Delimiter to use between values
4283
4575
  * @returns Joined string
4576
+ * @example
4577
+ * ```typescript
4578
+ * join(['a', 'b', 'c']); // => 'abc'
4579
+ * join(['a', 'b', 'c'], ', '); // => 'a, b, c'
4580
+ * join(['a', '', 'c']); // => 'ac'
4581
+ * join([null, 'b', undefined]); // => 'b'
4582
+ * join([]); // => ''
4583
+ * ```
4284
4584
  */
4285
4585
  export declare function join(array: unknown[], delimiter?: string): string;
4586
+ /**
4587
+ * @internal
4588
+ */
4286
4589
  export declare function tryDecode(value: string): string;
4590
+ /**
4591
+ * @internal
4592
+ */
4287
4593
  export declare function tryEncode(value: boolean | number | string): unknown;
4288
4594
  /**
4289
4595
  * Split a string into words _(and other readable parts)_
@@ -5530,7 +5836,13 @@ export declare function isRejected(value: unknown): value is RejectedPromise;
5530
5836
  * @returns Cancelable _Promise_
5531
5837
  */
5532
5838
  export declare function cancelable<Value>(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void): CancelablePromise<Value>;
5839
+ /**
5840
+ * @internal
5841
+ */
5533
5842
  export declare function handleResult(status: string, parameters: PromiseParameters): void;
5843
+ /**
5844
+ * @internal
5845
+ */
5534
5846
  export declare function settlePromise(settler: (value: any) => void, value: unknown, aborter?: Aborter): void;
5535
5847
  /**
5536
5848
  * Converts a _Promise_ to a promised result
@@ -5548,6 +5860,9 @@ export declare function toResult<Value>(callback: () => Promise<Value>): Promise
5548
5860
  export declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
5549
5861
  //#endregion
5550
5862
  //#region src/promise/timed.d.ts
5863
+ /**
5864
+ * @internal
5865
+ */
5551
5866
  export declare function getTimedPromise<Value>(promise: Promise<Value>, time: number, signal?: AbortSignal): Promise<Value>;
5552
5867
  /**
5553
5868
  * Create a _Promise_ that should be settled within a certain amount of time
@@ -6200,7 +6515,7 @@ export declare function getUuid(): string;
6200
6515
  *
6201
6516
  * @param value JSON string to parse
6202
6517
  * @param reviver Reviver function to transform the parsed values
6203
- * @returns Parsed value or `undefined` if parsing fails
6518
+ * @returns Parsed value, or `undefined` if parsing fails
6204
6519
  */
6205
6520
  export declare function parse(value: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown;
6206
6521
  /**
@@ -6208,6 +6523,13 @@ export declare function parse(value: string, reviver?: (this: unknown, key: stri
6208
6523
  *
6209
6524
  * @param value String to trim
6210
6525
  * @returns Trimmed string
6526
+ * @example
6527
+ * ```typescript
6528
+ * trim(' this is a test '); // => 'this is a test'
6529
+ * trim('this is a test'); // => 'this is a test'
6530
+ * trim(' '); // => ''
6531
+ * trim(''); // => ''
6532
+ * ```
6211
6533
  */
6212
6534
  export declare function trim(value: string): string;
6213
6535
  /**
@@ -6217,6 +6539,13 @@ export declare function trim(value: string): string;
6217
6539
  * @param length Maximum length of the string after truncation
6218
6540
  * @param suffix Suffix to append to the truncated string
6219
6541
  * @returns Truncated string
6542
+ * @example
6543
+ * ```typescript
6544
+ * truncate('this is a test', 7); // => 'this is'
6545
+ * truncate('this is a test', 7, '...'); // => 'this ...'
6546
+ * truncate('this is a test', 20); // => 'this is a test'
6547
+ * truncate('this is a test', 0); // => ''
6548
+ * ```
6220
6549
  */
6221
6550
  export declare function truncate(value: string, length: number, suffix?: string): string;
6222
6551
  //#endregion
@@ -6228,6 +6557,14 @@ export declare function truncate(value: string, length: number, suffix?: string)
6228
6557
  * @param needle String to look for
6229
6558
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
6230
6559
  * @returns `true` if the string ends with the given substring, otherwise `false`
6560
+ *
6561
+ * @example
6562
+ * ```typescript
6563
+ * endsWith('this is a test', 'test'); // => true
6564
+ * endsWith('this is a test', 'Test'); // => false
6565
+ * endsWith('this is a test', 'Test', true); // => true
6566
+ * endsWith('this is a test', 'not'); // => false
6567
+ * ```
6231
6568
  */
6232
6569
  export declare function endsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
6233
6570
  /**
@@ -6237,6 +6574,14 @@ export declare function endsWith(haystack: string, needle: string, ignoreCase?:
6237
6574
  * @param needle String to look for
6238
6575
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
6239
6576
  * @returns `true` if the string includes the given substring, otherwise `false`
6577
+ *
6578
+ * @example
6579
+ * ```typescript
6580
+ * includes('this is a test', 'is'); // => true
6581
+ * includes('this is a test', 'Is'); // => false
6582
+ * includes('this is a test', 'Is', true); // => true
6583
+ * includes('this is a test', 'not'); // => false
6584
+ * ```
6240
6585
  */
6241
6586
  export declare function includes(haystack: string, needle: string, ignoreCase?: boolean): boolean;
6242
6587
  /**
@@ -6246,6 +6591,14 @@ export declare function includes(haystack: string, needle: string, ignoreCase?:
6246
6591
  * @param needle String to look for
6247
6592
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
6248
6593
  * @returns `true` if the string starts with the given substring, otherwise `false`
6594
+ *
6595
+ * @example
6596
+ * ```typescript
6597
+ * startsWith('this is a test', 'this'); // => true
6598
+ * startsWith('this is a test', 'This'); // => false
6599
+ * startsWith('this is a test', 'This', true); // => true
6600
+ * startsWith('this is a test', 'not'); // => false
6601
+ * ```
6249
6602
  */
6250
6603
  export declare function startsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
6251
6604
  //#endregion
@@ -6391,6 +6744,10 @@ export declare function template(strings: TemplateStringsArray, ...values: unkno
6391
6744
  * @param variables Variables to use
6392
6745
  * @param options Templating options
6393
6746
  * @returns Templated string
6747
+ * @example
6748
+ * ```typescript
6749
+ * template('Hello, {{name}}!', {name: 'World'}); // => 'Hello, World!'
6750
+ * ```
6394
6751
  */
6395
6752
  export declare function template(value: string, variables?: PlainObject, options?: Partial<TemplateOptions>): string;
6396
6753
  export declare namespace template {
@@ -6769,7 +7126,7 @@ type BaseOptions = {
6769
7126
  /**
6770
7127
  * Key _(or key epxressions)_ for values that should be replaced
6771
7128
  *
6772
- * ```ts
7129
+ * ```typescript
6773
7130
  * merge([{items: [1, 2, 3]}, {items: [99]}]); // => {items: [99]}
6774
7131
  * ```
6775
7132
  */
@@ -6777,7 +7134,7 @@ type BaseOptions = {
6777
7134
  /**
6778
7135
  * Skip nullable values when merging objects?
6779
7136
  *
6780
- * ```ts
7137
+ * ```typescript
6781
7138
  * merge({a: 1, b: 2}, {b: null, c: 3}, {d: null}); // => {a: 1, b: 2, c: 3}
6782
7139
  * ```
6783
7140
  */
@@ -6785,7 +7142,7 @@ type BaseOptions = {
6785
7142
  /**
6786
7143
  * Skip nullable values when merging arrays?
6787
7144
  *
6788
- * ```ts
7145
+ * ```typescript
6789
7146
  * merge([1, 2, 3], [null, null, 99]); // => [1, 2, 99]
6790
7147
  * ```
6791
7148
  */
@@ -7676,6 +8033,14 @@ export declare function isRgbColor(value: unknown): value is RGBColor;
7676
8033
  * @param value Value to normalize
7677
8034
  * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
7678
8035
  * @returns Normalized hex color
8036
+ *
8037
+ * @example
8038
+ * ```typescript
8039
+ * getNormalizedHex('#abc'); // => '#aabbcc'
8040
+ * getNormalizedHex('#abc', true); // => '#aabbccff'
8041
+ * getNormalizedHex(123); // => '#000000'
8042
+ * getNormalizedHex(123, true); // => '#000000ff'
8043
+ * ```
7679
8044
  */
7680
8045
  export declare function getNormalizedHex(value: unknown, alpha?: boolean): string;
7681
8046
  /**
@@ -8220,7 +8585,19 @@ type TimeLogger = {
8220
8585
  //#endregion
8221
8586
  //#region src/logger.d.ts
8222
8587
  declare function TimeLogger(this: any, label: string): void;
8588
+ /**
8589
+ * Is the value a _Logger_?
8590
+ *
8591
+ * @param value Value to check
8592
+ * @returns `true` if the value is a _Logger_, otherwise `false`
8593
+ */
8223
8594
  declare function isLogger(value: unknown): value is Lumberjack;
8595
+ /**
8596
+ * Is the value a _TimeLogger_?
8597
+ *
8598
+ * @param value Value to check
8599
+ * @returns `true` if the value is a _TimeLogger_, otherwise `false`
8600
+ */
8224
8601
  declare function isTimeLogger(value: unknown): value is TimeLogger;
8225
8602
  /**
8226
8603
  * A logger that can be used to log messages to the console
@@ -8233,6 +8610,11 @@ declare const Logger: Lumberjack;
8233
8610
  /**
8234
8611
  * Get the maximum value from a list of items
8235
8612
  *
8613
+ * @param items List of items
8614
+ * @param callback Callback to get an item's value
8615
+ * @param first Return only the first item with the maximum value
8616
+ * @returns Item with the maximum value, or `undefined` if no maximum can be found
8617
+ *
8236
8618
  * @example
8237
8619
  * ```typescript
8238
8620
  * max(
@@ -8242,16 +8624,16 @@ declare const Logger: Lumberjack;
8242
8624
  *
8243
8625
  * max([], item => item.value); // => []
8244
8626
  * ```
8245
- *
8246
- * @param items List of items
8247
- * @param callback Callback to get an item's value
8248
- * @param first Return only the first item with the maximum value
8249
- * @returns Item with the maximum value, or `undefined` if no maximum can be found
8250
8627
  */
8251
8628
  export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
8252
8629
  /**
8253
8630
  * Get the maximum value from a list of items
8254
8631
  *
8632
+ * @param items List of items
8633
+ * @param key Key to use for value
8634
+ * @param first Return only the first item with the maximum value
8635
+ * @returns Item with the maximum value, or `undefined` if no maximum can be found
8636
+ *
8255
8637
  * @example
8256
8638
  * ```typescript
8257
8639
  * max(
@@ -8261,16 +8643,15 @@ export declare function max<Item>(items: Item[], callback: (item: Item, index: n
8261
8643
  *
8262
8644
  * max([], 'value'); // => []
8263
8645
  * ```
8264
- *
8265
- * @param items List of items
8266
- * @param key Key to use for value
8267
- * @param first Return only the first item with the maximum value
8268
- * @returns Item with the maximum value, or `undefined` if no maximum can be found
8269
8646
  */
8270
8647
  export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
8271
8648
  /**
8272
8649
  * Get the maximum value from a list of items
8273
8650
  *
8651
+ * @param items List of items
8652
+ * @param callback Callback to get an item's value
8653
+ * @returns Items with the maximum value
8654
+ *
8274
8655
  * @example
8275
8656
  * ```typescript
8276
8657
  * max(
@@ -8280,15 +8661,15 @@ export declare function max<Item extends PlainObject>(items: Item[], key: keyof
8280
8661
  *
8281
8662
  * max([], item => item.value); // => []
8282
8663
  * ```
8283
- *
8284
- * @param items List of items
8285
- * @param callback Callback to get an item's value
8286
- * @returns Items with the maximum value
8287
8664
  */
8288
8665
  export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
8289
8666
  /**
8290
8667
  * Get the maximum value from a list of items
8291
8668
  *
8669
+ * @param items List of items
8670
+ * @param key Key to use for value
8671
+ * @returns Items with the maximum value
8672
+ *
8292
8673
  * @example
8293
8674
  * ```typescript
8294
8675
  * max(
@@ -8298,23 +8679,19 @@ export declare function max<Item>(items: Item[], callback: (item: Item, index: n
8298
8679
  *
8299
8680
  * max([], 'value'); // => []
8300
8681
  * ```
8301
- *
8302
- * @param items List of items
8303
- * @param key Key to use for value
8304
- * @returns Items with the maximum value
8305
8682
  */
8306
8683
  export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
8307
8684
  /**
8308
8685
  * Get the maximum value from a list of numbers
8309
8686
  *
8687
+ * @param values List of numbers
8688
+ * @returns Maximum value, or `Number.NaN` if no maximum can be found
8689
+ *
8310
8690
  * @example
8311
8691
  * ```typescript
8312
8692
  * max([10, 20]); // => 20
8313
8693
  * max([]); // => Number.NaN
8314
8694
  * ```
8315
- *
8316
- * @param values List of numbers
8317
- * @returns Maximum value, or `Number.NaN` if no maximum can be found
8318
8695
  */
8319
8696
  export declare function max(values: number[]): number;
8320
8697
  /**
@@ -8324,6 +8701,17 @@ export declare function max(values: number[]): number;
8324
8701
  * @param callback Callback to get an item's value
8325
8702
  * @param first Return only the first item with the minimum value
8326
8703
  * @returns First item with the minimum value, or `undefined` if no minimum can be found
8704
+ *
8705
+ * @example
8706
+ * ```typescript
8707
+ * min(
8708
+ * [{id: 1, value: 10}, {id: 2, value: 5}],
8709
+ * item => item.value,
8710
+ * true,
8711
+ * ); // => {id: 2, value: 5}
8712
+ *
8713
+ * min([], item => item.value, true); // => undefined
8714
+ * ```
8327
8715
  */
8328
8716
  export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
8329
8717
  /**
@@ -8333,6 +8721,17 @@ export declare function min<Item>(items: Item[], callback: (item: Item, index: n
8333
8721
  * @param key Key to use for value
8334
8722
  * @param first Return only the first item with the minimum value
8335
8723
  * @returns First item with the minimum value, or `undefined` if no minimum can be found
8724
+ *
8725
+ * @example
8726
+ * ```typescript
8727
+ * min(
8728
+ * [{id: 1, value: 10}, {id: 2, value: 5}],
8729
+ * 'value',
8730
+ * true,
8731
+ * ); // => {id: 2, value: 5}
8732
+ *
8733
+ * min([], 'value', true); // => undefined
8734
+ * ```
8336
8735
  */
8337
8736
  export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
8338
8737
  /**
@@ -8341,6 +8740,16 @@ export declare function min<Item extends PlainObject>(items: Item[], key: keyof
8341
8740
  * @param items List of items
8342
8741
  * @param callback Callback to get an item's value
8343
8742
  * @returns Items with the minimum value
8743
+ *
8744
+ * @example
8745
+ * ```typescript
8746
+ * min(
8747
+ * [{id: 1, value: 10}, {id: 2, value: 5}],
8748
+ * item => item.value,
8749
+ * ); // => [{id: 2, value: 5}]
8750
+ *
8751
+ * min([], item => item.value); // => []
8752
+ * ```
8344
8753
  */
8345
8754
  export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
8346
8755
  /**
@@ -8349,6 +8758,16 @@ export declare function min<Item>(items: Item[], callback: (item: Item, index: n
8349
8758
  * @param items List of items
8350
8759
  * @param key Key to use for value
8351
8760
  * @returns Items with the minimum value
8761
+ *
8762
+ * @example
8763
+ * ```typescript
8764
+ * min(
8765
+ * [{id: 1, value: 10}, {id: 2, value: 5}],
8766
+ * 'value',
8767
+ * ); // => [{id: 2, value: 5}]
8768
+ *
8769
+ * min([], 'value'); // => []
8770
+ * ```
8352
8771
  */
8353
8772
  export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
8354
8773
  /**
@@ -8356,6 +8775,12 @@ export declare function min<Item extends PlainObject>(items: Item[], key: keyof
8356
8775
  *
8357
8776
  * @param values List of numbers
8358
8777
  * @returns Minimum value, or `Number.NaN` if no minimum can be found
8778
+ *
8779
+ * @example
8780
+ * ```typescript
8781
+ * min([10, 20]); // => 10
8782
+ * min([]); // => Number.NaN
8783
+ * ```
8359
8784
  */
8360
8785
  export declare function min(values: number[]): number;
8361
8786
  //#endregion
@@ -8366,6 +8791,13 @@ export declare function min(values: number[]): number;
8366
8791
  * @param value Number to round down
8367
8792
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
8368
8793
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8794
+ *
8795
+ * @example
8796
+ * ```typescript
8797
+ * floor(10.567, 2); // => 10.56
8798
+ * floor(10.567); // => 10
8799
+ * floor('abc'); // => Number.NaN
8800
+ * ```
8369
8801
  */
8370
8802
  export declare function floor(value: number, decimals?: number): number;
8371
8803
  /**
@@ -8374,6 +8806,13 @@ export declare function floor(value: number, decimals?: number): number;
8374
8806
  * @param value Number to round
8375
8807
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
8376
8808
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8809
+ *
8810
+ * @example
8811
+ * ```typescript
8812
+ * round(10.567, 2); // => 10.57
8813
+ * round(10.567); // => 11
8814
+ * round('abc'); // => Number.NaN
8815
+ * ```
8377
8816
  */
8378
8817
  export declare function round(value: number, decimals?: number): number;
8379
8818
  //#endregion
@@ -8384,6 +8823,16 @@ export declare function round(value: number, decimals?: number): number;
8384
8823
  * @param items List of items
8385
8824
  * @param callback Callback to get an item's value
8386
8825
  * @returns Average value, or `Number.NaN` if no average can be calculated
8826
+ *
8827
+ * @example
8828
+ * ```typescript
8829
+ * average([
8830
+ * {value: 1},
8831
+ * {value: 2},
8832
+ * {value: 3},
8833
+ * ], item => item.value); // => 2
8834
+ * average([{value: 1}], item => item.nope); // => Number.NaN
8835
+ * ```
8387
8836
  */
8388
8837
  export declare function average<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
8389
8838
  /**
@@ -8392,6 +8841,12 @@ export declare function average<Item>(items: Item[], callback: (item: Item, inde
8392
8841
  * @param items List of items
8393
8842
  * @param key Key to use for value
8394
8843
  * @returns Average value, or `Number.NaN` if no average can be calculated
8844
+ *
8845
+ * @example
8846
+ * ```typescript
8847
+ * average([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 2
8848
+ * average([{value: 1}], 'nope'); // => Number.NaN
8849
+ * ```
8395
8850
  */
8396
8851
  export declare function average<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
8397
8852
  /**
@@ -8399,6 +8854,12 @@ export declare function average<Item extends PlainObject>(items: Item[], key: ke
8399
8854
  *
8400
8855
  * @param numbers List of numbers
8401
8856
  * @returns Average value, or `Number.NaN` if no average can be calculated
8857
+ *
8858
+ * @example
8859
+ * ```typescript
8860
+ * average([1, 2, 3, 4, 5]); // => 3
8861
+ * average([]); // => Number.NaN
8862
+ * ```
8402
8863
  */
8403
8864
  export declare function average(numbers: number[]): number;
8404
8865
  /**
@@ -8407,6 +8868,13 @@ export declare function average(numbers: number[]): number;
8407
8868
  * @param value Number to round up
8408
8869
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
8409
8870
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
8871
+ *
8872
+ * @example
8873
+ * ```typescript
8874
+ * ceil(1.234, 2); // => 1.24
8875
+ * ceil(1.234); // => 2
8876
+ * ceil('abc'); // => Number.NaN
8877
+ * ```
8410
8878
  */
8411
8879
  export declare function ceil(value: number, decimals?: number): number;
8412
8880
  /**
@@ -8416,6 +8884,14 @@ export declare function ceil(value: number, decimals?: number): number;
8416
8884
  * @param callback Callback to get an item's value
8417
8885
  * @param value Value to match and count
8418
8886
  * @returns Number of items that match the condition, or `Number.NaN` if no count can be calculated
8887
+ *
8888
+ * @example
8889
+ * ```typescript
8890
+ * count([1, 2, 3, 2], (item) => item, 2); // => 2
8891
+ * count([{value: 1}, {value: 2}, {value: 3}], 'value', 2); // => 1
8892
+ * count([1, 2, 3], (item) => item, 4); // => 0
8893
+ * count([], (item) => item, 1); // => Number.NaN
8894
+ * ```
8419
8895
  */
8420
8896
  export declare function count<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown, value: unknown): number;
8421
8897
  /**
@@ -8425,6 +8901,12 @@ export declare function count<Item>(array: Item[], callback: (item: Item, index:
8425
8901
  * @param key Key to use for value
8426
8902
  * @param value Value to match and count
8427
8903
  * @returns Number of items with the specified key value, or `Number.NaN` if no count can be calculated
8904
+ *
8905
+ * @example
8906
+ * ```typescript
8907
+ * count([{value: 1}, {value: 2}, {value: 3}], 'value', 2); // => 1
8908
+ * count([{value: 1}], 'nope', 1); // => Number.NaN
8909
+ * ```
8428
8910
  */
8429
8911
  export declare function count<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
8430
8912
  /**
@@ -8432,6 +8914,12 @@ export declare function count<Item extends PlainObject, ItemKey extends keyof It
8432
8914
  *
8433
8915
  * @param values Array to count for
8434
8916
  * @returns Number of items, or `Number.NaN` if no count can be calculated
8917
+ *
8918
+ * @example
8919
+ * ```typescript
8920
+ * count([1, 2, 3]); // => 3
8921
+ * count([]); // => Number.NaN
8922
+ * ```
8435
8923
  */
8436
8924
  export declare function count(values: unknown[]): number;
8437
8925
  /**
@@ -8440,6 +8928,13 @@ export declare function count(values: unknown[]): number;
8440
8928
  * @param array List of items
8441
8929
  * @param callback Callback to get an item's value
8442
8930
  * @returns Median value, or `Number.NaN` if no median can be calculated
8931
+ *
8932
+ * @example
8933
+ * ```typescript
8934
+ * median([1, 2, 3, 4, 5]); // => 3
8935
+ * median([1, 2, 3, 4]); // => 2.5
8936
+ * median([]); // => Number.NaN
8937
+ * ```
8443
8938
  */
8444
8939
  export declare function median<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
8445
8940
  /**
@@ -8448,6 +8943,13 @@ export declare function median<Item>(array: Item[], callback: (item: Item, index
8448
8943
  * @param array List of items
8449
8944
  * @param key Key to use for value
8450
8945
  * @returns Median value, or `Number.NaN` if no median can be calculated
8946
+ *
8947
+ * @example
8948
+ * ```typescript
8949
+ * median([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 2
8950
+ * median([{value: 1}, {value: 2}, {value: 3}, {value: 4}], 'value'); // => 2.5
8951
+ * median([], 'value'); // => Number.NaN
8952
+ * ```
8451
8953
  */
8452
8954
  export declare function median<Item extends PlainObject>(array: Item[], key: keyof NumericalValues<Item>): number;
8453
8955
  /**
@@ -8455,6 +8957,13 @@ export declare function median<Item extends PlainObject>(array: Item[], key: key
8455
8957
  *
8456
8958
  * @param array List of numbers
8457
8959
  * @returns Median value, or `Number.NaN` if no median can be calculated
8960
+ *
8961
+ * @example
8962
+ * ```typescript
8963
+ * median([1, 2, 3, 4, 5]); // => 3
8964
+ * median([1, 2, 3, 4]); // => 2.5
8965
+ * median([]); // => Number.NaN
8966
+ * ```
8458
8967
  */
8459
8968
  export declare function median(array: number[]): number;
8460
8969
  /**
@@ -8463,6 +8972,13 @@ export declare function median(array: number[]): number;
8463
8972
  * @param items List of items
8464
8973
  * @param callback Callback to get an item's value
8465
8974
  * @returns Sum of the values, or `Number.NaN` if no sum can be calculated
8975
+ *
8976
+ * @example
8977
+ * ```typescript
8978
+ * sum([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 6
8979
+ * sum([{value: 1}, {value: 2}, {value: 3}], item => item.value); // => 6
8980
+ * sum([]); // => Number.NaN
8981
+ * ```
8466
8982
  */
8467
8983
  export declare function sum<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
8468
8984
  /**
@@ -8471,6 +8987,13 @@ export declare function sum<Item>(items: Item[], callback: (item: Item, index: n
8471
8987
  * @param items List of items
8472
8988
  * @param key Key to use for value
8473
8989
  * @returns Sum of the values, or `Number.NaN` if no sum can be calculated
8990
+ *
8991
+ * @example
8992
+ * ```typescript
8993
+ * sum([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 6
8994
+ * sum([{value: 1}, {value: 2}, {value: 3}], item => item.value); // => 6
8995
+ * sum([]); // => Number.NaN
8996
+ * ```
8474
8997
  */
8475
8998
  export declare function sum<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
8476
8999
  /**
@@ -8478,6 +9001,12 @@ export declare function sum<Item extends PlainObject>(items: Item[], key: keyof
8478
9001
  *
8479
9002
  * @param values List of numbers
8480
9003
  * @returns Sum of the numbers, or `Number.NaN` if no sum can be calculated
9004
+ *
9005
+ * @example
9006
+ * ```typescript
9007
+ * sum([1, 2, 3]); // => 6
9008
+ * sum([]); // => Number.NaN
9009
+ * ```
8481
9010
  */
8482
9011
  export declare function sum(values: number[]): number;
8483
9012
  //#endregion
@@ -8489,6 +9018,13 @@ export declare function sum(values: number[]): number;
8489
9018
  * @param minimum Minimum value
8490
9019
  * @param maximum Maximum value _(inclusive)_
8491
9020
  * @returns `true` if the value is between the minimum and maximum, otherwise `false`
9021
+ *
9022
+ * @example
9023
+ * ```typescript
9024
+ * between(5, 1, 10); // => true
9025
+ * between(0, 1, 10); // => false
9026
+ * between(10, 10, 10); // => true
9027
+ * ```
8492
9028
  */
8493
9029
  export declare function between(value: number, minimum: number, maximum: number): boolean;
8494
9030
  /**
@@ -8514,6 +9050,17 @@ export declare function clamp(value: number, minimum: number, maximum: number, l
8514
9050
  *
8515
9051
  * @param value Original value
8516
9052
  * @returns Original value as a number, or `Number.NaN` if the value is unable to be parsed
9053
+ *
9054
+ * @example
9055
+ * ```typescript
9056
+ * getNumber(null) // => Number.NaN
9057
+ * getNumber('foo') // => Number.NaN
9058
+ * getNumber('123') // => 123
9059
+ * getNumber(true) // => 1
9060
+ * getNumber([1, 2, 3]) // => Number.NaN
9061
+ * getNumber({a: 1}) // => Number.NaN
9062
+ * getNumber(() => 123) // => 123
9063
+ * ```
8517
9064
  */
8518
9065
  export declare function getNumber(value: unknown): number;
8519
9066
  //#endregion
@@ -8744,7 +9291,6 @@ export declare function isKeyedQueue(value: unknown): value is KeyedQueue<Generi
8744
9291
  * @returns `true` if the value is a queue, otherwise `false`
8745
9292
  */
8746
9293
  export declare function isQueue(value: unknown): value is Queue<GenericCallback | GenericAsyncCallback>;
8747
- export declare function isQueueInstance<Instance>(name: string, value: unknown): value is Instance;
8748
9294
  /**
8749
9295
  * Create a keyed queue for an asynchronous callback function, where each key has its own queue
8750
9296
  *