@oscarpalmer/atoms 0.200.0 → 0.202.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -43,7 +43,23 @@ export type GenericCallback = (...args: any[]) => any;
43
43
  * A generic key type
44
44
  */
45
45
  type Key$1 = number | string;
46
+ /**
47
+ * The `PropertyKey`-safe value of `Item`'s `ItemKey` property
48
+ */
46
49
  export type KeyedValue<Item, ItemKey extends keyof Item> = Item[ItemKey] extends PropertyKey ? Item[ItemKey] : never;
50
+ /**
51
+ * A key of `Item`, or a callback returning `Return`, used to derive a value from an item
52
+ */
53
+ export type KeyOrCallback<Item, Return = unknown> = ((item: Item, index: number, array: Item[]) => Return) | (Item extends PlainObject ? keyof Item : never);
54
+ /**
55
+ * The `PropertyKey`-safe value resolved from a `KeyOrCallback<Item, Key>` argument, for use as a
56
+ * `Record` or `Map` key
57
+ */
58
+ export type KeyOrCallbackKey<Item, Arg extends KeyOrCallback<Item, Key$1>> = Arg extends ((item: Item, index: number, array: Item[]) => Key$1) ? ReturnType<Arg> : Arg extends keyof Item ? KeyedValue<Item, Arg> : never;
59
+ /**
60
+ * The value resolved from a `KeyOrCallback` argument against `Item`
61
+ */
62
+ export type KeyOrCallbackValue<Item, Arg extends KeyOrCallback<Item>> = Arg extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Arg> : Arg extends keyof Item ? Item[Arg] : never;
47
63
  /**
48
64
  * A nested array
49
65
  */
@@ -450,13 +466,13 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item):
450
466
  //#endregion
451
467
  //#region src/array/group-by.d.ts
452
468
  /**
453
- * Create a record from an array of items using a specific key and value
469
+ * Create a record from an array of items using a specific key
454
470
  *
455
471
  * If multiple items have the same key, the latest item's value will be used
456
472
  *
457
473
  * @param array Array to group
458
- * @param key Callback to get an item's grouping key
459
- * @param value Callback to get an item's value
474
+ * @param key Callback or key to use for grouping
475
+ * @param value Callback or key to use for value, defaulting to the item itself
460
476
  * @returns Record of keyed values
461
477
  *
462
478
  * @example
@@ -468,74 +484,14 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item):
468
484
  * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
469
485
  * ```
470
486
  */
471
- export 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>>>;
472
- /**
473
- * Create a record from an array of items using a specific key and value
474
- *
475
- * If multiple items have the same key, the latest item's value will be used
476
- *
477
- * @param array Array to group
478
- * @param key Callback to get an item's grouping key
479
- * @param value Key to use for value
480
- * @returns Record of keyed values
481
- *
482
- * @example
483
- * ```typescript
484
- * groupBy(
485
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
486
- * item => item.value,
487
- * 'id'
488
- * ); // => {10: 3, 20: 2}
489
- * ```
490
- */
491
- export 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]>;
492
- /**
493
- * Create a record from an array of items using a specific key and value
494
- *
495
- * If multiple items have the same key, the latest item's value will be used
496
- *
497
- * @param array Array to group
498
- * @param key Key to use for grouping
499
- * @param value Callback to get an item's value
500
- * @returns Record of keyed values
501
- *
502
- * @example
503
- * ```typescript
504
- * groupBy(
505
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
506
- * 'value',
507
- * item => item,
508
- * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
509
- * ```
510
- */
511
- export 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>>>;
512
- /**
513
- * Create a record from an array of items using a specific key and value
514
- *
515
- * If multiple items have the same key, the latest item's value will be used
516
- *
517
- * @param array Array to group
518
- * @param key Key to use for grouping
519
- * @param value Key to use for value
520
- * @returns Record of keyed values
521
- *
522
- * @example
523
- * ```typescript
524
- * groupBy(
525
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
526
- * 'value',
527
- * 'id'
528
- * ); // => {10: 3, 20: 2}
529
- * ```
530
- */
531
- export 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]>>;
487
+ export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
532
488
  /**
533
489
  * Create a record from an array of items using a specific key
534
490
  *
535
491
  * If multiple items have the same key, the latest item will be used
536
492
  *
537
493
  * @param array Array to group
538
- * @param callback Callback to get an item's grouping key
494
+ * @param key Callback or key to use for grouping
539
495
  * @returns Record of keyed items
540
496
  *
541
497
  * @example
@@ -546,25 +502,7 @@ export declare function groupBy<Item extends PlainObject, ItemKey extends keyof
546
502
  * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
547
503
  * ```
548
504
  */
