@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/math.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { round } from "./internal/math/misc.mjs";
|
|
|
9
9
|
* @param callback Callback to get an item's value
|
|
10
10
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
11
11
|
*/
|
|
12
|
-
declare function average<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
12
|
+
export declare function average<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
13
13
|
/**
|
|
14
14
|
* Get the average value from a list of items
|
|
15
15
|
*
|
|
@@ -17,14 +17,14 @@ declare function average<Item>(items: Item[], callback: (item: Item, index: numb
|
|
|
17
17
|
* @param key Key to use for value
|
|
18
18
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
19
19
|
*/
|
|
20
|
-
declare function average<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
20
|
+
export declare function average<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
21
21
|
/**
|
|
22
22
|
* Get the average value from a list of numbers
|
|
23
23
|
*
|
|
24
24
|
* @param numbers List of numbers
|
|
25
25
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
26
26
|
*/
|
|
27
|
-
declare function average(numbers: number[]): number;
|
|
27
|
+
export declare function average(numbers: number[]): number;
|
|
28
28
|
/**
|
|
29
29
|
* Round a number up
|
|
30
30
|
*
|
|
@@ -32,7 +32,7 @@ declare function average(numbers: number[]): number;
|
|
|
32
32
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
33
33
|
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
34
34
|
*/
|
|
35
|
-
declare function ceil(value: number, decimals?: number): number;
|
|
35
|
+
export declare function ceil(value: number, decimals?: number): number;
|
|
36
36
|
/**
|
|
37
37
|
* Count the number of items in an array that match a specific value
|
|
38
38
|
*
|
|
@@ -41,7 +41,7 @@ declare function ceil(value: number, decimals?: number): number;
|
|
|
41
41
|
* @param value Value to match and count
|
|
42
42
|
* @returns Number of items that match the condition, or `Number.NaN` if no count can be calculated
|
|
43
43
|
*/
|
|
44
|
-
declare function count<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown, value: unknown): number;
|
|
44
|
+
export declare function count<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown, value: unknown): number;
|
|
45
45
|
/**
|
|
46
46
|
* Count the number of items in an array that have a specific value
|
|
47
47
|
*
|
|
@@ -50,14 +50,14 @@ declare function count<Item>(array: Item[], callback: (item: Item, index: number
|
|
|
50
50
|
* @param value Value to match and count
|
|
51
51
|
* @returns Number of items with the specified key value, or `Number.NaN` if no count can be calculated
|
|
52
52
|
*/
|
|
53
|
-
declare function count<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
|
|
53
|
+
export declare function count<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
|
|
54
54
|
/**
|
|
55
55
|
* Count the number of items in an array
|
|
56
56
|
*
|
|
57
57
|
* @param values Array to count for
|
|
58
58
|
* @returns Number of items, or `Number.NaN` if no count can be calculated
|
|
59
59
|
*/
|
|
60
|
-
declare function count(values: unknown[]): number;
|
|
60
|
+
export declare function count(values: unknown[]): number;
|
|
61
61
|
/**
|
|
62
62
|
* Round a number down
|
|
63
63
|
*
|
|
@@ -65,7 +65,7 @@ declare function count(values: unknown[]): number;
|
|
|
65
65
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
66
66
|
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
67
67
|
*/
|
|
68
|
-
declare function floor(value: number, decimals?: number): number;
|
|
68
|
+
export declare function floor(value: number, decimals?: number): number;
|
|
69
69
|
/**
|
|
70
70
|
* Get the median value from a list of items
|
|
71
71
|
*
|
|
@@ -73,7 +73,7 @@ declare function floor(value: number, decimals?: number): number;
|
|
|
73
73
|
* @param callback Callback to get an item's value
|
|
74
74
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
75
75
|
*/
|
|
76
|
-
declare function median<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
76
|
+
export declare function median<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
77
77
|
/**
|
|
78
78
|
* Get the median value from a list of items
|
|
79
79
|
*
|
|
@@ -81,14 +81,14 @@ declare function median<Item>(array: Item[], callback: (item: Item, index: numbe
|
|
|
81
81
|
* @param key Key to use for value
|
|
82
82
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
83
83
|
*/
|
|
84
|
-
declare function median<Item extends PlainObject>(array: Item[], key: keyof NumericalValues<Item>): number;
|
|
84
|
+
export declare function median<Item extends PlainObject>(array: Item[], key: keyof NumericalValues<Item>): number;
|
|
85
85
|
/**
|
|
86
86
|
* Get the median value from a list of numbers
|
|
87
87
|
*
|
|
88
88
|
* @param array List of numbers
|
|
89
89
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
90
90
|
*/
|
|
91
|
-
declare function median(array: number[]): number;
|
|
91
|
+
export declare function median(array: number[]): number;
|
|
92
92
|
/**
|
|
93
93
|
* Get the minimum value from a list of items
|
|
94
94
|
*
|
|
@@ -97,7 +97,7 @@ declare function median(array: number[]): number;
|
|
|
97
97
|
* @param first Return only the first item with the minimum value
|
|
98
98
|
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
99
99
|
*/
|
|
100
|
-
declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
100
|
+
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
101
101
|
/**
|
|
102
102
|
* Get the minimum value from a list of items
|
|
103
103
|
*
|
|
@@ -106,7 +106,7 @@ declare function min<Item>(items: Item[], callback: (item: Item, index: number,
|
|
|
106
106
|
* @param first Return only the first item with the minimum value
|
|
107
107
|
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
108
108
|
*/
|
|
109
|
-
declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
109
|
+
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
110
110
|
/**
|
|
111
111
|
* Get the minimum value from a list of items
|
|
112
112
|
*
|
|
@@ -114,7 +114,7 @@ declare function min<Item extends PlainObject>(items: Item[], key: keyof Numeric
|
|
|
114
114
|
* @param callback Callback to get an item's value
|
|
115
115
|
* @returns Items with the minimum value
|
|
116
116
|
*/
|
|
117
|
-
declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
117
|
+
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
118
118
|
/**
|
|
119
119
|
* Get the minimum value from a list of items
|
|
120
120
|
*
|
|
@@ -122,14 +122,14 @@ declare function min<Item>(items: Item[], callback: (item: Item, index: number,
|
|
|
122
122
|
* @param key Key to use for value
|
|
123
123
|
* @returns Items with the minimum value
|
|
124
124
|
*/
|
|
125
|
-
declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
125
|
+
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
126
126
|
/**
|
|
127
127
|
* Get the minimum value from a list of numbers
|
|
128
128
|
*
|
|
129
129
|
* @param values List of numbers
|
|
130
130
|
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
131
131
|
*/
|
|
132
|
-
declare function min(values: number[]): number;
|
|
132
|
+
export declare function min(values: number[]): number;
|
|
133
133
|
/**
|
|
134
134
|
* Get the sum of a list of items
|
|
135
135
|
*
|
|
@@ -137,7 +137,7 @@ declare function min(values: number[]): number;
|
|
|
137
137
|
* @param callback Callback to get an item's value
|
|
138
138
|
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
139
139
|
*/
|
|
140
|
-
declare function sum<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
140
|
+
export declare function sum<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
141
141
|
/**
|
|
142
142
|
* Get the sum of a list of items
|
|
143
143
|
*
|
|
@@ -145,13 +145,13 @@ declare function sum<Item>(items: Item[], callback: (item: Item, index: number,
|
|
|
145
145
|
* @param key Key to use for value
|
|
146
146
|
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
147
147
|
*/
|
|
148
|
-
declare function sum<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
148
|
+
export declare function sum<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
149
149
|
/**
|
|
150
150
|
* Get the sum of a list of numbers
|
|
151
151
|
*
|
|
152
152
|
* @param values List of numbers
|
|
153
153
|
* @returns Sum of the numbers, or `Number.NaN` if no sum can be calculated
|
|
154
154
|
*/
|
|
155
|
-
declare function sum(values: number[]): number;
|
|
155
|
+
export declare function sum(values: number[]): number;
|
|
156
156
|
//#endregion
|
|
157
|
-
export {
|
|
157
|
+
export { max, round };
|
package/dist/models.d.mts
CHANGED
|
@@ -2,82 +2,80 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* A generic array or object
|
|
4
4
|
*/
|
|
5
|
-
type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
|
|
6
|
-
/**
|
|
7
|
-
* An asynchronous callback that can be canceled
|
|
8
|
-
*/
|
|
9
|
-
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
|
-
};
|
|
5
|
+
export type ArrayOrPlainObject = unknown[] | Record<PropertyKey, unknown>;
|
|
15
6
|
/**
|
|
16
7
|
* For matching any `void`, `Date`, primitive, or `RegExp` values
|
|
17
8
|
*
|
|
18
9
|
* _(Thanks, type-fest!)_
|
|
19
10
|
*/
|
|
20
|
-
type BuiltIns = void | Date | Primitive | RegExp;
|
|
21
|
-
/**
|
|
22
|
-
* A synchronous callback that can be canceled
|
|
23
|
-
*/
|
|
24
|
-
type CancelableCallback<Callback extends GenericCallback> = Callback & {
|
|
25
|
-
/**
|
|
26
|
-
* Cancel the callback
|
|
27
|
-
*/
|
|
28
|
-
cancel: () => void;
|
|
29
|
-
};
|
|
11
|
+
export type BuiltIns = void | Date | Primitive | RegExp;
|
|
30
12
|
/**
|
|
31
13
|
* A generic class constructor
|
|
32
14
|
*/
|
|
33
|
-
type Constructor<Instance = unknown> = new (...args: any[]) => Instance;
|
|
15
|
+
export type Constructor<Instance = unknown> = new (...args: any[]) => Instance;
|
|
34
16
|
/**
|
|
35
17
|
* A generic async callback function
|
|
36
18
|
*/
|
|
37
|
-
type GenericAsyncCallback = (...args: any[]) => Promise<any>;
|
|
19
|
+
export type GenericAsyncCallback = (...args: any[]) => Promise<any>;
|
|
38
20
|
/**
|
|
39
21
|
* A generic callback function
|
|
40
22
|
*/
|
|
41
|
-
type GenericCallback = (...args: any[]) => any;
|
|
23
|
+
export type GenericCallback = (...args: any[]) => any;
|
|
42
24
|
/**
|
|
43
25
|
* A generic key type
|
|
44
26
|
*/
|
|
45
|
-
type Key = number | string;
|
|
46
|
-
|
|
27
|
+
export type Key = number | string;
|
|
28
|
+
/**
|
|
29
|
+
* The `PropertyKey`-safe value of `Item`'s `ItemKey` property
|
|
30
|
+
*/
|
|
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>> = Arg extends ((item: Item, index: number, array: Item[]) => Key) ? 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
|
*/
|
|
50
|
-
type NestedArray<Value> = Value extends Array<infer NestedValue> ? NestedArray<NestedValue> : Value;
|
|
48
|
+
export type NestedArray<Value> = Value extends Array<infer NestedValue> ? NestedArray<NestedValue> : Value;
|
|
51
49
|
/**
|
|
52
50
|
* All nested keys of an object as dot notation strings _(up to 5 levels deep)_
|
|
53
51
|
*/
|
|
54
|
-
type NestedKeys<Value extends PlainObject> = _NestedKeys<Value>;
|
|
52
|
+
export type NestedKeys<Value extends PlainObject> = _NestedKeys<Value>;
|
|
55
53
|
type _NestedKeys<Value, Depth extends number = 5> = Depth extends 0 ? never : Value extends readonly any[] ? Value extends readonly [any, ...any] ? { [ItemKey in keyof Value]-?: ItemKey extends `${number}` ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never; }[number] : never : Value extends PlainObject ? { [ItemKey in keyof Value]-?: ItemKey extends number | string ? NonNullable<Value[ItemKey]> extends readonly any[] | PlainObject ? `${ItemKey}` | `${ItemKey}.${_NestedKeys<NonNullable<Value[ItemKey]>, SubtractDepth<Depth>>}` : `${ItemKey}` : never; }[keyof Value] : never;
|
|
56
54
|
/**
|
|
57
55
|
* An extended version of `Partial` that allows for nested properties to be optional
|
|
58
56
|
*/
|
|
59
|
-
type NestedPartial<Value> = { [ItemKey in keyof Value]?: Value[ItemKey] extends object ? NestedPartial<Value[ItemKey]> : Value[ItemKey]; };
|
|
57
|
+
export type NestedPartial<Value> = { [ItemKey in keyof Value]?: Value[ItemKey] extends object ? NestedPartial<Value[ItemKey]> : Value[ItemKey]; };
|
|
60
58
|
/**
|
|
61
59
|
* The value for a nested key of an object
|
|
62
60
|
*/
|
|
63
|
-
type NestedValue<Value extends PlainObject, Path extends string> = _NestedValue<Value, Path>;
|
|
61
|
+
export type NestedValue<Value extends PlainObject, Path extends string> = _NestedValue<Value, Path>;
|
|
64
62
|
type _NestedValue<Value, Path extends string> = Path extends `${infer ItemKey}.${infer Rest}` ? ItemKey extends keyof Value ? undefined extends Value[ItemKey] ? _NestedValue<Exclude<Value[ItemKey], undefined>, Rest> | undefined : _NestedValue<Value[ItemKey], Rest> : ItemKey extends `${number}` ? Value extends readonly any[] ? _NestedValue<Value[number], Rest> : never : never : Path extends `${number}` ? Value extends readonly any[] ? Value[number] : never : Path extends keyof Value ? Value[Path] : never;
|
|
65
63
|
/**
|
|
66
64
|
* The nested _(keyed)_ values of an object _(up to 5 levels deep)_
|
|
67
65
|
*/
|
|
68
|
-
type NestedValues<Value extends PlainObject> = { [Path in NestedKeys<Value>]: NestedValue<Value, Path>; };
|
|
66
|
+
export type NestedValues<Value extends PlainObject> = { [Path in NestedKeys<Value>]: NestedValue<Value, Path>; };
|
|
69
67
|
/**
|
|
70
68
|
* The numerical keys of an object
|
|
71
69
|
*/
|
|
72
|
-
type NumericalKeys<Value> = { [ItemKey in keyof Value]: ItemKey extends number ? ItemKey : ItemKey extends `${number}` ? ItemKey : never; }[keyof Value];
|
|
70
|
+
export type NumericalKeys<Value> = { [ItemKey in keyof Value]: ItemKey extends number ? ItemKey : ItemKey extends `${number}` ? ItemKey : never; }[keyof Value];
|
|
73
71
|
/**
|
|
74
72
|
* The numerical values of an object
|
|
75
73
|
*/
|
|
76
|
-
type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey]; };
|
|
74
|
+
export type NumericalValues<Item extends PlainObject> = { [ItemKey in keyof Item as Item[ItemKey] extends number ? ItemKey : never]: Item[ItemKey]; };
|
|
77
75
|
/**
|
|
78
76
|
* An asynchronous function that can only be called once, returning the same value on subsequent calls
|
|
79
77
|
*/
|
|
80
|
-
type
|
|
78
|
+
export type OnceAsync<Callback extends GenericAsyncCallback> = {
|
|
81
79
|
/**
|
|
82
80
|
* Did the callback's promise reject?
|
|
83
81
|
*/
|
|
@@ -86,12 +84,27 @@ 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
|
-
type
|
|
94
|
-
|
|
98
|
+
export 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
|
*/
|
|
@@ -108,34 +121,34 @@ type OnceCallbackProperties = {
|
|
|
108
121
|
/**
|
|
109
122
|
* A generic object
|
|
110
123
|
*/
|
|
111
|
-
type PlainObject = Record<PropertyKey, unknown>;
|
|
124
|
+
export type PlainObject = Record<PropertyKey, unknown>;
|
|
112
125
|
/**
|
|
113
126
|
* A primitive value
|
|
114
127
|
*
|
|
115
128
|
* _(Thanks, type-fest!)_
|
|
116
129
|
*/
|
|
117
|
-
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
130
|
+
export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
118
131
|
/**
|
|
119
132
|
* Set required keys for a type
|
|
120
133
|
*/
|
|
121
|
-
type RequiredKeys<Model extends object, Keys extends keyof Model> = Required<Pick<Model, Keys>> & Omit<Model, Keys>;
|
|
134
|
+
export type RequiredKeys<Model extends object, Keys extends keyof Model> = Required<Pick<Model, Keys>> & Omit<Model, Keys>;
|
|
122
135
|
/**
|
|
123
136
|
* Flattens the type to improve type hints in IDEs
|
|
124
137
|
*
|
|
125
138
|
* _(Thanks, type-fest!)_
|
|
126
139
|
*/
|
|
127
|
-
type Simplify<Value> = { [ValueKey in keyof Value]: Value[ValueKey]; } & {};
|
|
140
|
+
export type Simplify<Value> = { [ValueKey in keyof Value]: Value[ValueKey]; } & {};
|
|
128
141
|
type SubtractDepth<Value extends number> = Value extends 5 ? 4 : Value extends 4 ? 3 : Value extends 3 ? 2 : Value extends 2 ? 1 : Value extends 1 ? 0 : never;
|
|
129
142
|
/**
|
|
130
143
|
* Get the value's type as a string
|
|
131
144
|
*
|
|
132
145
|
* _(Thanks, type-fest!)_
|
|
133
146
|
*/
|
|
134
|
-
type ToString<Value> = Value extends string | number ? `${Value}` : never;
|
|
147
|
+
export type ToString<Value> = Value extends string | number ? `${Value}` : never;
|
|
135
148
|
/**
|
|
136
149
|
* A union type of all typed arrays
|
|
137
150
|
*/
|
|
138
|
-
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
151
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
139
152
|
/**
|
|
140
153
|
* Converts a union type to an intersection type
|
|
141
154
|
*
|
|
@@ -148,10 +161,9 @@ type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint
|
|
|
148
161
|
*
|
|
149
162
|
* Thanks, type-fest!
|
|
150
163
|
*/
|
|
151
|
-
type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
|
|
164
|
+
export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
|
|
152
165
|
/**
|
|
153
166
|
* A function that unsubscribes from a subscription
|
|
154
167
|
*/
|
|
155
|
-
type Unsubscriber = () => void;
|
|
156
|
-
//#endregion
|
|
157
|
-
export { ArrayOrPlainObject, AsyncCancelableCallback, BuiltIns, CancelableCallback, Constructor, GenericAsyncCallback, GenericCallback, Key, KeyedValue, NestedArray, NestedKeys, NestedPartial, NestedValue, NestedValues, NumericalKeys, NumericalValues, OnceAsyncCallback, OnceCallback, PlainObject, Primitive, RequiredKeys, Simplify, ToString, TypedArray, UnionToIntersection, Unsubscriber };
|
|
168
|
+
export type Unsubscriber = () => void;
|
|
169
|
+
//#endregion
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { PromiseStrategy } from "./models.mjs";
|
|
2
2
|
//#region src/promise/constants.d.ts
|
|
3
|
-
declare const PROMISE_ABORT_EVENT = "abort";
|
|
4
|
-
declare const PROMISE_ABORT_OPTIONS: {
|
|
3
|
+
export declare const PROMISE_ABORT_EVENT = "abort";
|
|
4
|
+
export declare const PROMISE_ABORT_OPTIONS: {
|
|
5
5
|
once: boolean;
|
|
6
6
|
};
|
|
7
|
-
declare const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
8
|
-
declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
9
|
-
declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY = "promises expected at least one promise-function or promise in the array or object";
|
|
10
|
-
declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
11
|
-
declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
12
|
-
declare const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
13
|
-
declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
14
|
-
declare const PROMISE_STRATEGY_ALL: Set<PromiseStrategy>;
|
|
15
|
-
declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
|
|
16
|
-
declare const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
17
|
-
declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
18
|
-
//#endregion
|
|
19
|
-
export { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED };
|
|
7
|
+
export declare const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
8
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
9
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY = "promises expected at least one promise-function or promise in the array or object";
|
|
10
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
11
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
12
|
+
export declare const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
13
|
+
export declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
14
|
+
export declare const PROMISE_STRATEGY_ALL: Set<PromiseStrategy>;
|
|
15
|
+
export declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
|
|
16
|
+
export declare const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
17
|
+
export declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
18
|
+
//#endregion
|
package/dist/promise/delay.d.mts
CHANGED
|
@@ -6,13 +6,12 @@ import { PromiseOptions } from "./models.mjs";
|
|
|
6
6
|
* @param options Options for the delay
|
|
7
7
|
* @returns Delayed promise
|
|
8
8
|
*/
|
|
9
|
-
declare function delay(options?: PromiseOptions): Promise<void>;
|
|
9
|
+
export declare function delay(options?: PromiseOptions): Promise<void>;
|
|
10
10
|
/**
|
|
11
11
|
* Create a delayed promise that resolves after a certain amount of time
|
|
12
12
|
*
|
|
13
13
|
* @param time How long to wait for _(in milliseconds; defaults to `0`)_
|
|
14
14
|
* @returns Delayed promise
|
|
15
15
|
*/
|
|
16
|
-
declare function delay(time?: number): Promise<void>;
|
|
17
|
-
//#endregion
|
|
18
|
-
export { delay };
|
|
16
|
+
export declare function delay(time?: number): Promise<void>;
|
|
17
|
+
//#endregion
|
package/dist/promise/delay.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAborter } from "../internal/abort.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { LIMITER_WAIT, getLimiter } from "../internal/function/limit.mjs";
|
|
3
3
|
import { createPromiseOptions } from "./helpers.mjs";
|
|
4
4
|
import { settlePromise } from "./misc.mjs";
|
|
5
5
|
//#region src/promise/delay.ts
|
|
@@ -7,17 +7,17 @@ function delay(options) {
|
|
|
7
7
|
const { signal, time } = createPromiseOptions(options);
|
|
8
8
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
9
9
|
const aborter = createAborter(signal, () => {
|
|
10
|
-
|
|
10
|
+
limiter.cancel();
|
|
11
11
|
rejector(signal?.reason);
|
|
12
12
|
});
|
|
13
|
-
const
|
|
13
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(resolver, void 0, aborter), time);
|
|
14
14
|
let rejector;
|
|
15
15
|
let resolver;
|
|
16
16
|
return new Promise((resolve, reject) => {
|
|
17
17
|
rejector = reject;
|
|
18
18
|
resolver = resolve;
|
|
19
19
|
if (time === 0) settlePromise(resolver, void 0, aborter);
|
|
20
|
-
else
|
|
20
|
+
else limiter.run();
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
//#endregion
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { RequiredKeys } from "../models.mjs";
|
|
2
2
|
import { FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, PromisesValue, RejectedPromise } from "./models.mjs";
|
|
3
3
|
//#region src/promise/helpers.d.ts
|
|
4
|
-
declare function createPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, 'time'>;
|
|
5
|
-
declare function createPromisesOptions(input: unknown): RequiredKeys<PromisesOptions, 'strategy'>;
|
|
6
|
-
declare function getResultsFromPromises(promised: Array<PromisesValue<unknown>> | Record<string, PromisesValue<unknown>>): unknown;
|
|
7
|
-
declare function getStrategyOrDefault(value: unknown): PromiseStrategy;
|
|
4
|
+
export declare function createPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, 'time'>;
|
|
5
|
+
export declare function createPromisesOptions(input: unknown): RequiredKeys<PromisesOptions, 'strategy'>;
|
|
6
|
+
export declare function getResultsFromPromises(promised: Array<PromisesValue<unknown>> | Record<string, PromisesValue<unknown>>): unknown;
|
|
7
|
+
export declare function getStrategyOrDefault(value: unknown): PromiseStrategy;
|
|
8
8
|
/**
|
|
9
9
|
* Is the value a fulfilled _Promise_ result?
|
|
10
10
|
*
|
|
11
11
|
* @param value Value to check
|
|
12
12
|
* @returns `true` if the value is a fulfilled _Promise_ result, otherwise `false`
|
|
13
13
|
*/
|
|
14
|
-
declare function isFulfilled<Value>(value: unknown): value is FulfilledPromise<Value>;
|
|
14
|
+
export declare function isFulfilled<Value>(value: unknown): value is FulfilledPromise<Value>;
|
|
15
15
|
/**
|
|
16
16
|
* Is the value a rejected _Promise_ result?
|
|
17
17
|
*
|
|
18
18
|
* @param value Value to check
|
|
19
19
|
* @returns `true` if the value is a rejected _Promise_ result, otherwise `false`
|
|
20
20
|
*/
|
|
21
|
-
declare function isRejected(value: unknown): value is RejectedPromise;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { createPromiseOptions, createPromisesOptions, getResultsFromPromises, getStrategyOrDefault, isFulfilled, isRejected };
|
|
21
|
+
export declare function isRejected(value: unknown): value is RejectedPromise;
|
|
22
|
+
//#endregion
|
package/dist/promise/index.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { PromiseOptions, PromiseStrategy, PromisesItems, PromisesOptions, Promis
|
|
|
8
8
|
* @param options Options for the _Promise_
|
|
9
9
|
* @returns Wrapped _Promise_
|
|
10
10
|
*/
|
|
11
|
-
declare function attemptPromise<Value>(promise: Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
11
|
+
export declare function attemptPromise<Value>(promise: Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
12
12
|
/**
|
|
13
13
|
* Wrap a _Promise_-returning callback with safety handlers
|
|
14
14
|
*
|
|
@@ -16,7 +16,7 @@ declare function attemptPromise<Value>(promise: Promise<Value>, options?: Promis
|
|
|
16
16
|
* @param options Options for the _Promise_
|
|
17
17
|
* @returns _Promise_-wrapped callback
|
|
18
18
|
*/
|
|
19
|
-
declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
19
|
+
export declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
20
20
|
/**
|
|
21
21
|
* Wrap a callback with a _Promise_ and safety handlers
|
|
22
22
|
*
|
|
@@ -24,7 +24,7 @@ declare function attemptPromise<Value>(callback: () => Promise<Value>, options?:
|
|
|
24
24
|
* @param options Options for the _Promise_
|
|
25
25
|
* @returns _Promise_-wrapped callback
|
|
26
26
|
*/
|
|
27
|
-
declare function attemptPromise<Value>(callback: () => Value, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
27
|
+
export declare function attemptPromise<Value>(callback: () => Value, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
28
28
|
/**
|
|
29
29
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
30
30
|
*
|
|
@@ -34,7 +34,7 @@ declare function attemptPromise<Value>(callback: () => Value, options?: PromiseO
|
|
|
34
34
|
* @param options Options for handling the _Promises_
|
|
35
35
|
* @returns List of results
|
|
36
36
|
*/
|
|
37
|
-
declare function promises<Items extends unknown[], Options extends PromisesOptions>(items: [...Items], options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
37
|
+
export declare function promises<Items extends unknown[], Options extends PromisesOptions>(items: [...Items], options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
38
38
|
/**
|
|
39
39
|
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
40
40
|
*
|
|
@@ -44,7 +44,7 @@ declare function promises<Items extends unknown[], Options extends PromisesOptio
|
|
|
44
44
|
* @param options Options for handling the _Promises_
|
|
45
45
|
* @returns Keyed object of results
|
|
46
46
|
*/
|
|
47
|
-
declare function promises<Items extends PlainObject, Options extends PromisesOptions>(items: Items, options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
47
|
+
export declare function promises<Items extends PlainObject, Options extends PromisesOptions>(items: Items, options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
48
48
|
/**
|
|
49
49
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
50
50
|
*
|
|
@@ -54,7 +54,7 @@ declare function promises<Items extends PlainObject, Options extends PromisesOpt
|
|
|
54
54
|
* @param strategy Strategy for handling the _Promises_
|
|
55
55
|
* @returns List of results
|
|
56
56
|
*/
|
|
57
|
-
declare function promises<Items extends unknown[], Strategy extends PromiseStrategy>(items: [...Items], strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
57
|
+
export declare function promises<Items extends unknown[], Strategy extends PromiseStrategy>(items: [...Items], strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
58
58
|
/**
|
|
59
59
|
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
60
60
|
*
|
|
@@ -64,7 +64,7 @@ declare function promises<Items extends unknown[], Strategy extends PromiseStrat
|
|
|
64
64
|
* @param strategy Strategy for handling the _Promises_
|
|
65
65
|
* @returns Keyed object of results
|
|
66
66
|
*/
|
|
67
|
-
declare function promises<Items extends PlainObject, Strategy extends PromiseStrategy>(items: Items, strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
67
|
+
export declare function promises<Items extends PlainObject, Strategy extends PromiseStrategy>(items: Items, strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
68
68
|
/**
|
|
69
69
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
70
70
|
*
|
|
@@ -72,7 +72,7 @@ declare function promises<Items extends PlainObject, Strategy extends PromiseStr
|
|
|
72
72
|
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
73
73
|
* @returns List of results
|
|
74
74
|
*/
|
|
75
|
-
declare function promises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
75
|
+
export declare function promises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
76
76
|
/**
|
|
77
77
|
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
78
78
|
*
|
|
@@ -80,8 +80,8 @@ declare function promises<Items extends unknown[]>(items: [...Items], signal?: A
|
|
|
80
80
|
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
81
81
|
* @returns Keyed object of results
|
|
82
82
|
*/
|
|
83
|
-
declare function promises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
84
|
-
declare namespace promises {
|
|
83
|
+
export declare function promises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
84
|
+
export declare namespace promises {
|
|
85
85
|
var result: typeof resultPromises;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -95,7 +95,7 @@ declare namespace promises {
|
|
|
95
95
|
* @param signal AbortSignal for aborting all _Promises_
|
|
96
96
|
* @returns List of results
|
|
97
97
|
*/
|
|
98
|
-
declare function resultPromises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
98
|
+
export declare function resultPromises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
99
99
|
/**
|
|
100
100
|
* Handle keyed _Promises_, returning their results in a similarly keyed object of results _({@link Result})_
|
|
101
101
|
*
|
|
@@ -105,6 +105,5 @@ declare function resultPromises<Items extends unknown[]>(items: [...Items], sign
|
|
|
105
105
|
* @param signal AbortSignal for aborting all _Promises_
|
|
106
106
|
* @returns Keyed object of results
|
|
107
107
|
*/
|
|
108
|
-
declare function resultPromises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
109
|
-
//#endregion
|
|
110
|
-
export { attemptPromise, promises, resultPromises };
|
|
108
|
+
export declare function resultPromises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
109
|
+
//#endregion
|
package/dist/promise/misc.d.mts
CHANGED
|
@@ -10,22 +10,22 @@ import { isFulfilled, isRejected } from "./helpers.mjs";
|
|
|
10
10
|
* @param executor Executor function for the _Promise_
|
|
11
11
|
* @returns Cancelable _Promise_
|
|
12
12
|
*/
|
|
13
|
-
declare function cancelable<Value>(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void): CancelablePromise<Value>;
|
|
14
|
-
declare function handleResult(status: string, parameters: PromiseParameters): void;
|
|
15
|
-
declare function settlePromise(settler: (value: any) => void, value: unknown, aborter?: Aborter): void;
|
|
13
|
+
export declare function cancelable<Value>(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void): CancelablePromise<Value>;
|
|
14
|
+
export declare function handleResult(status: string, parameters: PromiseParameters): void;
|
|
15
|
+
export declare function settlePromise(settler: (value: any) => void, value: unknown, aborter?: Aborter): void;
|
|
16
16
|
/**
|
|
17
17
|
* Converts a _Promise_ to a promised result
|
|
18
18
|
*
|
|
19
19
|
* @param callback _Promise_ callback
|
|
20
20
|
* @returns Promised result
|
|
21
21
|
*/
|
|
22
|
-
declare function toResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
|
|
22
|
+
export declare function toResult<Value>(callback: () => Promise<Value>): Promise<Result<Value>>;
|
|
23
23
|
/**
|
|
24
24
|
* Converts a _Promise_ to a promised result
|
|
25
25
|
*
|
|
26
26
|
* @param promise _Promise_ to convert
|
|
27
27
|
* @returns Promised result
|
|
28
28
|
*/
|
|
29
|
-
declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
|
|
29
|
+
export declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
|
|
30
30
|
//#endregion
|
|
31
|
-
export {
|
|
31
|
+
export { toPromise as fromResult, isFulfilled, isRejected };
|