@oscarpalmer/atoms 0.201.0 → 0.203.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/difference.d.mts +4 -5
- package/dist/array/exists.d.mts +5 -6
- package/dist/array/filter.d.mts +10 -11
- package/dist/array/find.d.mts +10 -11
- package/dist/array/first.d.mts +10 -11
- package/dist/array/flatten.d.mts +2 -3
- package/dist/array/from.d.mts +7 -8
- package/dist/array/group-by.d.mts +16 -185
- package/dist/array/insert.d.mts +3 -4
- package/dist/array/intersection.d.mts +4 -5
- package/dist/array/last.d.mts +10 -11
- package/dist/array/move.d.mts +9 -10
- package/dist/array/partition.d.mts +5 -6
- package/dist/array/push.d.mts +2 -3
- package/dist/array/reverse.d.mts +2 -3
- package/dist/array/select.d.mts +11 -12
- package/dist/array/single.d.mts +4 -5
- package/dist/array/slice.d.mts +12 -13
- package/dist/array/sort.d.mts +31 -32
- package/dist/array/sort.mjs +41 -33
- package/dist/array/splice.d.mts +5 -6
- package/dist/array/swap.d.mts +8 -9
- package/dist/array/to-map.d.mts +18 -175
- package/dist/array/to-record.d.mts +18 -175
- package/dist/array/to-set.d.mts +4 -5
- package/dist/array/toggle.d.mts +4 -5
- package/dist/array/union.d.mts +4 -5
- package/dist/array/unique.d.mts +4 -5
- package/dist/array/update.d.mts +4 -5
- package/dist/beacon.d.mts +8 -9
- package/dist/beacon.mjs +90 -65
- package/dist/color/constants.d.mts +14 -13
- package/dist/color/constants.mjs +9 -2
- package/dist/color/index.d.mts +2 -2
- package/dist/color/instance.d.mts +3 -3
- package/dist/color/instance.mjs +125 -61
- package/dist/color/misc/alpha.d.mts +4 -5
- package/dist/color/misc/format.d.mts +6 -7
- package/dist/color/misc/format.mjs +15 -12
- package/dist/color/misc/get.d.mts +14 -15
- package/dist/color/misc/is.d.mts +16 -17
- package/dist/color/misc/is.mjs +3 -4
- package/dist/color/misc/state.d.mts +8 -10
- package/dist/color/misc/state.mjs +22 -20
- package/dist/color/models.d.mts +25 -19
- package/dist/color/space/hex.d.mts +9 -10
- package/dist/color/space/hsl.d.mts +8 -9
- package/dist/color/space/hwb.d.mts +9 -10
- package/dist/color/space/rgb.d.mts +11 -12
- package/dist/function/limit.d.mts +9 -8
- package/dist/function/limit.mjs +5 -5
- package/dist/function/once.d.mts +26 -6
- package/dist/function/once.mjs +135 -76
- package/dist/function/retry.d.mts +5 -6
- package/dist/function/retry.mjs +3 -3
- package/dist/index.d.mts +244 -584
- package/dist/index.mjs +1191 -810
- package/dist/internal/abort.d.mts +3 -4
- package/dist/internal/array/callbacks.d.mts +4 -5
- package/dist/internal/array/chunk.d.mts +2 -3
- package/dist/internal/array/compact.d.mts +3 -4
- package/dist/internal/array/find.d.mts +10 -11
- package/dist/internal/array/get.d.mts +7 -8
- package/dist/internal/array/group.d.mts +2 -3
- package/dist/internal/array/index-of.d.mts +10 -11
- package/dist/internal/array/insert.d.mts +5 -6
- package/dist/internal/array/match.d.mts +17 -18
- package/dist/internal/array/overlap.d.mts +2 -3
- package/dist/internal/array/sets.d.mts +5 -6
- package/dist/internal/array/shuffle.d.mts +2 -3
- package/dist/internal/array/update.d.mts +2 -3
- package/dist/internal/defaults.d.mts +3 -4
- package/dist/internal/function/assert.d.mts +10 -11
- package/dist/internal/function/limit.d.mts +41 -0
- package/dist/internal/function/limit.mjs +110 -0
- package/dist/internal/function/memoize.d.mts +4 -5
- package/dist/internal/function/memoize.mjs +53 -31
- package/dist/internal/function/misc.d.mts +2 -3
- package/dist/internal/function/work.d.mts +53 -54
- package/dist/internal/herald.d.mts +8 -9
- package/dist/internal/herald.mjs +38 -26
- package/dist/internal/is.d.mts +19 -20
- package/dist/internal/math/aggregate.d.mts +14 -15
- package/dist/internal/math/misc.d.mts +3 -4
- package/dist/internal/number.d.mts +4 -5
- package/dist/internal/random.d.mts +3 -4
- package/dist/internal/result/misc.d.mts +29 -14
- package/dist/internal/result/misc.mjs +4 -0
- package/dist/internal/result/models.d.mts +9 -10
- package/dist/internal/sized/map.d.mts +2 -3
- package/dist/internal/sized/misc.d.mts +2 -3
- package/dist/internal/string/case.d.mts +9 -10
- package/dist/internal/string/misc.d.mts +8 -9
- package/dist/internal/subscription.d.mts +14 -15
- package/dist/internal/subscription.mjs +69 -57
- package/dist/internal/value/compare.d.mts +17 -9
- package/dist/internal/value/compare.mjs +7 -7
- package/dist/internal/value/equal.d.mts +34 -15
- package/dist/internal/value/equal.mjs +28 -13
- package/dist/internal/value/get.d.mts +3 -4
- package/dist/internal/value/handlers.d.mts +19 -9
- package/dist/internal/value/handlers.mjs +50 -50
- package/dist/internal/value/has.d.mts +6 -7
- package/dist/internal/value/misc.d.mts +6 -7
- package/dist/internal/value/partial.d.mts +3 -4
- package/dist/internal/value/set.d.mts +4 -5
- package/dist/is.d.mts +13 -13
- package/dist/logger.d.mts +5 -4
- package/dist/logger.mjs +61 -54
- package/dist/math.d.mts +20 -20
- package/dist/models.d.mts +58 -46
- package/dist/promise/constants.d.mts +14 -15
- package/dist/promise/delay.d.mts +3 -4
- package/dist/promise/delay.mjs +4 -4
- package/dist/promise/helpers.d.mts +7 -8
- package/dist/promise/index.d.mts +13 -14
- package/dist/promise/misc.d.mts +6 -6
- package/dist/promise/models.d.mts +16 -17
- package/dist/promise/timed.d.mts +4 -5
- package/dist/promise/timed.mjs +5 -5
- package/dist/query.d.mts +3 -4
- package/dist/queue.d.mts +14 -15
- package/dist/queue.mjs +185 -129
- package/dist/random.d.mts +8 -8
- package/dist/result/index.d.mts +8 -9
- package/dist/result/match.d.mts +6 -7
- package/dist/result/misc.d.mts +3 -3
- package/dist/result/work/flow.d.mts +28 -29
- package/dist/result/work/pipe.d.mts +24 -25
- package/dist/sized/set.d.mts +2 -3
- package/dist/string/fuzzy.d.mts +21 -12
- package/dist/string/fuzzy.mjs +77 -49
- package/dist/string/index.d.mts +8 -8
- package/dist/string/match.d.mts +4 -5
- package/dist/string/normalize.d.mts +8 -9
- package/dist/string/normalize.mjs +9 -4
- package/dist/string/template.d.mts +9 -9
- package/dist/string/template.mjs +11 -4
- package/dist/value/clone.d.mts +21 -13
- package/dist/value/clone.mjs +22 -20
- package/dist/value/collection.d.mts +4 -5
- package/dist/value/diff.d.mts +5 -6
- package/dist/value/freeze.d.mts +18 -19
- package/dist/value/freeze.mjs +1 -1
- package/dist/value/merge.d.mts +13 -14
- package/dist/value/merge.mjs +21 -5
- package/dist/value/omit.d.mts +2 -3
- package/dist/value/pick.d.mts +2 -3
- package/dist/value/shake.d.mts +3 -4
- package/dist/value/smush.d.mts +3 -4
- package/dist/value/transform.d.mts +15 -10
- package/dist/value/transform.mjs +12 -7
- package/dist/value/unsmush.d.mts +3 -4
- package/package.json +1 -1
- package/dist/internal/function/timer.d.mts +0 -10
- package/dist/internal/function/timer.mjs +0 -87
package/dist/index.d.mts
CHANGED
|
@@ -3,30 +3,12 @@
|
|
|
3
3
|
* A generic array or object
|
|
4
4
|
*/
|
|
5
5
|
export type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
|
|
6
|
-
/**
|
|
7
|
-
* An asynchronous callback that can be canceled
|
|
8
|
-
*/
|
|
9
|
-
export type AsyncCancelableCallback<Callback extends GenericAsyncCallback | GenericCallback> = (ReturnType<Callback> extends Promise<any> ? (...args: Parameters<Callback>) => Promise<Awaited<ReturnType<Callback>>> : (...args: Parameters<Callback>) => Promise<ReturnType<Callback>>) & {
|
|
10
|
-
/**
|
|
11
|
-
* Cancel the callback
|
|
12
|
-
*/
|
|
13
|
-
cancel: () => void;
|
|
14
|
-
};
|
|
15
6
|
/**
|
|
16
7
|
* For matching any `void`, `Date`, primitive, or `RegExp` values
|
|
17
8
|
*
|
|
18
9
|
* _(Thanks, type-fest!)_
|
|
19
10
|
*/
|
|
20
11
|
export type BuiltIns = void | Date | Primitive | RegExp;
|
|
21
|
-
/**
|
|
22
|
-
* A synchronous callback that can be canceled
|
|
23
|
-
*/
|
|
24
|
-
export type CancelableCallback<Callback extends GenericCallback> = Callback & {
|
|
25
|
-
/**
|
|
26
|
-
* Cancel the callback
|
|
27
|
-
*/
|
|
28
|
-
cancel: () => void;
|
|
29
|
-
};
|
|
30
12
|
/**
|
|
31
13
|
* A generic class constructor
|
|
32
14
|
*/
|
|
@@ -43,7 +25,23 @@ export type GenericCallback = (...args: any[]) => any;
|
|
|
43
25
|
* A generic key type
|
|
44
26
|
*/
|
|
45
27
|
type Key$1 = number | string;
|
|
28
|
+
/**
|
|
29
|
+
* The `PropertyKey`-safe value of `Item`'s `ItemKey` property
|
|
30
|
+
*/
|
|
46
31
|
export type KeyedValue<Item, ItemKey extends keyof Item> = Item[ItemKey] extends PropertyKey ? Item[ItemKey] : never;
|
|
32
|
+
/**
|
|
33
|
+
* A key of `Item`, or a callback returning `Return`, used to derive a value from an item
|
|
34
|
+
*/
|
|
35
|
+
export type KeyOrCallback<Item, Return = unknown> = ((item: Item, index: number, array: Item[]) => Return) | (Item extends PlainObject ? keyof Item : never);
|
|
36
|
+
/**
|
|
37
|
+
* The `PropertyKey`-safe value resolved from a `KeyOrCallback<Item, Key>` argument, for use as a
|
|
38
|
+
* `Record` or `Map` key
|
|
39
|
+
*/
|
|
40
|
+
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;
|
|
41
|
+
/**
|
|
42
|
+
* The value resolved from a `KeyOrCallback` argument against `Item`
|
|
43
|
+
*/
|
|
44
|
+
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
45
|
/**
|
|
48
46
|
* A nested array
|
|
49
47
|
*/
|
|
@@ -77,7 +75,7 @@ export type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item
|
|
|
77
75
|
/**
|
|
78
76
|
* An asynchronous function that can only be called once, returning the same value on subsequent calls
|
|
79
77
|
*/
|
|
80
|
-
|
|
78
|
+
type OnceAsync<Callback extends GenericAsyncCallback> = {
|
|
81
79
|
/**
|
|
82
80
|
* Did the callback's promise reject?
|
|
83
81
|
*/
|
|
@@ -86,12 +84,27 @@ export type OnceAsyncCallback<Callback extends GenericAsyncCallback> = {
|
|
|
86
84
|
* Has the callback finished?
|
|
87
85
|
*/
|
|
88
86
|
readonly finished: boolean;
|
|
89
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Run the callback
|
|
89
|
+
*
|
|
90
|
+
* @param parameters Callback parameters
|
|
91
|
+
* @returns Call result
|
|
92
|
+
*/
|
|
93
|
+
run: (...parameters: Parameters<Callback>) => ReturnType<Callback>;
|
|
94
|
+
} & OnceProperties;
|
|
90
95
|
/**
|
|
91
96
|
* A callback function that can only be called once, returning the same value on subsequent calls
|
|
92
97
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
type Once<Callback extends GenericCallback> = {
|
|
99
|
+
/**
|
|
100
|
+
* Run the callback
|
|
101
|
+
*
|
|
102
|
+
* @param parameters Callback parameters
|
|
103
|
+
* @returns Call result
|
|
104
|
+
*/
|
|
105
|
+
run: (...parameters: Parameters<Callback>) => ReturnType<Callback>;
|
|
106
|
+
} & OnceProperties;
|
|
107
|
+
type OnceProperties = {
|
|
95
108
|
/**
|
|
96
109
|
* Has the callback been called?
|
|
97
110
|
*/
|
|
@@ -450,33 +463,13 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item):
|
|
|
450
463
|
//#endregion
|
|
451
464
|
//#region src/array/group-by.d.ts
|
|
452
465
|
/**
|
|
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
|
|
466
|
+
* Create a record from an array of items using a specific key
|
|
474
467
|
*
|
|
475
468
|
* If multiple items have the same key, the latest item's value will be used
|
|
476
469
|
*
|
|
477
470
|
* @param array Array to group
|
|
478
|
-
* @param key Callback to
|
|
479
|
-
* @param value
|
|
471
|
+
* @param key Callback or key to use for grouping
|
|
472
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
480
473
|
* @returns Record of keyed values
|
|
481
474
|
*
|
|
482
475
|
* @example
|
|
@@ -484,58 +477,18 @@ export declare function groupBy<Item, KeyCallback extends (item: Item, index: nu
|
|
|
484
477
|
* groupBy(
|
|
485
478
|
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
486
479
|
* 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
480
|
* item => item,
|
|
508
481
|
* ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
|
|
509
482
|
* ```
|
|
510
483
|
*/
|
|
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]>>;
|
|
484
|
+
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
485
|
/**
|
|
533
486
|
* Create a record from an array of items using a specific key
|
|
534
487
|
*
|
|
535
488
|
* If multiple items have the same key, the latest item will be used
|
|
536
489
|
*
|
|
537
490
|
* @param array Array to group
|
|
538
|
-
* @param
|
|
491
|
+
* @param key Callback or key to use for grouping
|
|
539
492
|
* @returns Record of keyed items
|
|
540
493
|
*
|
|
541
494
|
* @example
|
|
@@ -546,25 +499,7 @@ export declare function groupBy<Item extends PlainObject, ItemKey extends keyof
|
|
|
546
499
|
* ); // => {10: {id: 3, value: 10}, 20: {id: 2, value: 20}}
|
|
547
500
|
* ```
|
|
548
501
|
*/
|
|
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>>;
|
|
502
|
+
export declare function groupBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
|
|
568
503
|
/**
|
|
569
504
|
* Create a record from an array of items _(using indices as keys)_
|
|
570
505
|
*
|
|
@@ -583,13 +518,13 @@ export declare namespace groupBy {
|
|
|
583
518
|
var arrays: typeof groupArraysBy;
|
|
584
519
|
}
|
|
585
520
|
/**
|
|
586
|
-
* Create a record from an array of items using a specific key
|
|
521
|
+
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
587
522
|
*
|
|
588
523
|
* _Available as `groupArraysBy` and `groupBy.arrays`_
|
|
589
524
|
*
|
|
590
525
|
* @param array Array to group
|
|
591
|
-
* @param key Callback to
|
|
592
|
-
* @param value Callback to
|
|
526
|
+
* @param key Callback or key to use for grouping
|
|
527
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
593
528
|
* @returns Record of keyed values
|
|
594
529
|
*
|
|
595
530
|
* @example
|
|
@@ -604,83 +539,14 @@ export declare namespace groupBy {
|
|
|
604
539
|
* // }
|
|
605
540
|
* ```
|
|
606
541
|
*/
|
|
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][]>>;
|
|
542
|
+
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
543
|
/**
|
|
678
544
|
* Create a record from an array of items using a specific key, grouping items into arrays
|
|
679
545
|
*
|
|
680
546
|
* _Available as `groupArraysBy` and `groupBy.arrays`_
|
|
681
547
|
*
|
|
682
548
|
* @param array Array to group
|
|
683
|
-
* @param
|
|
549
|
+
* @param key Callback or key to use for grouping
|
|
684
550
|
* @returns Record of keyed items
|
|
685
551
|
*
|
|
686
552
|
* @example
|
|
@@ -694,28 +560,7 @@ export declare function groupArraysBy<Item extends PlainObject, ItemKey extends
|
|
|
694
560
|
* // }
|
|
695
561
|
* ```
|
|
696
562
|
*/
|
|
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[]>>;
|
|
563
|
+
export declare function groupArraysBy<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
719
564
|
//#endregion
|
|
720
565
|
//#region src/internal/array/chunk.d.ts
|
|
721
566
|
/**
|
|
@@ -2926,13 +2771,6 @@ export type SortDirection = 'ascending' | 'descending';
|
|
|
2926
2771
|
* Can be used to sort an array, get the predicted index for an item, and check if an array is sorted
|
|
2927
2772
|
*/
|
|
2928
2773
|
export type Sorter<Item> = {
|
|
2929
|
-
/**
|
|
2930
|
-
* Sort an array of items
|
|
2931
|
-
*
|
|
2932
|
-
* @param array Array to sort
|
|
2933
|
-
* @returns Sorted array
|
|
2934
|
-
*/
|
|
2935
|
-
(array: Item[]): Item[];
|
|
2936
2774
|
/**
|
|
2937
2775
|
* Get the index for an item _(to be inserted into an array of items)_
|
|
2938
2776
|
*
|
|
@@ -2950,6 +2788,13 @@ export type Sorter<Item> = {
|
|
|
2950
2788
|
* @returns `true` if sorted, otherwise `false`
|
|
2951
2789
|
*/
|
|
2952
2790
|
is(array: Item[]): boolean;
|
|
2791
|
+
/**
|
|
2792
|
+
* Sort an array of items
|
|
2793
|
+
*
|
|
2794
|
+
* @param array Array to sort
|
|
2795
|
+
* @returns Sorted array
|
|
2796
|
+
*/
|
|
2797
|
+
sort(array: Item[]): Item[];
|
|
2953
2798
|
};
|
|
2954
2799
|
/**
|
|
2955
2800
|
* Get the index for an item _(to be inserted into an array of items)_ based on sorters _(and an optional default direction)_
|
|
@@ -3290,33 +3135,13 @@ declare function swapIndices<Item>(array: Item[], first: number, second: number)
|
|
|
3290
3135
|
//#endregion
|
|
3291
3136
|
//#region src/array/to-map.d.ts
|
|
3292
3137
|
/**
|
|
3293
|
-
* Create a _Map_ from an array of items using
|
|
3294
|
-
*
|
|
3295
|
-
* If multiple items have the same key, the latest item's value will be used
|
|
3296
|
-
*
|
|
3297
|
-
* @param array Array to convert
|
|
3298
|
-
* @param key Callback to get an item's grouping key
|
|
3299
|
-
* @param value Callback to get an item's value
|
|
3300
|
-
* @returns _Map_ of keyed values
|
|
3301
|
-
*
|
|
3302
|
-
* @example
|
|
3303
|
-
* ```typescript
|
|
3304
|
-
* toMap(
|
|
3305
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3306
|
-
* item => item.value,
|
|
3307
|
-
* item => item.id,
|
|
3308
|
-
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3309
|
-
* ```
|
|
3310
|
-
*/
|
|
3311
|
-
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>>;
|
|
3312
|
-
/**
|
|
3313
|
-
* Create a _Map_ from an array of items using a callback and value
|
|
3138
|
+
* Create a _Map_ from an array of items using a specific key
|
|
3314
3139
|
*
|
|
3315
3140
|
* If multiple items have the same key, the latest item's value will be used
|
|
3316
3141
|
*
|
|
3317
3142
|
* @param array Array to convert
|
|
3318
|
-
* @param key Callback to
|
|
3319
|
-
* @param value
|
|
3143
|
+
* @param key Callback or key to use for grouping
|
|
3144
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
3320
3145
|
* @returns _Map_ of keyed values
|
|
3321
3146
|
*
|
|
3322
3147
|
* @example
|
|
@@ -3324,58 +3149,18 @@ export declare function toMap<Item, KeyCallback extends (item: Item, index: numb
|
|
|
3324
3149
|
* toMap(
|
|
3325
3150
|
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3326
3151
|
* 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
3152
|
* item => item.id,
|
|
3348
3153
|
* ); // => Map { 10 => 3, 20 => 2 }
|
|
3349
3154
|
* ```
|
|
3350
3155
|
*/
|
|
3351
|
-
export declare function toMap<Item
|
|
3156
|
+
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>>;
|
|
3352
3157
|
/**
|
|
3353
|
-
* Create a _Map_ from an array of items using a key
|
|
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
|
|
3158
|
+
* Create a _Map_ from an array of items using a specific key
|
|
3374
3159
|
*
|
|
3375
3160
|
* If multiple items have the same key, the latest item will be used
|
|
3376
3161
|
*
|
|
3377
3162
|
* @param array Array to convert
|
|
3378
|
-
* @param
|
|
3163
|
+
* @param key Callback or key to use for grouping
|
|
3379
3164
|
* @returns _Map_ of keyed items
|
|
3380
3165
|
*
|
|
3381
3166
|
* @example
|
|
@@ -3386,25 +3171,7 @@ export declare function toMap<Item extends PlainObject, ItemKey extends keyof It
|
|
|
3386
3171
|
* ); // => Map { 10 => {id: 3, value: 10}, 20 => {id: 2, value: 20} }
|
|
3387
3172
|
* ```
|
|
3388
3173
|
*/
|
|
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>;
|
|
3174
|
+
export declare function toMap<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item>;
|
|
3408
3175
|
/**
|
|
3409
3176
|
* Create a _Map_ from an array of items _(using indices as keys)_
|
|
3410
3177
|
*
|
|
@@ -3423,33 +3190,13 @@ export declare namespace toMap {
|
|
|
3423
3190
|
var arrays: typeof toMapArrays;
|
|
3424
3191
|
}
|
|
3425
3192
|
/**
|
|
3426
|
-
* Create a _Map_ from an array of items using
|
|
3427
|
-
*
|
|
3428
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3429
|
-
*
|
|
3430
|
-
* @param array Array to convert
|
|
3431
|
-
* @param key Callback to get an item's grouping key
|
|
3432
|
-
* @param value Callback to get an item's value
|
|
3433
|
-
* @returns _Map_ of keyed arrays of values
|
|
3434
|
-
*
|
|
3435
|
-
* @example
|
|
3436
|
-
* ```typescript
|
|
3437
|
-
* toMapArrays(
|
|
3438
|
-
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3439
|
-
* item => item.value,
|
|
3440
|
-
* item => item.id,
|
|
3441
|
-
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3442
|
-
* ```
|
|
3443
|
-
*/
|
|
3444
|
-
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>>>;
|
|
3445
|
-
/**
|
|
3446
|
-
* Create a _Map_ from an array of items using a callback and value, grouping values into arrays
|
|
3193
|
+
* Create a _Map_ from an array of items using a specific key, grouping values into arrays
|
|
3447
3194
|
*
|
|
3448
3195
|
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3449
3196
|
*
|
|
3450
3197
|
* @param array Array to convert
|
|
3451
|
-
* @param key Callback to
|
|
3452
|
-
* @param value
|
|
3198
|
+
* @param key Callback or key to use for grouping
|
|
3199
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
3453
3200
|
* @returns _Map_ of keyed arrays of values
|
|
3454
3201
|
*
|
|
3455
3202
|
* @example
|
|
@@ -3457,58 +3204,18 @@ export declare function toMapArrays<Item, KeyCallback extends (item: Item, index
|
|
|
3457
3204
|
* toMapArrays(
|
|
3458
3205
|
* [{id: 1, value: 10}, {id: 2, value: 20}, {id: 3, value: 10}],
|
|
3459
3206
|
* 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
3207
|
* item => item.id,
|
|
3481
3208
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3482
3209
|
* ```
|
|
3483
3210
|
*/
|
|
3484
|
-
export declare function toMapArrays<Item
|
|
3485
|
-
/**
|
|
3486
|
-
* Create a _Map_ from an array of items using a key and value, grouping values into arrays
|
|
3487
|
-
*
|
|
3488
|
-
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3489
|
-
*
|
|
3490
|
-
* @param array Array to convert
|
|
3491
|
-
* @param key Key to use for grouping
|
|
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][]>;
|
|
3211
|
+
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>>>;
|
|
3505
3212
|
/**
|
|
3506
|
-
* Create a _Map_ from an array of items using a
|
|
3213
|
+
* Create a _Map_ from an array of items using a specific key, grouping items into arrays
|
|
3507
3214
|
*
|
|
3508
3215
|
* _Available as `toMapArrays` and `toMap.arrays`_
|
|
3509
3216
|
*
|
|
3510
3217
|
* @param array Array to convert
|
|
3511
|
-
* @param
|
|
3218
|
+
* @param key Callback or key to use for grouping
|
|
3512
3219
|
* @returns _Map_ of keyed arrays of items
|
|
3513
3220
|
*
|
|
3514
3221
|
* @example
|
|
@@ -3519,35 +3226,17 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
|
|
|
3519
3226
|
* ); // => Map { 10 => [{id: 1, value: 10}, {id: 3, value: 10}], 20 => [{id: 2, value: 20}] }
|
|
3520
3227
|
* ```
|
|
3521
3228
|
*/
|
|
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[]>;
|
|
3229
|
+
export declare function toMapArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Map<KeyOrCallbackKey<Item, KeyArg>, Item[]>;
|
|
3541
3230
|
//#endregion
|
|
3542
3231
|
//#region src/array/to-record.d.ts
|
|
3543
3232
|
/**
|
|
3544
|
-
* Create a record from an array of items using
|
|
3233
|
+
* Create a record from an array of items using a specific key
|
|
3545
3234
|
*
|
|
3546
3235
|
* If multiple items have the same key, the latest item will be used
|
|
3547
3236
|
*
|
|
3548
3237
|
* @param array Array to convert
|
|
3549
|
-
* @param key Callback to
|
|
3550
|
-
* @param value Callback to
|
|
3238
|
+
* @param key Callback or key to use for grouping
|
|
3239
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
3551
3240
|
* @returns Record of keyed values
|
|
3552
3241
|
*
|
|
3553
3242
|
* @example
|
|
@@ -3559,74 +3248,14 @@ export declare function toMapArrays<Item extends PlainObject, ItemKey extends ke
|
|
|
3559
3248
|
* ); // => { 10: 3, 20: 2 }
|
|
3560
3249
|
* ```
|
|
3561
3250
|
*/
|
|
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]>;
|
|
3251
|
+
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>>>;
|
|
3583
3252
|
/**
|
|
3584
|
-
* Create a record from an array of items using a key
|
|
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>>>;
|
|
3603
|
-
/**
|
|
3604
|
-
* Create a record from an array of items using a key and value
|
|
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
|
|
3253
|
+
* Create a record from an array of items using a specific key
|
|
3625
3254
|
*
|
|
3626
3255
|
* If multiple items have the same key, the latest item will be used
|
|
3627
3256
|
*
|
|
3628
3257
|
* @param array Array to convert
|
|
3629
|
-
* @param
|
|
3258
|
+
* @param key Callback or key to use for grouping
|
|
3630
3259
|
* @returns Record of keyed values
|
|
3631
3260
|
*
|
|
3632
3261
|
* @example
|
|
@@ -3637,25 +3266,7 @@ export declare function toRecord<Item extends PlainObject, ItemKey extends keyof
|
|
|
3637
3266
|
* ); // => { 10: {id: 3, value: 10}, 20: {id: 2, value: 20} }
|
|
3638
3267
|
* ```
|
|
3639
3268
|
*/
|
|
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>>;
|
|
3269
|
+
export declare function toRecord<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item>>;
|
|
3659
3270
|
/**
|
|
3660
3271
|
* Create a record from an array of items _(using indices as keys)_
|
|
3661
3272
|
*
|
|
@@ -3674,13 +3285,13 @@ export declare namespace toRecord {
|
|
|
3674
3285
|
var arrays: typeof toRecordArrays;
|
|
3675
3286
|
}
|
|
3676
3287
|
/**
|
|
3677
|
-
* Create a record from an array of items using
|
|
3288
|
+
* Create a record from an array of items using a specific key, grouping values into arrays
|
|
3678
3289
|
*
|
|
3679
3290
|
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3680
3291
|
*
|
|
3681
3292
|
* @param array Array to convert
|
|
3682
|
-
* @param key Callback to
|
|
3683
|
-
* @param value Callback to
|
|
3293
|
+
* @param key Callback or key to use for grouping
|
|
3294
|
+
* @param value Callback or key to use for value, defaulting to the item itself
|
|
3684
3295
|
* @returns Record of keyed arrays of values
|
|
3685
3296
|
*
|
|
3686
3297
|
* @example
|
|
@@ -3692,74 +3303,14 @@ export declare namespace toRecord {
|
|
|
3692
3303
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
3693
3304
|
* ```
|
|
3694
3305
|
*/
|
|
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][]>;
|
|
3306
|
+
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
3307
|
/**
|
|
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
|
|
3308
|
+
* Create a record from an array of items using a specific key, grouping items into arrays
|
|
3758
3309
|
*
|
|
3759
3310
|
* _Available as `toRecordArrays` and `toRecord.arrays`_
|
|
3760
3311
|
*
|
|
3761
3312
|
* @param array Array to convert
|
|
3762
|
-
* @param
|
|
3313
|
+
* @param key Callback or key to use for grouping
|
|
3763
3314
|
* @returns Record of keyed arrays of items
|
|
3764
3315
|
*
|
|
3765
3316
|
* @example
|
|
@@ -3770,25 +3321,7 @@ export declare function toRecordArrays<Item extends PlainObject, ItemKey extends
|
|
|
3770
3321
|
* ); // => { 10: [{id: 1, value: 10}, {id: 3, value: 10}], 20: [{id: 2, value: 20}] }
|
|
3771
3322
|
* ```
|
|
3772
3323
|
*/
|
|
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[]>>;
|
|
3324
|
+
export declare function toRecordArrays<Item, KeyArg extends KeyOrCallback<Item, Key$1>>(array: Item[], key: KeyArg): Simplify<Record<KeyOrCallbackKey<Item, KeyArg>, Item[]>>;
|
|
3792
3325
|
//#endregion
|
|
3793
3326
|
//#region src/internal/function/misc.d.ts
|
|
3794
3327
|
/**
|
|
@@ -3796,6 +3329,40 @@ export declare function toRecordArrays<Item extends PlainObject, ItemKey extends
|
|
|
3796
3329
|
*/
|
|
3797
3330
|
export declare function noop(): void;
|
|
3798
3331
|
//#endregion
|
|
3332
|
+
//#region src/internal/function/limit.d.ts
|
|
3333
|
+
/**
|
|
3334
|
+
* An asynchronous function that can be cancelled
|
|
3335
|
+
*/
|
|
3336
|
+
type AsyncLimiter<Callback extends GenericAsyncCallback> = {
|
|
3337
|
+
/**
|
|
3338
|
+
* Cancel the function
|
|
3339
|
+
*/
|
|
3340
|
+
cancel(): void;
|
|
3341
|
+
/**
|
|
3342
|
+
* Call the function
|
|
3343
|
+
*
|
|
3344
|
+
* @param parameters Function parameters
|
|
3345
|
+
* @returns Function result
|
|
3346
|
+
*/
|
|
3347
|
+
run(...parameters: Parameters<Callback>): Promise<ReturnType<Callback>>;
|
|
3348
|
+
};
|
|
3349
|
+
/**
|
|
3350
|
+
* A function that can be cancelled
|
|
3351
|
+
*/
|
|
3352
|
+
type Limiter<Callback extends GenericCallback> = {
|
|
3353
|
+
/**
|
|
3354
|
+
* Cancel the function
|
|
3355
|
+
*/
|
|
3356
|
+
cancel(): void;
|
|
3357
|
+
/**
|
|
3358
|
+
* Call the function
|
|
3359
|
+
*
|
|
3360
|
+
* @param parameters Function parameters
|
|
3361
|
+
* @returns Function result
|
|
3362
|
+
*/
|
|
3363
|
+
run(...parameters: Parameters<Callback>): ReturnType<Callback>;
|
|
3364
|
+
};
|
|
3365
|
+
//#endregion
|
|
3799
3366
|
//#region src/function/limit.d.ts
|
|
3800
3367
|
/**
|
|
3801
3368
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
@@ -3809,7 +3376,7 @@ export declare function noop(): void;
|
|
|
3809
3376
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
3810
3377
|
* @returns Debounced callback handler with a `cancel` method
|
|
3811
3378
|
*/
|
|
3812
|
-
export declare function asyncDebounce<Callback extends GenericAsyncCallback | GenericCallback>(callback: Callback, time?: number):
|
|
3379
|
+
export declare function asyncDebounce<Callback extends GenericAsyncCallback | GenericCallback>(callback: Callback, time?: number): AsyncLimiter<Callback>;
|
|
3813
3380
|
/**
|
|
3814
3381
|
* Throttle a function, ensuring it is only called once every `time` milliseconds
|
|
3815
3382
|
*
|
|
@@ -3822,7 +3389,7 @@ export declare function asyncDebounce<Callback extends GenericAsyncCallback | Ge
|
|
|
3822
3389
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
3823
3390
|
* @returns Throttled callback handler with a `cancel` method
|
|
3824
3391
|
*/
|
|
3825
|
-
export declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCallback>(callback: Callback, time?: number):
|
|
3392
|
+
export declare function asyncThrottle<Callback extends GenericAsyncCallback | GenericCallback>(callback: Callback, time?: number): AsyncLimiter<Callback>;
|
|
3826
3393
|
/**
|
|
3827
3394
|
* Debounce a function, ensuring it is only called after `time` milliseconds have passed
|
|
3828
3395
|
*
|
|
@@ -3832,7 +3399,7 @@ export declare function asyncThrottle<Callback extends GenericAsyncCallback | Ge
|
|
|
3832
3399
|
* @param time Time in milliseconds to wait before calling the callback _(defaults to `0`; e.g., as soon as possible)_
|
|
3833
3400
|
* @returns Debounced callback handler with a `cancel` method
|
|
3834
3401
|
*/
|
|
3835
|
-
export declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number):
|
|
3402
|
+
export declare function debounce<Callback extends GenericCallback>(callback: Callback, time?: number): Limiter<Callback>;
|
|
3836
3403
|
export declare namespace debounce {
|
|
3837
3404
|
var async: typeof asyncDebounce;
|
|
3838
3405
|
}
|
|
@@ -3843,12 +3410,14 @@ export declare namespace debounce {
|
|
|
3843
3410
|
* @param time Time in milliseconds to wait before calling the callback again _(defaults to `0`; e.g., as soon as possible)_
|
|
3844
3411
|
* @returns Throttled callback handler with a `cancel` method
|
|
3845
3412
|
*/
|
|
3846
|
-
export declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number):
|
|
3413
|
+
export declare function throttle<Callback extends GenericCallback>(callback: Callback, time?: number): Limiter<Callback>;
|
|
3847
3414
|
export declare namespace throttle {
|
|
3848
3415
|
var async: typeof asyncThrottle;
|
|
3849
3416
|
}
|
|
3850
3417
|
//#endregion
|
|
3851
3418
|
//#region src/function/once.d.ts
|
|
3419
|
+
declare function OnceAsync(this: any, callback: GenericAsyncCallback): void;
|
|
3420
|
+
declare function Once(this: any, callback: GenericCallback): void;
|
|
3852
3421
|
/**
|
|
3853
3422
|
* Create an asynchronous function that can only be called once, rejecting or resolving the same result on subsequent calls
|
|
3854
3423
|
*
|
|
@@ -3857,16 +3426,35 @@ export declare namespace throttle {
|
|
|
3857
3426
|
* @param callback Callback to use once
|
|
3858
3427
|
* @returns _Once_ callback
|
|
3859
3428
|
*/
|
|
3860
|
-
export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback):
|
|
3429
|
+
export declare function asyncOnce<Callback extends GenericAsyncCallback>(callback: Callback): OnceAsync<Callback>;
|
|
3430
|
+
export declare namespace asyncOnce {
|
|
3431
|
+
var is: typeof isAsyncOnce;
|
|
3432
|
+
}
|
|
3433
|
+
/**
|
|
3434
|
+
* Is the value an asynchronous once callback?
|
|
3435
|
+
*
|
|
3436
|
+
* @param value Value to check
|
|
3437
|
+
* @returns `true` if the value is an asynchronous once callback, otherwise `false`
|
|
3438
|
+
*/
|
|
3439
|
+
export declare function isAsyncOnce(value: unknown): boolean;
|
|
3440
|
+
/**
|
|
3441
|
+
* Is the value a once callback?
|
|
3442
|
+
*
|
|
3443
|
+
* @param value Value to check
|
|
3444
|
+
* @returns `true` if the value is a once callback, otherwise `false`
|
|
3445
|
+
*/
|
|
3446
|
+
export declare function isOnce(value: unknown): boolean;
|
|
3861
3447
|
/**
|
|
3862
3448
|
* Create a function that can only be called once, returning the same value on subsequent calls
|
|
3863
3449
|
*
|
|
3864
3450
|
* @param callback Callback to use once
|
|
3865
3451
|
* @returns _Once_ callback
|
|
3866
3452
|
*/
|
|
3867
|
-
export declare function once<Callback extends GenericCallback>(callback: Callback):
|
|
3453
|
+
export declare function once<Callback extends GenericCallback>(callback: Callback): Once<Callback>;
|
|
3868
3454
|
export declare namespace once {
|
|
3869
3455
|
var async: typeof asyncOnce;
|
|
3456
|
+
var is: typeof isOnce;
|
|
3457
|
+
var isAsync: typeof isAsyncOnce;
|
|
3870
3458
|
}
|
|
3871
3459
|
//#endregion
|
|
3872
3460
|
//#region src/function/retry.d.ts
|
|
@@ -4670,10 +4258,19 @@ type Comparator<Value = any> = (first: Value, second: Value) => number;
|
|
|
4670
4258
|
export declare function compare(first: unknown, second: unknown): number;
|
|
4671
4259
|
export declare namespace compare {
|
|
4672
4260
|
var deregister: typeof deregisterComparator;
|
|
4673
|
-
var
|
|
4674
|
-
|
|
4261
|
+
var handler: {
|
|
4262
|
+
base: {
|
|
4263
|
+
handlers: WeakMap<Constructor, string | GenericCallback>;
|
|
4264
|
+
options: {
|
|
4265
|
+
callback: GenericCallback;
|
|
4266
|
+
method?: string;
|
|
4267
|
+
};
|
|
4268
|
+
owner: GenericCallback;
|
|
4269
|
+
deregister: (constructor: Constructor) => void;
|
|
4270
|
+
get: (first: unknown, second: unknown) => string | GenericCallback | undefined;
|
|
4271
|
+
register: (constructor: Constructor, handler?: string | GenericCallback) => void;
|
|
4272
|
+
};
|
|
4675
4273
|
handle(first: unknown, second: unknown, ...parameters: unknown[]): number;
|
|
4676
|
-
register(constructor: Constructor, handler?: string | GenericCallback): void;
|
|
4677
4274
|
};
|
|
4678
4275
|
var register: typeof registerComparator;
|
|
4679
4276
|
}
|
|
@@ -4727,7 +4324,7 @@ type Equalizer = {
|
|
|
4727
4324
|
* @param ignoreCase If `true`, comparison will be case-insensitive
|
|
4728
4325
|
* @returns `true` if the strings are equal, otherwise `false`
|
|
4729
4326
|
*/
|
|
4730
|
-
(first: string, second: string, ignoreCase?: boolean): boolean;
|
|
4327
|
+
compare(first: string, second: string, ignoreCase?: boolean): boolean;
|
|
4731
4328
|
/**
|
|
4732
4329
|
* Are two values equal?
|
|
4733
4330
|
*
|
|
@@ -4735,7 +4332,7 @@ type Equalizer = {
|
|
|
4735
4332
|
* @param second Second value
|
|
4736
4333
|
* @returns `true` if the values are equal, otherwise `false`
|
|
4737
4334
|
*/
|
|
4738
|
-
(first: unknown, second: unknown): boolean;
|
|
4335
|
+
compare(first: unknown, second: unknown): boolean;
|
|
4739
4336
|
/**
|
|
4740
4337
|
* Deregister a equality comparison handler for a specific class
|
|
4741
4338
|
*
|
|
@@ -4750,6 +4347,17 @@ type Equalizer = {
|
|
|
4750
4347
|
*/
|
|
4751
4348
|
register: <Instance>(constructor: Constructor<Instance>, handler: (first: Instance, second: Instance) => boolean) => void;
|
|
4752
4349
|
};
|
|
4350
|
+
type Options = {
|
|
4351
|
+
ignoreCase: boolean;
|
|
4352
|
+
ignoreExpressions: OptionsKeys<RegExp[]>;
|
|
4353
|
+
ignoreKeys: OptionsKeys<Set<string>>;
|
|
4354
|
+
relaxedNullish: boolean;
|
|
4355
|
+
};
|
|
4356
|
+
type OptionsKeys<Values> = {
|
|
4357
|
+
enabled: boolean;
|
|
4358
|
+
values: Values;
|
|
4359
|
+
};
|
|
4360
|
+
declare function Equalizer(this: any, options: Options): void;
|
|
4753
4361
|
/**
|
|
4754
4362
|
* Deregister a equality comparison handler for a specific class
|
|
4755
4363
|
*
|
|
@@ -4777,12 +4385,21 @@ export declare function equal(first: string, second: string, ignoreCase?: boolea
|
|
|
4777
4385
|
*/
|
|
4778
4386
|
export declare function equal(first: unknown, second: unknown, options?: EqualOptions): boolean;
|
|
4779
4387
|
export declare namespace equal {
|
|
4780
|
-
var
|
|
4781
|
-
|
|
4388
|
+
var deregister: typeof deregisterEqualizer;
|
|
4389
|
+
var handler: {
|
|
4390
|
+
base: {
|
|
4391
|
+
handlers: WeakMap<Constructor, string | GenericCallback>;
|
|
4392
|
+
options: {
|
|
4393
|
+
callback: GenericCallback;
|
|
4394
|
+
method?: string;
|
|
4395
|
+
};
|
|
4396
|
+
owner: GenericCallback;
|
|
4397
|
+
deregister: (constructor: Constructor) => void;
|
|
4398
|
+
get: (first: unknown, second: unknown) => string | GenericCallback | undefined;
|
|
4399
|
+
register: (constructor: Constructor, handler?: string | GenericCallback) => void;
|
|
4400
|
+
};
|
|
4782
4401
|
handle(first: unknown, second: unknown, ...parameters: unknown[]): boolean;
|
|
4783
|
-
register(constructor: Constructor, handler?: string | GenericCallback): void;
|
|
4784
4402
|
};
|
|
4785
|
-
var deregister: typeof deregisterEqualizer;
|
|
4786
4403
|
var initialize: typeof initializeEqualizer;
|
|
4787
4404
|
var register: typeof registerEqualizer;
|
|
4788
4405
|
}
|
|
@@ -5231,9 +4848,14 @@ export declare function error<E>(value: E, original: Error): ExtendedErr<E>;
|
|
|
5231
4848
|
* @returns Error result
|
|
5232
4849
|
*/
|
|
5233
4850
|
export declare function error<E>(value: E): Err<E>;
|
|
4851
|
+
export declare namespace error {
|
|
4852
|
+
var is: typeof isError;
|
|
4853
|
+
}
|
|
5234
4854
|
/**
|
|
5235
4855
|
* Is the _Result_ an extended error?
|
|
5236
4856
|
*
|
|
4857
|
+
* _Available as `isError` and `error.is`_
|
|
4858
|
+
*
|
|
5237
4859
|
* @param result _Result_ to check
|
|
5238
4860
|
* @returns `true` if the _Result_ is an extended error, otherwise `false`
|
|
5239
4861
|
*/
|
|
@@ -5241,6 +4863,8 @@ export declare function isError<Value, E = Error>(result: ExtendedErr<E> | Resul
|
|
|
5241
4863
|
/**
|
|
5242
4864
|
* Is the _Result_ an error?
|
|
5243
4865
|
*
|
|
4866
|
+
* _Available as `isError` and `error.is`_
|
|
4867
|
+
*
|
|
5244
4868
|
* @param result _Result_ to check
|
|
5245
4869
|
* @returns `true` if the _Result_ is an error, otherwise `false`
|
|
5246
4870
|
*/
|
|
@@ -5248,6 +4872,8 @@ export declare function isError<Value, E = Error>(result: Result<Value, E>): res
|
|
|
5248
4872
|
/**
|
|
5249
4873
|
* Is the value an error?
|
|
5250
4874
|
*
|
|
4875
|
+
* _Available as `isError` and `error.is`_
|
|
4876
|
+
*
|
|
5251
4877
|
* @param value Value to check
|
|
5252
4878
|
* @returns `true` if the value is an error, otherwise `false`
|
|
5253
4879
|
*/
|
|
@@ -5255,6 +4881,8 @@ export declare function isError(value: unknown): value is Err<unknown> | Extende
|
|
|
5255
4881
|
/**
|
|
5256
4882
|
* Is the _Result_ ok?
|
|
5257
4883
|
*
|
|
4884
|
+
* _Available as `isOk` and `ok.is`_
|
|
4885
|
+
*
|
|
5258
4886
|
* @param value _Result_ to check
|
|
5259
4887
|
* @returns `true` if the _Result_ is ok, otherwise `false`
|
|
5260
4888
|
*/
|
|
@@ -5262,6 +4890,8 @@ export declare function isOk<Value, E = Error>(value: Result<Value, E>): value i
|
|
|
5262
4890
|
/**
|
|
5263
4891
|
* Is the value ok?
|
|
5264
4892
|
*
|
|
4893
|
+
* _Available as `isOk` and `ok.is`_
|
|
4894
|
+
*
|
|
5265
4895
|
* @param value Value to check
|
|
5266
4896
|
* @returns `true` if the value is ok, otherwise `false`
|
|
5267
4897
|
*/
|
|
@@ -5280,6 +4910,9 @@ export declare function isResult(value: unknown): value is ExtendedErr<unknown>
|
|
|
5280
4910
|
* @returns Ok result
|
|
5281
4911
|
*/
|
|
5282
4912
|
export declare function ok<Value>(value: Value): Ok<Value>;
|
|
4913
|
+
export declare namespace ok {
|
|
4914
|
+
var is: typeof isOk;
|
|
4915
|
+
}
|
|
5283
4916
|
/**
|
|
5284
4917
|
* Gets the value of an ok result _(or a default value)_
|
|
5285
4918
|
*
|
|
@@ -5952,6 +5585,7 @@ export declare function fuzzy<Item>(items: Item[], handler?: (item: Item) => str
|
|
|
5952
5585
|
*/
|
|
5953
5586
|
export declare function fuzzy<Item>(items: Item[], configuration?: FuzzyConfiguration<Item>): Fuzzy<Item>;
|
|
5954
5587
|
export declare namespace fuzzy {
|
|
5588
|
+
var is: typeof isFuzzy;
|
|
5955
5589
|
var match: typeof fuzzyMatch;
|
|
5956
5590
|
}
|
|
5957
5591
|
/**
|
|
@@ -5964,6 +5598,15 @@ export declare namespace fuzzy {
|
|
|
5964
5598
|
* @returns `true` if the needle matches the haystack in a fuzzy way, otherwise `false`
|
|
5965
5599
|
*/
|
|
5966
5600
|
export declare function fuzzyMatch(haystack: string, needle: string): boolean;
|
|
5601
|
+
/**
|
|
5602
|
+
* Is the value a fuzzy searcher?
|
|
5603
|
+
*
|
|
5604
|
+
* _Available as `isFuzzy` and `fuzzy.is`_
|
|
5605
|
+
*
|
|
5606
|
+
* @param value Value to check
|
|
5607
|
+
* @returns `true` if the value is a fuzzy searcher, otherwise `false`
|
|
5608
|
+
*/
|
|
5609
|
+
export declare function isFuzzy<Item = unknown>(value: unknown): value is Fuzzy<Item>;
|
|
5967
5610
|
//#endregion
|
|
5968
5611
|
//#region src/string/index.d.ts
|
|
5969
5612
|
/**
|
|
@@ -6084,7 +5727,7 @@ export type Normalizer = {
|
|
|
6084
5727
|
* @param value String to normalize
|
|
6085
5728
|
* @returns Normalized string
|
|
6086
5729
|
*/
|
|
6087
|
-
(value: string): string;
|
|
5730
|
+
normalize(value: string): string;
|
|
6088
5731
|
};
|
|
6089
5732
|
/**
|
|
6090
5733
|
* Deburr a string, removing diacritical marks
|
|
@@ -6144,7 +5787,7 @@ type Templater = {
|
|
|
6144
5787
|
*
|
|
6145
5788
|
* @returns Templated string
|
|
6146
5789
|
*/
|
|
6147
|
-
(strings: TemplateStringsArray, ...values: unknown[]): TemplaterRenderer;
|
|
5790
|
+
render(strings: TemplateStringsArray, ...values: unknown[]): TemplaterRenderer;
|
|
6148
5791
|
/**
|
|
6149
5792
|
* Render a string from a template with variables
|
|
6150
5793
|
*
|
|
@@ -6152,12 +5795,13 @@ type Templater = {
|
|
|
6152
5795
|
* @param variables Variables to use
|
|
6153
5796
|
* @returns Templated string
|
|
6154
5797
|
*/
|
|
6155
|
-
(value: string, variables?: PlainObject): string;
|
|
5798
|
+
render(value: string, variables?: PlainObject): string;
|
|
6156
5799
|
};
|
|
6157
5800
|
/**
|
|
6158
5801
|
* Render a template string with variables
|
|
6159
5802
|
*/
|
|
6160
5803
|
type TemplaterRenderer = (variables?: PlainObject) => string;
|
|
5804
|
+
declare function Templater(this: any, options: Required<TemplateOptions>): void;
|
|
6161
5805
|
/**
|
|
6162
5806
|
* Create a _Templater_ with predefined options
|
|
6163
5807
|
*
|
|
@@ -6207,7 +5851,7 @@ export type Cloner = {
|
|
|
6207
5851
|
* @param value Value to clone
|
|
6208
5852
|
* @returns Cloned value
|
|
6209
5853
|
*/
|
|
6210
|
-
<Value>(value: Value): Value;
|
|
5854
|
+
clone<Value>(value: Value): Value;
|
|
6211
5855
|
/**
|
|
6212
5856
|
* Deregister a clone handler for a specific class
|
|
6213
5857
|
*
|
|
@@ -6237,9 +5881,18 @@ export declare function clone<Value>(value: Value, options?: CloneOptions): Valu
|
|
|
6237
5881
|
export declare namespace clone {
|
|
6238
5882
|
var deregister: typeof deregisterCloner;
|
|
6239
5883
|
var handlers: {
|
|
6240
|
-
|
|
5884
|
+
base: {
|
|
5885
|
+
handlers: WeakMap<Constructor, string | GenericCallback>;
|
|
5886
|
+
options: {
|
|
5887
|
+
callback: GenericCallback;
|
|
5888
|
+
method?: string;
|
|
5889
|
+
};
|
|
5890
|
+
owner: GenericCallback;
|
|
5891
|
+
deregister: (constructor: Constructor) => void;
|
|
5892
|
+
get: (first: unknown, second: unknown) => string | GenericCallback | undefined;
|
|
5893
|
+
register: (constructor: Constructor, handler?: string | GenericCallback) => void;
|
|
5894
|
+
};
|
|
6241
5895
|
handle(value: unknown, ...parameters: unknown[]): unknown;
|
|
6242
|
-
register(constructor: Constructor, handler?: string | GenericCallback): void;
|
|
6243
5896
|
};
|
|
6244
5897
|
var initialize: typeof initializeCloner;
|
|
6245
5898
|
var register: typeof registerCloner;
|
|
@@ -6584,7 +6237,7 @@ export type Assigner = {
|
|
|
6584
6237
|
* @param from Values to assign
|
|
6585
6238
|
* @returns Assigned value
|
|
6586
6239
|
*/
|
|
6587
|
-
<To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From]): To & UnionToIntersection<From[number]>;
|
|
6240
|
+
assign<To extends PlainObject, From extends PlainObject[]>(to: To, from: [...From]): To & UnionToIntersection<From[number]>;
|
|
6588
6241
|
};
|
|
6589
6242
|
/**
|
|
6590
6243
|
* Options for merging values
|
|
@@ -6629,7 +6282,7 @@ export type Merger = {
|
|
|
6629
6282
|
* @param values Values to merge
|
|
6630
6283
|
* @returns Merged value
|
|
6631
6284
|
*/
|
|
6632
|
-
<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
|
|
6285
|
+
merge<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
|
|
6633
6286
|
};
|
|
6634
6287
|
/**
|
|
6635
6288
|
* Assign values from one or more objects to the first one
|
|
@@ -6683,10 +6336,16 @@ type TransformCallback<Value extends PlainObject, Key extends keyof Value> = (ke
|
|
|
6683
6336
|
*/
|
|
6684
6337
|
type TransformCallbacks<Value extends PlainObject> = Partial<{ [Key in keyof Value]: (value: Value[Key]) => Value[Key]; }>;
|
|
6685
6338
|
/**
|
|
6686
|
-
* A transformer
|
|
6339
|
+
* A transformer for an object, with predefined callbacks for transforming its properties
|
|
6687
6340
|
*/
|
|
6688
6341
|
export type Transformer<Value extends PlainObject> = {
|
|
6689
|
-
|
|
6342
|
+
/**
|
|
6343
|
+
* Transform an object's properties
|
|
6344
|
+
*
|
|
6345
|
+
* @param value Object to transform
|
|
6346
|
+
* @returns Transformed object
|
|
6347
|
+
*/
|
|
6348
|
+
transform(value: Value): Value;
|
|
6690
6349
|
};
|
|
6691
6350
|
/**
|
|
6692
6351
|
* Initialize a transformer for an object with a transformer function
|
|
@@ -6771,7 +6430,7 @@ type SubscriptionProperty = {
|
|
|
6771
6430
|
*/
|
|
6772
6431
|
value: unknown;
|
|
6773
6432
|
};
|
|
6774
|
-
type Subscriptions = {
|
|
6433
|
+
type Subscriptions<Value = unknown> = {
|
|
6775
6434
|
/**
|
|
6776
6435
|
* Items of the subscriptions store
|
|
6777
6436
|
*
|
|
@@ -6787,7 +6446,7 @@ type Subscriptions = {
|
|
|
6787
6446
|
* - `to.any` - Map of subscriptions to values _(for unkeyed subscriptions)_
|
|
6788
6447
|
* - `to.keyed` - Map of keys to maps of subscriptions to values _(for keyed subscriptions)_
|
|
6789
6448
|
*/
|
|
6790
|
-
readonly values: Readonly<SubscriptionsValues
|
|
6449
|
+
readonly values: Readonly<SubscriptionsValues<Value>>;
|
|
6791
6450
|
/**
|
|
6792
6451
|
* Clear all subscriptions
|
|
6793
6452
|
*/
|
|
@@ -6817,9 +6476,9 @@ type SubscriptionsItems = {
|
|
|
6817
6476
|
any: Set<Subscription>;
|
|
6818
6477
|
keyed?: Map<Key$1, Set<Subscription>>;
|
|
6819
6478
|
};
|
|
6820
|
-
type SubscriptionsValues = {
|
|
6821
|
-
from: SubscriptionsValuesItem<
|
|
6822
|
-
to: SubscriptionsValuesItem<Subscription,
|
|
6479
|
+
type SubscriptionsValues<Value = unknown> = {
|
|
6480
|
+
from: SubscriptionsValuesItem<Value, Subscription>;
|
|
6481
|
+
to: SubscriptionsValuesItem<Subscription, Value>;
|
|
6823
6482
|
};
|
|
6824
6483
|
type SubscriptionsValuesItem<MapKey, MapValue> = {
|
|
6825
6484
|
any: Map<MapKey, MapValue>;
|
|
@@ -6845,7 +6504,7 @@ export declare function isSubscriptions(value: unknown): value is Subscriptions;
|
|
|
6845
6504
|
* @param parameters Store parameters
|
|
6846
6505
|
* @returns Subscription store
|
|
6847
6506
|
*/
|
|
6848
|
-
export declare function subscriptions(parameters?: SubscriptionsParameters): Subscriptions
|
|
6507
|
+
export declare function subscriptions<Value = unknown>(parameters?: SubscriptionsParameters): Subscriptions<Value>;
|
|
6849
6508
|
//#endregion
|
|
6850
6509
|
//#region src/beacon.d.ts
|
|
6851
6510
|
/**
|
|
@@ -7962,12 +7621,12 @@ type Logger = {
|
|
|
7962
7621
|
* @param label Label for the logger
|
|
7963
7622
|
* @returns _TimedLogger_ instance
|
|
7964
7623
|
*/
|
|
7965
|
-
time(label: string):
|
|
7624
|
+
time(label: string): TimeLogger;
|
|
7966
7625
|
};
|
|
7967
7626
|
/**
|
|
7968
7627
|
* A named timer that can be used to log durations to the console
|
|
7969
7628
|
*/
|
|
7970
|
-
type
|
|
7629
|
+
type TimeLogger = {
|
|
7971
7630
|
/**
|
|
7972
7631
|
* Is the timer active? _(i.e. has it been started and not stopped, and is logging enabled?)_
|
|
7973
7632
|
*/
|
|
@@ -7983,8 +7642,9 @@ type TimedLogger = {
|
|
|
7983
7642
|
*/
|
|
7984
7643
|
get stop(): () => void;
|
|
7985
7644
|
};
|
|
7645
|
+
declare function TimeLogger(this: any, label: string): void;
|
|
7986
7646
|
declare function isLogger(value: unknown): value is Logger;
|
|
7987
|
-
declare function
|
|
7647
|
+
declare function isTimeLogger(value: unknown): value is TimeLogger;
|
|
7988
7648
|
/**
|
|
7989
7649
|
* A logger that can be used to log messages to the console
|
|
7990
7650
|
*
|
|
@@ -8666,4 +8326,4 @@ export declare class SizedSet<Value = unknown> extends Set<Value> {
|
|
|
8666
8326
|
get(value: Value, update?: boolean): Value | undefined;
|
|
8667
8327
|
}
|
|
8668
8328
|
//#endregion
|
|
8669
|
-
export { type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, Logger, type RGBAColor, type RGBColor, type Shaken, type Smushed, type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, type
|
|
8329
|
+
export { type AsyncLimiter, type Color, type ColorType, type ColorTypeExtended, type ColorValue, type ColorValueExtended, type HSLAColor, type HSLColor, type HWBAColor, type HWBColor, Key$1 as Key, type Limiter, Logger, Once, OnceAsync, type RGBAColor, type RGBColor, type Shaken, type Smushed, type Subscription, type SubscriptionParameters, type SubscriptionProperty, type Subscriptions, type SubscriptionsParameters, type TimeLogger, type Unsmushed, toPromise as fromResult, getRandomFloatingNumber as getRandomFloat, isLogger, isTimeLogger };
|