549
- export declare function groupBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
550
- /**
551
- * Create a record from an array of items using a specific key
552
- *
553
- * If multiple items have the same key, the latest item will be used
554
- *
555
- * @param array Array to group
556
- * @param key Key to use for grouping
557
- * @returns Record of keyed items
558
- *
559
- * @example
560
- * ```typescript
561
- * groupBy(
562
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
563
- * 'value',
564
- * ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
565
- * ```
566
- */
567
- export declare function groupBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
505
+ export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
568
506
  /**
569
507
  * Create a record from an array of items _(using indices as keys)_
570
508
  *
@@ -583,36 +521,13 @@ export declare namespace groupBy {
583
521
  var arrays: typeof groupArraysBy;
584
522
  }
585
523
  /**
586
- * Create a record from an array of items using a specific key and value, grouping values into arrays
587
- *
588
- * _Available as `groupArraysBy` and `groupBy.arrays`_
589
- *
590
- * @param array Array to group
591
- * @param key Callback to get an item's grouping key
592
- * @param value Callback to get an item's value
593
- * @returns Record of keyed values
594
- *
595
- * @example
596
- * ```typescript
597
- * groupArraysBy(
598
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
599
- * item => item.value,
600
- * item => item,
601
- * ); // => {
602
- * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
603
- * // 20: [{id: 2, value: 20}],
604
- * // }
605
- * ```
606
- */
607
- export 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>, Array<ReturnType<ValueCallback>>>;
608
- /**
609
- * Create a record from an array of items using a specific key and value, grouping values into arrays
524
+ * Create a record from an array of items using a specific key, grouping values into arrays
610
525
  *
611
526
  * _Available as `groupArraysBy` and `groupBy.arrays`_
612
527
  *
613
528
  * @param array Array to group
614
- * @param key Callback to get an item's grouping key
615
- * @param value Key to use for value
529
+ * @param key Callback or key to use for grouping
530
+ * @param value Callback or key to use for value, defaulting to the item itself
616
531
  * @returns Record of keyed values
617
532
  *
618
533
  * @example
@@ -620,29 +535,6 @@ export declare function groupArraysBy<Item, KeyCallback extends (item: Item, ind
620
535
  * groupArraysBy(
621
536
  * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
622
537
  * item => item.value,
623
- * 'id',
624
- * ); // => {
625
- * // 10: [1, 3],
626
- * // 20: [2],
627
- * // }
628
- * ```
629
- */
630
- export 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][]>;
631
- /**
632
- * Create a record from an array of items using a specific key and value, grouping values into arrays
633
- *
634
- * _Available as `groupArraysBy` and `groupBy.arrays`_
635
- *
636
- * @param array Array to group
637
- * @param key Key to use for grouping
638
- * @param value Callback to get an item's value
639
- * @returns Record of keyed values
640
- *
641
- * @example
642
- * ```typescript
643
- * groupArraysBy(
644
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
645
- * 'value',
646
538
  * item => item,
647
539
  * ); // => {
648
540
  * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
@@ -650,37 +542,14 @@ export declare function groupArraysBy<Item extends PlainObject, KeyCallback exte
650
542
  * // }
651
543
  * ```
652
544
  */
653
- export declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ValueCallback>>>>;
654
- /**
655
- * Create a record from an array of items using a specific key and value, grouping values into arrays
656
- *
657
- * _Available as `groupArraysBy` and `groupBy.arrays`_
658
- *
659
- * @param array Array to group
660
- * @param key Key to use for grouping
661
- * @param value Key to use for value
662
- * @returns Record of keyed values
663
- *
664
- * @example
665
- * ```typescript
666
- * groupArraysBy(
667
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
668
- * 'value',
669
- * 'id',
670
- * ); // => {
671
- * // 10: [1, 3],
672
- * // 20: [2],
673
- * // }
674
- * ```
675
- */
676
- export 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][]>>;
545
+ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
677
546
  /**
678
547
  * Create a record from an array of items using a specific key, grouping items into arrays
679
548
  *
680
549
  * _Available as `groupArraysBy` and `groupBy.arrays`_
681
550
  *
682
551
  * @param array Array to group
683
- * @param callback Callback to get an item's grouping key
552
+ * @param key Callback or key to use for grouping
684
553
  * @returns Record of keyed items
685
554
  *
686
555
  * @example
@@ -694,28 +563,7 @@ export declare function groupArraysBy<Item extends PlainObject, ItemKey extends
694
563
  * // }
695
564
  * ```
696
565
  */
697
- export declare function groupArraysBy<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
698
- /**
699
- * Create a record from an array of items using a specific key, grouping items into arrays
700
- *
701
- * _Available as `groupArraysBy` and `groupBy.arrays`_
702
- *
703
- * @param array Array to group
704
- * @param key Key to use for grouping
705
- * @returns Record of keyed items
706
- *
707
- * @example
708
- * ```typescript
709
- * groupArraysBy(
710
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
711
- * 'value',
712
- * ); // => {
713
- * // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
714
- * // 20: [{id: 2, value: 20}],
715
- * // }
716
- * ```
717
- */
718
- export declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
566
+ export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
719
567
  //#endregion
720
568
  //#region src/internal/array/chunk.d.ts
