@oscarpalmer/atoms 0.201.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/array/group-by.d.mts +13 -181
- package/dist/array/to-map.d.mts +15 -171
- package/dist/array/to-record.d.mts +15 -171
- package/dist/index.d.mts +62 -526
- package/dist/internal/subscription.d.mts +6 -6
- package/dist/models.d.mts +17 -1
- package/package.json +1 -1
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,33 +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
|
|
454
|
-
*
|
|
455
|
-
* If multiple items have the same key, the latest item's value will be used
|
|
456
|
-
*
|
|
457
|
-
* @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
|
|
460
|
-
* @returns Record of keyed values
|
|
461
|
-
*
|
|
462
|
-
* @example
|
|
463
|
-
* ```typescript
|
|
464
|
-
* groupBy(
|
|
465
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
466
|
-
* item => item.value,
|
|
467
|
-
* item => item,
|
|
468
|
-
* ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
|
|
469
|
-
* ```
|
|
470
|
-
*/
|
|
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
|
|
469
|
+
* Create a record from an array of items using a specific key
|
|
474
470
|
*
|
|
475
471
|
* If multiple items have the same key, the latest item's value will be used
|
|
476
472
|
*
|
|
477
473
|
* @param array Array to group
|
|
478
|
-
* @param key Callback to
|
|
479
|
-
* @param 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
|
|
480
476
|
* @returns Record of keyed values
|
|
481
477
|
*
|
|
482
478
|
* @example
|
|
@@ -484,58 +480,18 @@ export declare function groupBy<Item, KeyCallback extends (item: Item, index: nu
|
|
|
484
480
|
* groupBy(
|
|
485
481
|
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
486
482
|
* 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
483
|
* item => item,
|
|
508
484
|
* ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
|
|
509
485
|
* ```
|
|
510
486
|
*/
|
|
511
|
-
export declare function groupBy<Item
|
|
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
|
|
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,
|
|
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,13 +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
|
|
524
|
+
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
587
525
|
*
|
|
588
526
|
* _Available as `groupArraysBy` and `groupBy.arrays`_
|
|
589
527
|
*
|
|
590
528
|
* @param array Array to group
|
|
591
|
-
* @param key Callback to
|
|
592
|
-
* @param value Callback to
|
|
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
|
|
593
531
|
* @returns Record of keyed values
|
|
594
532
|
*
|
|
595
533
|
* @example
|
|
@@ -604,83 +542,14 @@ export declare namespace groupBy {
|
|
|
604
542
|
* // }
|
|
605
543
|
* ```
|
|
606
544
|
*/
|
|
607
|
-
export declare function groupArraysBy<Item,
|
|
608
|
-
/**
|
|
609
|
-
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
610
|
-
*
|
|
611
|
-
* _Available as `groupArraysBy` and `groupBy.arrays`_
|
|
612
|
-
*
|
|
613
|
-
* @param array Array to group
|
|
614
|
-
* @param key Callback to get an item's grouping key
|
|
615
|
-
* @param value Key to use for value
|
|
616
|
-
* @returns Record of keyed values
|
|
617
|
-
*
|
|
618
|
-
* @example
|
|
619
|
-
* ```typescript
|
|
620
|
-
* groupArraysBy(
|
|
621
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
622
|
-
* 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
|
-
* item => item,
|
|
647
|
-
* ); // => {
|
|
648
|
-
* // 10: [{id: 1, value: 10}, {id: 3, value: 10}],
|
|
649
|
-
* // 20: [{id: 2, value: 20}],
|
|
650
|
-
* // }
|
|
651
|
-
* ```
|
|
652
|
-
*/
|
|
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
|
|
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,
|
|
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
|
/**
|
|
@@ -3290,13 +3138,13 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
|
|
|
3290
3138
|
//#endregion
|
|
3291
3139
|
//#region src/array/to-map.d.ts
|
|
3292
3140
|
/**
|
|
3293
|
-
* Create a _Map_ from an array of items using
|
|
3141
|
+
* Create a _Map_ from an array of items using a specific key
|
|
3294
3142
|
*
|
|
3295
3143
|
* If multiple items have the same key, the latest item's value will be used
|
|
3296
3144
|
*
|
|
3297
3145
|
* @param array Array to convert
|
|
3298
|
-
* @param key Callback to
|
|
3299
|
-
* @param value Callback to
|
|
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
|
|
3300
3148
|
* @returns _Map_ of keyed values
|
|
3301
3149
|
*
|
|
3302
3150
|
* @example
|
|
@@ -3308,74 +3156,14 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
|
|
|
3308
3156
|
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3309
3157
|
* ```
|
|
3310
3158
|
*/
|
|
3311
|
-
export declare function toMap<Item,
|
|
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>>;
|
|
3312
3160
|
/**
|
|
3313
|
-
* Create a _Map_ from an array of items using a
|
|
3314
|
-
*
|
|
3315
|
-
* If multiple items have the same key, the latest item's value will be used
|
|
3316
|
-
*
|
|
3317
|
-
* @param array Array to convert
|
|
3318
|
-
* @param key Callback to get an item's grouping key
|
|
3319
|
-
* @param value Key to use for value
|
|
3320
|
-
* @returns _Map_ of keyed values
|
|
3321
|
-
*
|
|
3322
|
-
* @example
|
|
3323
|
-
* ```typescript
|
|
3324
|
-
* toMap(
|
|
3325
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3326
|
-
* item => item.value,
|
|
3327
|
-
* 'id',
|
|
3328
|
-
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3329
|
-
* ```
|
|
3330
|
-
*/
|
|
3331
|
-
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]>;
|
|
3332
|
-
/**
|
|
3333
|
-
* Create a _Map_ from an array of items using a key and callback
|
|
3334
|
-
*
|
|
3335
|
-
* If multiple items have the same key, the latest item's value will be used
|
|
3336
|
-
*
|
|
3337
|
-
* @param array Array to convert
|
|
3338
|
-
* @param key Key to use for grouping
|
|
3339
|
-
* @param value Callback to get an item's value
|
|
3340
|
-
* @returns _Map_ of keyed values
|
|
3341
|
-
*
|
|
3342
|
-
* @example
|
|
3343
|
-
* ```typescript
|
|
3344
|
-
* toMap(
|
|
3345
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3346
|
-
* 'value',
|
|
3347
|
-
* item => item.id,
|
|
3348
|
-
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3349
|
-
* ```
|
|
3350
|
-
*/
|
|
3351
|
-
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>>;
|
|
3352
|
-
/**
|
|
3353
|
-
* Create a _Map_ from an array of items using a key and value
|
|
3354
|
-
*
|
|
3355
|
-
* If multiple items have the same key, the latest item's value will be used
|
|
3356
|
-
*
|
|
3357
|
-
* @param array Array to convert
|
|
3358
|
-
* @param key Key to use for grouping
|
|
3359
|
-
* @param value Key to use for value
|
|
3360
|
-
* @returns _Map_ of keyed values
|
|
3361
|
-
*
|
|
3362
|
-
* @example
|
|
3363
|
-
* ```typescript
|
|
3364
|
-
* toMap(
|
|
3365
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3366
|
-
* 'value',
|
|
3367
|
-
* 'id',
|
|
3368
|
-
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3369
|
-
* ```
|
|
3370
|
-
*/
|
|
3371
|
-
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]>;
|
|
3372
|
-
/**
|
|
3373
|
-
* Create a _Map_ from an array of items using a callback
|
|
3161
|
+
* Create a _Map_ from an array of items using a specific key
|
|
3374
3162
|
*
|
|
3375
3163
|
* If multiple items have the same key, the latest item will be used
|
|
3376
3164
|
*
|
|
3377
3165
|
* @param array Array to convert
|
|
3378
|
-
* @param
|
|
3166
|
+
* @param key Callback or key to use for grouping
|
|
3379
3167
|
* @returns _Map_ of keyed items
|
|
3380
3168
|
*
|
|
3381
3169
|
* @example
|
|
@@ -3386,25 +3174,7 @@ export declare function toMap<Item extends PlainObject, ItemKey extends keyof It
|
|
|
3386
3174
|
* ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
|
|
3387
3175
|
* ```
|
|
3388
3176
|
*/
|
|
3389
|
-
export declare function toMap<Item,
|
|
3390
|
-
/**
|
|
3391
|
-
* Create a _Map_ from an array of items using a key
|
|
3392
|
-
*
|
|
3393
|
-
* If multiple items have the same key, the latest item will be used
|
|
3394
|
-
*
|
|
3395
|
-
* @param array Array to convert
|
|
3396
|
-
* @param key Key to use for grouping
|
|
3397
|
-
* @returns _Map_ of keyed items
|
|
3398
|
-
*
|
|
3399
|
-
* @example
|
|
3400
|
-
* ```typescript
|
|
3401
|
-
* toMap(
|
|
3402
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3403
|
-
* 'value',
|
|
3404
|
-
* ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
|
|
3405
|
-
* ```
|
|
3406
|
-
*/
|
|
3407
|
-
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>;
|
|
3408
3178
|
/**
|
|
3409
3179
|
* Create a _Map_ from an array of items _(using indices as keys)_
|
|
3410
3180
|
*
|
|
@@ -3423,13 +3193,13 @@ export declare namespace toMap {
|
|
|
3423
3193
|
var arrays: typeof toMapArrays;
|
|
3424
3194
|
}
|
|
3425
3195
|
/**
|
|
3426
|
-
* Create a _Map_ from an array of items using
|
|
3196
|
+
* Create a _Map_ from an array of items using a specific key, grouping values into arrays
|
|
3427
3197
|
*
|
|
3428
3198
|
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3429
3199
|
*
|
|
3430
3200
|
* @param array Array to convert
|
|
3431
|
-
* @param key Callback to
|
|
3432
|
-
* @param value Callback to
|
|
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
|
|
3433
3203
|
* @returns _Map_ of keyed arrays of values
|
|
3434
3204
|
*
|
|
3435
3205
|
* @example
|
|
@@ -3441,74 +3211,14 @@ export declare namespace toMap {
|
|
|
3441
3211
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3442
3212
|
* ```
|
|
3443
3213
|
*/
|
|
3444
|
-
export declare function toMapArrays<Item,
|
|
3445
|
-
/**
|
|
3446
|
-
* Create a _Map_ from an array of items using a callback and value, grouping values into arrays
|
|
3447
|
-
*
|
|
3448
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3449
|
-
*
|
|
3450
|
-
* @param array Array to convert
|
|
3451
|
-
* @param key Callback to get an item's grouping key
|
|
3452
|
-
* @param value Key to use for value
|
|
3453
|
-
* @returns _Map_ of keyed arrays of values
|
|
3454
|
-
*
|
|
3455
|
-
* @example
|
|
3456
|
-
* ```typescript
|
|
3457
|
-
* toMapArrays(
|
|
3458
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3459
|
-
* item => item.value,
|
|
3460
|
-
* 'id',
|
|
3461
|
-
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3462
|
-
* ```
|
|
3463
|
-
*/
|
|
3464
|
-
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][]>;
|
|
3465
|
-
/**
|
|
3466
|
-
* Create a _Map_ from an array of items using a key and callback, grouping values into arrays
|
|
3467
|
-
*
|
|
3468
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3469
|
-
*
|
|
3470
|
-
* @param array Array to convert
|
|
3471
|
-
* @param key Key to use for grouping
|
|
3472
|
-
* @param value Callback to get an item's value
|
|
3473
|
-
* @returns _Map_ of keyed arrays of values
|
|
3474
|
-
*
|
|
3475
|
-
* @example
|
|
3476
|
-
* ```typescript
|
|
3477
|
-
* toMapArrays(
|
|
3478
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3479
|
-
* 'value',
|
|
3480
|
-
* item => item.id,
|
|
3481
|
-
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3482
|
-
* ```
|
|
3483
|
-
*/
|
|
3484
|
-
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>>>;
|
|
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>>>;
|
|
3485
3215
|
/**
|
|
3486
|
-
* Create a _Map_ from an array of items using a key
|
|
3216
|
+
* Create a _Map_ from an array of items using a specific key, grouping items into arrays
|
|
3487
3217
|
*
|
|
3488
3218
|
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3489
3219
|
*
|
|
3490
3220
|
* @param array Array to convert
|
|
3491
|
-
* @param key
|
|
3492
|
-
* @param value Key to use for value
|
|
3493
|
-
* @returns _Map_ of keyed arrays of values
|
|
3494
|
-
*
|
|
3495
|
-
* @example
|
|
3496
|
-
* ```typescript
|
|
3497
|
-
* toMapArrays(
|
|
3498
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3499
|
-
* 'value',
|
|
3500
|
-
* 'id',
|
|
3501
|
-
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3502
|
-
* ```
|
|
3503
|
-
*/
|
|
3504
|
-
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][]>;
|
|
3505
|
-
/**
|
|
3506
|
-
* Create a _Map_ from an array of items using a callback, grouping items into arrays
|
|
3507
|
-
*
|
|
3508
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3509
|
-
*
|
|
3510
|
-
* @param array Array to convert
|
|
3511
|
-
* @param callback Callback to get an item's grouping key
|
|
3221
|
+
* @param key Callback or key to use for grouping
|
|
3512
3222
|
* @returns _Map_ of keyed arrays of items
|
|
3513
3223
|
*
|
|
3514
3224
|
* @example
|
|
@@ -3519,35 +3229,17 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
|
|
|
3519
3229
|
* ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
|
|
3520
3230
|
* ```
|
|
3521
3231
|
*/
|
|
3522
|
-
export declare function toMapArrays<Item,
|
|
3523
|
-
/**
|
|
3524
|
-
* Create a _Map_ from an array of items using a key, grouping items into arrays
|
|
3525
|
-
*
|
|
3526
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3527
|
-
*
|
|
3528
|
-
* @param array Array to convert
|
|
3529
|
-
* @param key Key to use for grouping
|
|
3530
|
-
* @returns _Map_ of keyed arrays of items
|
|
3531
|
-
*
|
|
3532
|
-
* @example
|
|
3533
|
-
* ```typescript
|
|
3534
|
-
* toMapArrays(
|
|
3535
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3536
|
-
* 'value',
|
|
3537
|
-
* ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
|
|
3538
|
-
* ```
|
|
3539
|
-
*/
|
|
3540
|
-
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[]>;
|
|
3541
3233
|
//#endregion
|
|
3542
3234
|
//#region src/array/to-record.d.ts
|
|
3543
3235
|
/**
|
|
3544
|
-
* Create a record from an array of items using
|
|
3236
|
+
* Create a record from an array of items using a specific key
|
|
3545
3237
|
*
|
|
3546
3238
|
* If multiple items have the same key, the latest item will be used
|
|
3547
3239
|
*
|
|
3548
3240
|
* @param array Array to convert
|
|
3549
|
-
* @param key Callback to
|
|
3550
|
-
* @param value Callback to
|
|
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
|
|
3551
3243
|
* @returns Record of keyed values
|
|
3552
3244
|
*
|
|
3553
3245
|
* @example
|
|
@@ -3559,74 +3251,14 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
|
|
|
3559
3251
|
* ); // => { 10: 3, 20: 2 }
|
|
3560
3252
|
* ```
|
|
3561
3253
|
*/
|
|
3562
|
-
export declare function toRecord<Item,
|
|
3563
|
-
/**
|
|
3564
|
-
* Create a record from an array of items using a callback and value
|
|
3565
|
-
*
|
|
3566
|
-
* If multiple items have the same key, the latest item will be used
|
|
3567
|
-
*
|
|
3568
|
-
* @param array Array to convert
|
|
3569
|
-
* @param callback Callback to get an item's grouping key
|
|
3570
|
-
* @param value Key to use for value
|
|
3571
|
-
* @returns Record with keys
|
|
3572
|
-
*
|
|
3573
|
-
* @example
|
|
3574
|
-
* ```typescript
|
|
3575
|
-
* toRecord(
|
|
3576
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3577
|
-
* item => item.value,
|
|
3578
|
-
* 'id',
|
|
3579
|
-
* ); // => { 10: 3, 20: 2 }
|
|
3580
|
-
* ```
|
|
3581
|
-
*/
|
|
3582
|
-
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]>;
|
|
3583
|
-
/**
|
|
3584
|
-
* Create a record from an array of items using a key and callback
|
|
3585
|
-
*
|
|
3586
|
-
* If multiple items have the same key, the latest item will be used
|
|
3587
|
-
*
|
|
3588
|
-
* @param array Array to convert
|
|
3589
|
-
* @param key Key to use for grouping
|
|
3590
|
-
* @param callback Callback to get an item's value
|
|
3591
|
-
* @returns Record with keys
|
|
3592
|
-
*
|
|
3593
|
-
* @example
|
|
3594
|
-
* ```typescript
|
|
3595
|
-
* toRecord(
|
|
3596
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3597
|
-
* 'value',
|
|
3598
|
-
* item => item.id,
|
|
3599
|
-
* ); // => { 10: 3, 20: 2 }
|
|
3600
|
-
* ```
|
|
3601
|
-
*/
|
|
3602
|
-
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>>>;
|
|
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>>>;
|
|
3603
3255
|
/**
|
|
3604
|
-
* Create a record from an array of items using a key
|
|
3605
|
-
*
|
|
3606
|
-
* If multiple items have the same key, the latest item will be used
|
|
3607
|
-
*
|
|
3608
|
-
* @param array Array to convert
|
|
3609
|
-
* @param key Key to use for grouping
|
|
3610
|
-
* @param value Key to use for value
|
|
3611
|
-
* @returns Record of keyed values
|
|
3612
|
-
*
|
|
3613
|
-
* @example
|
|
3614
|
-
* ```typescript
|
|
3615
|
-
* toRecord(
|
|
3616
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3617
|
-
* 'value',
|
|
3618
|
-
* 'id',
|
|
3619
|
-
* ); // => { 10: 3, 20: 2 }
|
|
3620
|
-
* ```
|
|
3621
|
-
*/
|
|
3622
|
-
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]>>;
|
|
3623
|
-
/**
|
|
3624
|
-
* Create a record from an array of items using a callback
|
|
3256
|
+
* Create a record from an array of items using a specific key
|
|
3625
3257
|
*
|
|
3626
3258
|
* If multiple items have the same key, the latest item will be used
|
|
3627
3259
|
*
|
|
3628
3260
|
* @param array Array to convert
|
|
3629
|
-
* @param
|
|
3261
|
+
* @param key Callback or key to use for grouping
|
|
3630
3262
|
* @returns Record of keyed values
|
|
3631
3263
|
*
|
|
3632
3264
|
* @example
|
|
@@ -3637,25 +3269,7 @@ export declare function toRecord<Item extends PlainObject, ItemKey extends keyof
|
|
|
3637
3269
|
* ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
|
|
3638
3270
|
* ```
|
|
3639
3271
|
*/
|
|
3640
|
-
export declare function toRecord<Item,
|
|
3641
|
-
/**
|
|
3642
|
-
* Create a record from an array of items using a key
|
|
3643
|
-
*
|
|
3644
|
-
* If multiple items have the same key, the latest item will be used
|
|
3645
|
-
*
|
|
3646
|
-
* @param array Array to convert
|
|
3647
|
-
* @param key Key to use for grouping
|
|
3648
|
-
* @returns Record of keyed values
|
|
3649
|
-
*
|
|
3650
|
-
* @example
|
|
3651
|
-
* ```typescript
|
|
3652
|
-
* toRecord(
|
|
3653
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3654
|
-
* 'value',
|
|
3655
|
-
* ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
|
|
3656
|
-
* ```
|
|
3657
|
-
*/
|
|
3658
|
-
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>>;
|
|
3659
3273
|
/**
|
|
3660
3274
|
* Create a record from an array of items _(using indices as keys)_
|
|
3661
3275
|
*
|
|
@@ -3674,13 +3288,13 @@ export declare namespace toRecord {
|
|
|
3674
3288
|
var arrays: typeof toRecordArrays;
|
|
3675
3289
|
}
|
|
3676
3290
|
/**
|
|
3677
|
-
* Create a record from an array of items using
|
|
3291
|
+
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
3678
3292
|
*
|
|
3679
3293
|
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3680
3294
|
*
|
|
3681
3295
|
* @param array Array to convert
|
|
3682
|
-
* @param key Callback to
|
|
3683
|
-
* @param value Callback to
|
|
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
|
|
3684
3298
|
* @returns Record of keyed arrays of values
|
|
3685
3299
|
*
|
|
3686
3300
|
* @example
|
|
@@ -3692,74 +3306,14 @@ export declare namespace toRecord {
|
|
|
3692
3306
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
3693
3307
|
* ```
|
|
3694
3308
|
*/
|
|
3695
|
-
export declare function toRecordArrays<Item,
|
|
3696
|
-
/**
|
|
3697
|
-
* Create a record from an array of items using a callback and value, grouping values into arrays
|
|
3698
|
-
*
|
|
3699
|
-
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3700
|
-
*
|
|
3701
|
-
* @param array Array to convert
|
|
3702
|
-
* @param callback Callback to get an item's grouping key
|
|
3703
|
-
* @param value Key to use for value
|
|
3704
|
-
* @returns Record of keyed arrays of values
|
|
3705
|
-
*
|
|
3706
|
-
* @example
|
|
3707
|
-
* ```typescript
|
|
3708
|
-
* toRecordArrays(
|
|
3709
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3710
|
-
* item => item.value,
|
|
3711
|
-
* 'id',
|
|
3712
|
-
* ); // => { 10: [1, 3], 20: [2] }
|
|
3713
|
-
* ```
|
|
3714
|
-
*/
|
|
3715
|
-
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][]>;
|
|
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>>>>;
|
|
3716
3310
|
/**
|
|
3717
|
-
* Create a record from an array of items using a key
|
|
3718
|
-
*
|
|
3719
|
-
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3720
|
-
*
|
|
3721
|
-
* @param array Array to convert
|
|
3722
|
-
* @param key Key to use for grouping
|
|
3723
|
-
* @param callback Callback to get an item's value
|
|
3724
|
-
* @returns Record of keyed arrays of values
|
|
3725
|
-
*
|
|
3726
|
-
* @example
|
|
3727
|
-
* ```typescript
|
|
3728
|
-
* toRecordArrays(
|
|
3729
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3730
|
-
* 'value',
|
|
3731
|
-
* item => item.id,
|
|
3732
|
-
* ); // => { 10: [1, 3], 20: [2] }
|
|
3733
|
-
* ```
|
|
3734
|
-
*/
|
|
3735
|
-
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>>>>;
|
|
3736
|
-
/**
|
|
3737
|
-
* Create a record from an array of items using a key and value, grouping values into arrays
|
|
3738
|
-
*
|
|
3739
|
-
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3740
|
-
*
|
|
3741
|
-
* @param array Array to convert
|
|
3742
|
-
* @param key Key to use for grouping
|
|
3743
|
-
* @param value Key to use for value
|
|
3744
|
-
* @returns Record of keyed arrays of values
|
|
3745
|
-
*
|
|
3746
|
-
* @example
|
|
3747
|
-
* ```typescript
|
|
3748
|
-
* toRecordArrays(
|
|
3749
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3750
|
-
* 'value',
|
|
3751
|
-
* 'id',
|
|
3752
|
-
* ); // => { 10: [1, 3], 20: [2] }
|
|
3753
|
-
* ```
|
|
3754
|
-
*/
|
|
3755
|
-
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][]>>;
|
|
3756
|
-
/**
|
|
3757
|
-
* 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
|
|
3758
3312
|
*
|
|
3759
3313
|
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3760
3314
|
*
|
|
3761
3315
|
* @param array Array to convert
|
|
3762
|
-
* @param
|
|
3316
|
+
* @param key Callback or key to use for grouping
|
|
3763
3317
|
* @returns Record of keyed arrays of items
|
|
3764
3318
|
*
|
|
3765
3319
|
* @example
|
|
@@ -3770,25 +3324,7 @@ export declare function toRecordArrays<Item extends PlainObject, ItemKey extends
|
|
|
3770
3324
|
* ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
|
|
3771
3325
|
* ```
|
|
3772
3326
|
*/
|
|
3773
|
-
export declare function toRecordArrays<Item,
|
|
3774
|
-
/**
|
|
3775
|
-
* Create a record from an array of items using a key, grouping items into arrays
|
|
3776
|
-
*
|
|
3777
|
-
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3778
|
-
*
|
|
3779
|
-
* @param array Array to convert
|
|
3780
|
-
* @param key Key to use for grouping
|
|
3781
|
-
* @returns Record of keyed arrays of items
|
|
3782
|
-
*
|
|
3783
|
-
* @example
|
|
3784
|
-
* ```typescript
|
|
3785
|
-
* toRecordArrays(
|
|
3786
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3787
|
-
* 'value',
|
|
3788
|
-
* ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
|
|
3789
|
-
* ```
|
|
3790
|
-
*/
|
|
3791
|
-
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[]>>;
|
|
3792
3328
|
//#endregion
|
|
3793
3329
|
//#region src/internal/function/misc.d.ts
|
|
3794
3330
|
/**
|
|
@@ -6771,7 +6307,7 @@ type SubscriptionProperty = {
|
|
|
6771
6307
|
*/
|
|
6772
6308
|
value: unknown;
|
|
6773
6309
|
};
|
|
6774
|
-
type Subscriptions = {
|
|
6310
|
+
type Subscriptions<Value = unknown> = {
|
|
6775
6311
|
/**
|
|
6776
6312
|
* Items of the subscriptions store
|
|
6777
6313
|
*
|
|
@@ -6787,7 +6323,7 @@ type Subscriptions = {
|
|
|
6787
6323
|
* - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
|
|
6788
6324
|
* - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
|
|
6789
6325
|
*/
|
|
6790
|
-
readonly values: Readonly<SubscriptionsValues
|
|
6326
|
+
readonly values: Readonly<SubscriptionsValues<Value>>;
|
|
6791
6327
|
/**
|
|
6792
6328
|
* Clear all subscriptions
|
|
6793
6329
|
*/
|
|
@@ -6817,9 +6353,9 @@ type SubscriptionsItems = {
|
|
|
6817
6353
|
any: Set<Subscription>;
|
|
6818
6354
|
keyed?: Map<Key$1, Set<Subscription>>;
|
|
6819
6355
|
};
|
|
6820
|
-
type SubscriptionsValues = {
|
|
6821
|
-
from: SubscriptionsValuesItem<
|
|
6822
|
-
to: SubscriptionsValuesItem<Subscription,
|
|
6356
|
+
type SubscriptionsValues<Value = unknown> = {
|
|
6357
|
+
from: SubscriptionsValuesItem<Value, Subscription>;
|
|
6358
|
+
to: SubscriptionsValuesItem<Subscription, Value>;
|
|
6823
6359
|
};
|
|
6824
6360
|
type SubscriptionsValuesItem<MapKey, MapValue> = {
|
|
6825
6361
|
any: Map<MapKey, MapValue>;
|
|
@@ -6845,7 +6381,7 @@ export declare function isSubscriptions(value: unknown): value is Subscriptions;
|
|
|
6845
6381
|
* @param parameters Store parameters
|
|
6846
6382
|
* @returns Subscription store
|
|
6847
6383
|
*/
|
|
6848
|
-
export declare function subscriptions(parameters?: SubscriptionsParameters): Subscriptions
|
|
6384
|
+
export declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
|
|
6849
6385
|
//#endregion
|
|
6850
6386
|
//#region src/beacon.d.ts
|
|
6851
6387
|
/**
|