721
569
  /**
@@ -1778,110 +1626,112 @@ export declare function push<Item>(array: Item[], pushed: Item[]): number;
1778
1626
  export declare function reverse<Item>(array: Item[]): Item[];
1779
1627
  //#endregion
1780
1628
  //#region src/array/select.d.ts
1629
+ type MapKeyOrCallback<Item> = ((item: Item, index: number, array: Item[]) => unknown) | (Item extends PlainObject ? keyof Item : never);
1630
+ type Mapped<Item, Map extends MapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
1631
+ type ObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
1781
1632
  /**
1782
- * Get a filtered and mapped array of items
1633
+ * Get a mapped and filtered array of items
1783
1634
  *
1784
1635
  * @param array Array to search in
1785
- * @param filterCallback Callback to get an item's value for matching
1636
+ * @param map Callback or key to map the items
1637
+ * @param filterCallback Callback to get a mapped value's value for matching
1786
1638
  * @param filterValue Value to match against
1787
- * @param mapCallback Callback to map the matched items
1788
- * @returns Filtered and mapped array of items
1639
+ * @returns Mapped and filtered array of items
1789
1640
  *
1790
1641
  * @example
1791
1642
  * ```typescript
1792
- * select(
1643
+ * reverseSelect(
1793
1644
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1794
- * item => item.id,
1795
- * 2,
1796
1645
  * item => item.name,
1646
+ * value => value.length,
1647
+ * 3,
1797
1648
  * ); // => ['Bob']
1798
1649
  * ```
1799
1650
  */
1800
- export 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>>;
1651
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>, FilterCallback extends (item: Mapped<Item, Map>, index: number, array: Item[]) => unknown>(array: Item[], map: Map, filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>): Array<Mapped<Item, Map>>;
1801
1652
  /**
1802
- * Get a filtered and mapped array of items
1653
+ * Get a mapped and filtered array of items
1803
1654
  *
1804
1655
  * @param array Array to search in
1805
- * @param filterCallback Callback to get an item's value for matching
1656
+ * @param map Callback to map the items
1657
+ * @param filterKey Key to get a mapped value's value for matching
1806
1658
  * @param filterValue Value to match against
1807
- * @param mapKey Key to get an item's value for mapping
1808
- * @returns Filtered and mapped array of items
1659
+ * @returns Mapped and filtered array of items
1809
1660
  *
1810
1661
  * @example
1811
1662
  * ```typescript
1812
- * select(
1663
+ * reverseSelect(
1813
1664
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1814
- * item => item.id,
1815
- * 2,
1816
- * 'name',
1817
- * ); // => ['Bob']
1665
+ * item => ({label: item.name}),
1666
+ * 'label',
1667
+ * 'Bob',
1668
+ * ); // => [{label: 'Bob'}]
1818
1669
  * ```
1819
1670
  */
1820
- export 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]>;
1671
+ export declare function reverseSelect<Item, MapCallback extends (item: Item, index: number, array: Item[]) => PlainObject, ItemKey extends keyof ReturnType<MapCallback>>(array: Item[], map: MapCallback, filterKey: ItemKey, filterValue: ReturnType<MapCallback>[ItemKey]): Array<ReturnType<MapCallback>>;
1821
1672
  /**
1822
- * Get a filtered and mapped array of items
1673
+ * Get a mapped and filtered array of items
1823
1674
  *
1824
1675
  * @param array Array to search in
1825
- * @param filterKey Key to get an item's value for matching
1676
+ * @param map Key to map the items
1677
+ * @param filterKey Key to get a mapped value's value for matching
1826
1678
  * @param filterValue Value to match against
1827
- * @param mapCallback Callback to map the matched items
1828
- * @returns Filtered and mapped array of items
1679
+ * @returns Mapped and filtered array of items
1829
1680
  *
1830
1681
  * @example
1831
1682
  * ```typescript
1832
- * select(
1833
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1834
- * 'id',
1835
- * 2,
1836
- * item => item.name,
1837
- * ); // => ['Bob']
1683
+ * reverseSelect(
1684
+ * [{meta: {tag: 'a'}}, {meta: {tag: 'b'}}],
1685
+ * 'meta',
1686
+ * 'tag',
1687
+ * 'b',
1688
+ * ); // => [{tag: 'b'}]
1838
1689
  * ```
1839
1690
  */
1840
- export 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>>;
1691
+ export declare function reverseSelect<Item, MapKey extends ObjectKeysOf<Item>, ItemKey extends keyof Item[MapKey]>(array: Item[], map: MapKey, filterKey: ItemKey, filterValue: Item[MapKey][ItemKey]): Array<Item[MapKey]>;
1841
1692
  /**
1842
- * Get a filtered and mapped array of items
1693
+ * Get a mapped and filtered array of items
1843
1694
  *
1844
1695
  * @param array Array to search in
1845
- * @param filterKey Key to get an item's value for matching
1846
- * @param filterValue Value to match against
1847
- * @param mapKey Key to get an item's value for mapping
1848
- * @returns Filtered and mapped array of items
1696
+ * @param map Callback or key to map the items
1697
+ * @param filter Filter callback to match mapped values
1698
+ * @returns Mapped and filtered array of items
1849
1699
  *
1850
1700
  * @example
1851
1701
  * ```typescript
1852
- * select(
1702
+ * reverseSelect(
1853
1703
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1854
- * 'id',
1855
- * 2,
1856
- * 'name',
1704
+ * item => item.name,
1705
+ * value => value.startsWith('B'),
1857
1706
  * ); // => ['Bob']
1858
1707
  * ```
1859
1708
  */
1860
- export 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]>;
1709
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, filter: (item: Mapped<Item, Map>, index: number, array: Item[]) => boolean): Array<Mapped<Item, Map>>;
1861
1710
  /**
1862
- * Get a filtered and mapped array of items
1711
+ * Get a mapped and filtered array of items
1863
1712
  *
1864
1713
  * @param array Array to search in
1865
- * @param filterCallback Filter callback to match items
1866
- * @param mapCallback Callback to map the matched items
1867
- * @returns Filtered and mapped array of items
1714
+ * @param map Callback or key to map the items
1715
+ * @param value Mapped value to match against
1716
+ * @returns Mapped and filtered array of items
1868
1717
  *
1869
1718
  * @example
1870
1719
  * ```typescript
1871
- * select(
1872
- * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1873
- * item => item.id === 2,
1874
- * item => item.name,
1875
- * ); // => ['Bob']
1720
+ * reverseSelect(
1721
+ * [1, 2, 3, 2, 1],
1722
+ * value => value ** 2,
1723
+ * 4,
1724
+ * ); // => [4, 4]
1876
1725
  * ```
1877
1726
  */
1878
- export 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>>;
1727
+ export declare function reverseSelect<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], map: Map, value: Mapped<Item, Map>): Array<Mapped<Item, Map>>;
1879
1728
  /**
1880
1729
  * Get a filtered and mapped array of items
1881
1730
  *
1882
1731
  * @param array Array to search in
1883
- * @param filterCallback Filter callback to match items
1884
- * @param mapKey Key to get an item's value for mapping
1732
+ * @param filterCallback Callback to get an item's value for matching
1733
+ * @param filterValue Value to match against
1734
+ * @param map Callback or key to map the matched items
1885
1735
  * @returns Filtered and mapped array of items
1886
1736
  *
1887
1737
  * @example
@@ -1890,35 +1740,37 @@ export declare function select<Item, FilterCallback extends (item: Item, index:
1890
1740
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1891
1741
  * item => item.id,
1892
1742
  * 2,
1893
- * 'name'
1743
+ * item => item.name,
1894
1744
  * ); // => ['Bob']
1895
1745
  * ```
1896
1746
  */
1897
- export 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]>;
1747
+ export declare function select<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends MapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<Mapped<Item, Map>>;
1898
1748
  /**
1899
1749
  * Get a filtered and mapped array of items
1900
1750
  *
1901
1751
  * @param array Array to search in
1902
- * @param filter Filter callback to match items
1903
- * @param map Callback to map the matched items
1752
+ * @param filterKey Key to get an item's value for matching
1753
+ * @param filterValue Value to match against
1754
+ * @param map Callback or key to map the matched items
1904
1755
  * @returns Filtered and mapped array of items
1905
1756
  *
1906
1757
  * @example
1907
1758
  * ```typescript
1908
1759
  * select(
1909
1760
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1910
- * item => item.id === 2,
1911
- * item => item.name,
1761
+ * 'id',
1762
+ * 2,
1763
+ * 'name',
1912
1764
  * ); // => ['Bob']
1913
1765
  * ```
1914
1766
  */
1915
- export 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>>;
1767
+ export declare function select<Item extends PlainObject, ItemKey extends keyof Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filterKey: ItemKey, filterValue: Item[ItemKey], map: Map): Array<Mapped<Item, Map>>;
1916
1768
  /**
1917
1769
  * Get a filtered and mapped array of items
1918
1770
  *
1919
1771
  * @param array Array to search in
1920
1772
  * @param filter Filter callback to match items
1921
- * @param map Key to get an item's value for mapping
1773
+ * @param map Callback or key to map the matched items
1922
1774
  * @returns Filtered and mapped array of items
1923
1775
  *
1924
1776
  * @example
@@ -1926,17 +1778,17 @@ export declare function select<Item, MapCallback extends (item: Item, index: num
1926
1778
  * select(
1927
1779
  * [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
1928
1780
  * item => item.id === 2,
1929
- * 'name'
1781
+ * item => item.name,
1930
1782
  * ); // => ['Bob']
1931
1783
  * ```
1932
1784
  */
1933
- export 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]>;
1785
+ export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, map: Map): Array<Mapped<Item, Map>>;
1934
1786
  /**
1935
1787
  * Get a filtered and mapped array of items
1936
1788
  *
1937
1789
  * @param array Array to search in
1938
1790
  * @param item Item to match against
1939
- * @param map Callback to map the matched items
1791
+ * @param map Callback or key to map the matched items
1940
1792
  * @returns Filtered and mapped array of items
1941
1793
  *
1942
1794
  * @example
@@ -1948,7 +1800,10 @@ export declare function select<Item extends PlainObject, MapKey extends keyof It
1948
1800
  * ); // => [9]
1949
1801
  * ```
1950
1802
  */
1951
- export declare function select<Item, MapCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], item: Item, map: MapCallback): Array<ReturnType<MapCallback>>;
1803
+ export declare function select<Item, Map extends MapKeyOrCallback<Item>>(array: Item[], item: Item, map: Map): Array<Mapped<Item, Map>>;
1804
+ export declare namespace select {
1805
+ var reverse: typeof reverseSelect;
1806
+ }
1952
1807
  //#endregion
1953
1808
  //#region src/array/single.d.ts
1954
1809
  /**
@@ -3283,13 +3138,13 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
3283
3138
  //#endregion
3284
3139
  //#region src/array/to-map.d.ts
3285
3140
  /**
3286
- * Create a _Map_ from an array of items using callbacks
3141
+ * Create a _Map_ from an array of items using a specific key
3287
3142
  *
3288
3143
  * If multiple items have the same key, the latest item's value will be used
3289
3144
  *
3290
3145
  * @param array Array to convert
3291
- * @param key Callback to get an item's grouping key
3292
- * @param value Callback to get an item's value
3146
+ * @param key Callback or key to use for grouping
3147
+ * @param value Callback or key to use for value, defaulting to the item itself
3293
3148
  * @returns _Map_ of keyed values
3294
3149
  *
3295
3150
  * @example
@@ -3301,74 +3156,14 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
3301
3156
  * ); // => Map { 10 => 3, 20 => 2 }
3302
3157
  * ```
3303
3158
  */
3304
- export 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>>;
3305
- /**
3306
- * Create a _Map_ from an array of items using a callback and value
3307
- *
3308
- * If multiple items have the same key, the latest item's value will be used
3309
- *
3310
- * @param array Array to convert
3311
- * @param key Callback to get an item's grouping key
3312
- * @param value Key to use for value
3313
- * @returns _Map_ of keyed values
3314
- *
3315
- * @example
3316
- * ```typescript
3317
- * toMap(
3318
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3319
- * item => item.value,
3320
- * 'id',
3321
- * ); // => Map { 10 => 3, 20 => 2 }
3322
- * ```
3323
- */
3324
- export 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]>;
3159
+ export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>;
3325
3160
  /**
3326
- * Create a _Map_ from an array of items using a key and callback
3327
- *
3328
- * If multiple items have the same key, the latest item's value will be used
3329
- *
3330
- * @param array Array to convert
3331
- * @param key Key to use for grouping
3332
- * @param value Callback to get an item's value
3333
- * @returns _Map_ of keyed values
3334
- *
3335
- * @example
3336
- * ```typescript
3337
- * toMap(
3338
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3339
- * 'value',
3340
- * item => item.id,
3341
- * ); // => Map { 10 => 3, 20 => 2 }
3342
- * ```
3343
- */
3344
- export 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>>;
3345
- /**
3346
- * Create a _Map_ from an array of items using a key and value
3347
- *
3348
- * If multiple items have the same key, the latest item's value will be used
3349
- *
3350
- * @param array Array to convert
3351
- * @param key Key to use for grouping
3352
- * @param value Key to use for value
3353
- * @returns _Map_ of keyed values
3354
- *
3355
- * @example
3356
- * ```typescript
3357
- * toMap(
3358
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3359
- * 'value',
3360
- * 'id',
3361
- * ); // => Map { 10 => 3, 20 => 2 }
3362
- * ```
3363
- */
3364
- export 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]>;
3365
- /**
3366
- * Create a _Map_ from an array of items using a callback
3161
+ * Create a _Map_ from an array of items using a specific key
3367
3162
  *
3368
3163
  * If multiple items have the same key, the latest item will be used
3369
3164
  *
3370
3165
  * @param array Array to convert
3371
- * @param callback Callback to get an item's grouping key
3166
+ * @param key Callback or key to use for grouping
3372
3167
  * @returns _Map_ of keyed items
3373
3168
  *
3374
3169
  * @example
@@ -3379,25 +3174,7 @@ export declare function toMap<Item extends PlainObject, ItemKey extends keyof It
3379
3174
  * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
3380
3175
  * ```
3381
3176
  */
3382
- export declare function toMap<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item>;
3383
- /**
3384
- * Create a _Map_ from an array of items using a key
3385
- *
3386
- * If multiple items have the same key, the latest item will be used
3387
- *
3388
- * @param array Array to convert
3389
- * @param key Key to use for grouping
3390
- * @returns _Map_ of keyed items
3391
- *
3392
- * @example
3393
- * ```typescript
3394
- * toMap(
3395
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3396
- * 'value',
3397
- * ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
3398
- * ```
3399
- */
3400
- export declare function toMap<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item>;
3177
+ export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
3401
3178
  /**
3402
3179
  * Create a _Map_ from an array of items _(using indices as keys)_
3403
3180
  *
@@ -3416,13 +3193,13 @@ export declare namespace toMap {
3416
3193
  var arrays: typeof toMapArrays;
3417
3194
  }
3418
3195
  /**
3419
- * Create a _Map_ from an array of items using callbacks, grouping values into arrays
3196
+ * Create a _Map_ from an array of items using a specific key, grouping values into arrays
3420
3197
  *
3421
3198
  * _Available as `toMapArrays` and `toMap.arrays`_
3422
3199
  *
3423
3200
  * @param array Array to convert
3424
- * @param key Callback to get an item's grouping key
3425
- * @param value Callback to get an item's value
3201
+ * @param key Callback or key to use for grouping
3202
+ * @param value Callback or key to use for value, defaulting to the item itself
3426
3203
  * @returns _Map_ of keyed arrays of values
3427
3204
  *
3428
3205
  * @example
@@ -3434,74 +3211,14 @@ export declare namespace toMap {
3434
3211
  * ); // => Map { 10 => [1, 3], 20 => [2] }
3435
3212
  * ```
3436
3213
  */
3437
- export 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>, Array<ReturnType<ValueCallback>>>;
3438
- /**
3439
- * Create a _Map_ from an array of items using a callback and value, grouping values into arrays
3440
- *
3441
- * _Available as `toMapArrays` and `toMap.arrays`_
3442
- *
3443
- * @param array Array to convert
3444
- * @param key Callback to get an item's grouping key
3445
- * @param value Key to use for value
3446
- * @returns _Map_ of keyed arrays of values
3447
- *
3448
- * @example
3449
- * ```typescript
3450
- * toMapArrays(
3451
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3452
- * item => item.value,
3453
- * 'id',
3454
- * ); // => Map { 10 => [1, 3], 20 => [2] }
3455
- * ```
3456
- */
3457
- export 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][]>;
3214
+ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Map<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>;
3458
3215
  /**
3459
- * Create a _Map_ from an array of items using a key and callback, grouping values into arrays
3216
+ * Create a _Map_ from an array of items using a specific key, grouping items into arrays
3460
3217
  *
3461
3218
  * _Available as `toMapArrays` and `toMap.arrays`_
3462
3219
  *
3463
3220
  * @param array Array to convert
3464
- * @param key Key to use for grouping
3465
- * @param value Callback to get an item's value
3466
- * @returns _Map_ of keyed arrays of values
3467
- *
3468
- * @example
3469
- * ```typescript
3470
- * toMapArrays(
3471
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3472
- * 'value',
3473
- * item => item.id,
3474
- * ); // => Map { 10 => [1, 3], 20 => [2] }
3475
- * ```
3476
- */
3477
- export declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], Array<ReturnType<ValueCallback>>>;
3478
- /**
3479
- * Create a _Map_ from an array of items using a key and value, grouping values into arrays
3480
- *
3481
- * _Available as `toMapArrays` and `toMap.arrays`_
3482
- *
3483
- * @param array Array to convert
3484
- * @param key Key to use for grouping
3485
- * @param value Key to use for value
3486
- * @returns _Map_ of keyed arrays of values
3487
- *
3488
- * @example
3489
- * ```typescript
3490
- * toMapArrays(
3491
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3492
- * 'value',
3493
- * 'id',
3494
- * ); // => Map { 10 => [1, 3], 20 => [2] }
3495
- * ```
3496
- */
3497
- export 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][]>;
3498
- /**
3499
- * Create a _Map_ from an array of items using a callback, grouping items into arrays
3500
- *
3501
- * _Available as `toMapArrays` and `toMap.arrays`_
3502
- *
3503
- * @param array Array to convert
3504
- * @param callback Callback to get an item's grouping key
3221
+ * @param key Callback or key to use for grouping
3505
3222
  * @returns _Map_ of keyed arrays of items
3506
3223
  *
3507
3224
  * @example
@@ -3512,35 +3229,17 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
3512
3229
  * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
3513
3230
  * ```
3514
3231
  */
3515
- export declare function toMapArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Map<ReturnType<Callback>, Item[]>;
3516
- /**
3517
- * Create a _Map_ from an array of items using a key, grouping items into arrays
3518
- *
3519
- * _Available as `toMapArrays` and `toMap.arrays`_
3520
- *
3521
- * @param array Array to convert
3522
- * @param key Key to use for grouping
3523
- * @returns _Map_ of keyed arrays of items
3524
- *
3525
- * @example
3526
- * ```typescript
3527
- * toMapArrays(
3528
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3529
- * 'value',
3530
- * ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
3531
- * ```
3532
- */
3533
- export declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Map<Item[ItemKey], Item[]>;
3232
+ export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
3534
3233
  //#endregion
3535
3234
  //#region src/array/to-record.d.ts
3536
3235
  /**
3537
- * Create a record from an array of items using callbacks
3236
+ * Create a record from an array of items using a specific key
3538
3237
  *
3539
3238
  * If multiple items have the same key, the latest item will be used
3540
3239
  *
3541
3240
  * @param array Array to convert
3542
- * @param key Callback to get an item's grouping key
3543
- * @param value Callback to get an item's value
3241
+ * @param key Callback or key to use for grouping
3242
+ * @param value Callback or key to use for value, defaulting to the item itself
3544
3243
  * @returns Record of keyed values
3545
3244
  *
3546
3245
  * @example
@@ -3552,74 +3251,14 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
3552
3251
  * ); // => { 10: 3, 20: 2 }
3553
3252
  * ```
3554
3253
  */
3555
- export 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>>;
3556
- /**
3557
- * Create a record from an array of items using a callback and value
3558
- *
3559
- * If multiple items have the same key, the latest item will be used
3560
- *
3561
- * @param array Array to convert
3562
- * @param callback Callback to get an item's grouping key
3563
- * @param value Key to use for value
3564
- * @returns Record with keys
3565
- *
3566
- * @example
3567
- * ```typescript
3568
- * toRecord(
3569
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3570
- * item => item.value,
3571
- * 'id',
3572
- * ); // => { 10: 3, 20: 2 }
3573
- * ```
3574
- */
3575
- export 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]>;
3254
+ export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, KeyOrCallbackValue<Item, ValueArg>>>;
3576
3255
  /**
3577
- * Create a record from an array of items using a key and callback
3578
- *
3579
- * If multiple items have the same key, the latest item will be used
3580
- *
3581
- * @param array Array to convert
3582
- * @param key Key to use for grouping
3583
- * @param callback Callback to get an item's value
3584
- * @returns Record with keys
3585
- *
3586
- * @example
3587
- * ```typescript
3588
- * toRecord(
3589
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3590
- * 'value',
3591
- * item => item.id,
3592
- * ); // => { 10: 3, 20: 2 }
3593
- * ```
3594
- */
3595
- export 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>>>;
3596
- /**
3597
- * Create a record from an array of items using a key and value
3598
- *
3599
- * If multiple items have the same key, the latest item will be used
3600
- *
3601
- * @param array Array to convert
3602
- * @param key Key to use for grouping
3603
- * @param value Key to use for value
3604
- * @returns Record of keyed values
3605
- *
3606
- * @example
3607
- * ```typescript
3608
- * toRecord(
3609
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3610
- * 'value',
3611
- * 'id',
3612
- * ); // => { 10: 3, 20: 2 }
3613
- * ```
3614
- */
3615
- export 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]>>;
3616
- /**
3617
- * Create a record from an array of items using a callback
3256
+ * Create a record from an array of items using a specific key
3618
3257
  *
3619
3258
  * If multiple items have the same key, the latest item will be used
3620
3259
  *
3621
3260
  * @param array Array to convert
3622
- * @param callback Callback to get an item's grouping key
3261
+ * @param key Callback or key to use for grouping
3623
3262
  * @returns Record of keyed values
3624
3263
  *
3625
3264
  * @example
@@ -3630,25 +3269,7 @@ export declare function toRecord<Item extends PlainObject, ItemKey extends keyof
3630
3269
  * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
3631
3270
  * ```
3632
3271
  */
3633
- export declare function toRecord<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item>;
3634
- /**
3635
- * Create a record from an array of items using a key
3636
- *
3637
- * If multiple items have the same key, the latest item will be used
3638
- *
3639
- * @param array Array to convert
3640
- * @param key Key to use for grouping
3641
- * @returns Record of keyed values
3642
- *
3643
- * @example
3644
- * ```typescript
3645
- * toRecord(
3646
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3647
- * 'value',
3648
- * ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
3649
- * ```
3650
- */
3651
- export declare function toRecord<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item>>;
3272
+ export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
3652
3273
  /**
3653
3274
  * Create a record from an array of items _(using indices as keys)_
3654
3275
  *
@@ -3667,33 +3288,13 @@ export declare namespace toRecord {
3667
3288
  var arrays: typeof toRecordArrays;
3668
3289
  }
3669
3290
  /**
3670
- * Create a record from an array of items using callbacks, grouping values into arrays
3671
- *
3672
- * _Available as `toRecordArrays` and `toRecord.arrays`_
3673
- *
3674
- * @param array Array to convert
3675
- * @param key Callback to get an item's grouping key
3676
- * @param value Callback to get an item's value
3677
- * @returns Record of keyed arrays of values
3678
- *
3679
- * @example
3680
- * ```typescript
3681
- * toRecordArrays(
3682
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3683
- * item => item.value,
3684
- * item => item.id,
3685
- * ); // => { 10: [1, 3], 20: [2] }
3686
- * ```
3687
- */
3688
- export 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>, Array<ReturnType<ValueCallback>>>;
3689
- /**
3690
- * Create a record from an array of items using a callback and value, grouping values into arrays
3291
+ * Create a record from an array of items using a specific key, grouping values into arrays
3691
3292
  *
3692
3293
  * _Available as `toRecordArrays` and `toRecord.arrays`_
3693
3294
  *
3694
3295
  * @param array Array to convert
3695
- * @param callback Callback to get an item's grouping key
3696
- * @param value Key to use for value
3296
+ * @param key Callback or key to use for grouping
3297
+ * @param value Callback or key to use for value, defaulting to the item itself
3697
3298
  * @returns Record of keyed arrays of values
3698
3299
  *
3699
3300
  * @example
@@ -3701,58 +3302,18 @@ export declare function toRecordArrays<Item, KeyCallback extends (item: Item, in
3701
3302
  * toRecordArrays(
3702
3303
  * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3703
3304
  * item => item.value,
3704
- * 'id',
3705
- * ); // => { 10: [1, 3], 20: [2] }
3706
- * ```
3707
- */
3708
- export 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][]>;
3709
- /**
3710
- * Create a record from an array of items using a key and callback, grouping values into arrays
3711
- *
3712
- * _Available as `toRecordArrays` and `toRecord.arrays`_
3713
- *
3714
- * @param array Array to convert
3715
- * @param key Key to use for grouping
3716
- * @param callback Callback to get an item's value
3717
- * @returns Record of keyed arrays of values
3718
- *
3719
- * @example
3720
- * ```typescript
3721
- * toRecordArrays(
3722
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3723
- * 'value',
3724
3305
  * item => item.id,
3725
3306
  * ); // => { 10: [1, 3], 20: [2] }
3726
3307
  * ```
3727
3308
  */
3728
- export declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<Callback>>>>;
3729
- /**
3730
- * Create a record from an array of items using a key and value, grouping values into arrays
3731
- *
3732
- * _Available as `toRecordArrays` and `toRecord.arrays`_
3733
- *
3734
- * @param array Array to convert
3735
- * @param key Key to use for grouping
3736
- * @param value Key to use for value
3737
- * @returns Record of keyed arrays of values
3738
- *
3739
- * @example
3740
- * ```typescript
3741
- * toRecordArrays(
3742
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3743
- * 'value',
3744
- * 'id',
3745
- * ); // => { 10: [1, 3], 20: [2] }
3746
- * ```
3747
- */
3748
- export 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][]>>;
3309
+ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>, ValueArg extends KeyOrCallback<Item>>(array: Item[], key: KeyArg, value: ValueArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Array<KeyOrCallbackValue<Item, ValueArg>>>>;
3749
3310
  /**
3750
- * Create a record from an array of items using a callback, grouping items into arrays
3311
+ * Create a record from an array of items using a specific key, grouping items into arrays
3751
3312
  *
3752
3313
  * _Available as `toRecordArrays` and `toRecord.arrays`_
3753
3314
  *
3754
3315
  * @param array Array to convert
3755
- * @param callback Callback to get an item's grouping key
3316
+ * @param key Callback or key to use for grouping
3756
3317
  * @returns Record of keyed arrays of items
3757
3318
  *
3758
3319
  * @example
@@ -3763,25 +3324,7 @@ export declare function toRecordArrays<Item extends PlainObject, ItemKey extends
3763
3324
  * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
3764
3325
  * ```
3765
3326
  */
3766
- export declare function toRecordArrays<Item, Callback extends (item: Item, index: number, array: Item[]) => Key$1>(array: Item[], callback: Callback): Record<ReturnType<Callback>, Item[]>;
3767
- /**
3768
- * Create a record from an array of items using a key, grouping items into arrays
3769
- *
3770
- * _Available as `toRecordArrays` and `toRecord.arrays`_
3771
- *
3772
- * @param array Array to convert
3773
- * @param key Key to use for grouping
3774
- * @returns Record of keyed arrays of items
3775
- *
3776
- * @example
3777
- * ```typescript
3778
- * toRecordArrays(
3779
- * [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
3780
- * 'value',
3781
- * ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
3782
- * ```
3783
- */
3784
- export declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey): Simplify<Record<KeyedValue<Item, ItemKey>, Item[]>>;
3327
+ export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
3785
3328
  //#endregion
3786
3329
  //#region src/internal/function/misc.d.ts
3787
3330
  /**
@@ -6764,7 +6307,7 @@ type SubscriptionProperty = {
6764
6307
  */
6765
6308
  value: unknown;
6766
6309
  };
6767
- type Subscriptions = {
6310
+ type Subscriptions<Value = unknown> = {
6768
6311
  /**
6769
6312
  * Items of the subscriptions store
6770
6313
  *
@@ -6780,7 +6323,7 @@ type Subscriptions = {
6780
6323
  * - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
6781
6324
  * - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
6782
6325
  */
6783
- readonly values: Readonly<SubscriptionsValues>;
6326
+ readonly values: Readonly<SubscriptionsValues<Value>>;
6784
6327
  /**
6785
6328
  * Clear all subscriptions
6786
6329
  */
@@ -6810,9 +6353,9 @@ type SubscriptionsItems = {
6810
6353
  any: Set<Subscription>;
6811
6354
  keyed?: Map<Key$1, Set<Subscription>>;
6812
6355
  };
6813
- type SubscriptionsValues = {
6814
- from: SubscriptionsValuesItem<unknown, Subscription>;
6815
- to: SubscriptionsValuesItem<Subscription, unknown>;
6356
+ type SubscriptionsValues<Value = unknown> = {
6357
+ from: SubscriptionsValuesItem<Value, Subscription>;
6358
+ to: SubscriptionsValuesItem<Subscription, Value>;
6816
6359
  };
6817
6360
  type SubscriptionsValuesItem<MapKey, MapValue> = {
6818
6361
  any: Map<MapKey, MapValue>;
@@ -6838,7 +6381,7 @@ export declare function isSubscriptions(value: unknown): value is Subscriptions;
6838
6381
  * @param parameters Store parameters
6839
6382
  * @returns Subscription store
6840
6383
  */
6841
- export declare function subscriptions(parameters?: SubscriptionsParameters): Subscriptions;
6384
+ export declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
6842
6385
  //#endregion
6843
6386
  //#region src/beacon.d.ts
6844
6387
  /**