@oscarpalmer/atoms 0.221.0 → 0.223.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 +1 -3
- package/dist/array/difference.mjs +2 -3
- package/dist/array/exists.d.mts +1 -3
- package/dist/array/exists.mjs +11 -6
- package/dist/array/filter.d.mts +1 -3
- package/dist/array/filter.mjs +15 -6
- package/dist/array/find.d.mts +1 -3
- package/dist/array/find.mjs +9 -5
- package/dist/array/first.d.mts +1 -3
- package/dist/array/first.mjs +10 -5
- package/dist/array/flatten.d.mts +1 -3
- package/dist/array/flatten.mjs +1 -2
- package/dist/array/from.d.mts +1 -3
- package/dist/array/from.mjs +1 -2
- package/dist/array/group-by.d.mts +1 -3
- package/dist/array/group-by.mjs +1 -2
- package/dist/array/index.d.mts +4 -4
- package/dist/array/insert.d.mts +1 -3
- package/dist/array/insert.mjs +2 -3
- package/dist/array/intersection.d.mts +1 -3
- package/dist/array/intersection.mjs +2 -3
- package/dist/array/last.d.mts +1 -3
- package/dist/array/last.mjs +12 -5
- package/dist/array/move.d.mts +1 -3
- package/dist/array/move.mjs +1 -2
- package/dist/array/partition.d.mts +1 -3
- package/dist/array/partition.mjs +24 -5
- package/dist/array/push.d.mts +0 -2
- package/dist/array/push.mjs +2 -3
- package/dist/array/reverse.d.mts +1 -3
- package/dist/array/reverse.mjs +1 -2
- package/dist/array/select.d.mts +0 -2
- package/dist/array/select.mjs +40 -9
- package/dist/array/single.d.mts +1 -3
- package/dist/array/single.mjs +9 -7
- package/dist/array/slice.d.mts +1 -3
- package/dist/array/slice.mjs +1 -2
- package/dist/array/sort.d.mts +0 -2
- package/dist/array/sort.mjs +2 -3
- package/dist/array/splice.d.mts +1 -3
- package/dist/array/splice.mjs +2 -3
- package/dist/array/swap.d.mts +0 -2
- package/dist/array/swap.mjs +2 -3
- package/dist/array/to-map.d.mts +1 -3
- package/dist/array/to-map.mjs +1 -2
- package/dist/array/to-record.d.mts +1 -3
- package/dist/array/to-record.mjs +1 -2
- package/dist/array/to-set.d.mts +1 -3
- package/dist/array/to-set.mjs +1 -2
- package/dist/array/toggle.d.mts +1 -3
- package/dist/array/toggle.mjs +1 -2
- package/dist/array/union.d.mts +1 -3
- package/dist/array/union.mjs +2 -3
- package/dist/array/unique.d.mts +1 -3
- package/dist/array/unique.mjs +18 -5
- package/dist/array/update.d.mts +1 -3
- package/dist/array/update.mjs +1 -2
- package/dist/beacon.d.mts +3 -13
- package/dist/beacon.mjs +10 -21
- package/dist/color/constants.d.mts +1 -7
- package/dist/color/constants.mjs +3 -11
- package/dist/color/index.d.mts +0 -2
- package/dist/color/index.mjs +4 -5
- package/dist/color/instance.d.mts +1 -3
- package/dist/color/instance.mjs +5 -8
- package/dist/color/misc/alpha.d.mts +1 -3
- package/dist/color/misc/alpha.mjs +1 -2
- package/dist/color/misc/format.d.mts +1 -3
- package/dist/color/misc/format.mjs +1 -2
- package/dist/color/misc/get.d.mts +1 -3
- package/dist/color/misc/get.mjs +2 -3
- package/dist/color/misc/is.d.mts +1 -11
- package/dist/color/misc/is.mjs +4 -16
- package/dist/color/misc/state.d.mts +1 -3
- package/dist/color/misc/state.mjs +4 -5
- package/dist/color/space/hex.d.mts +1 -3
- package/dist/color/space/hex.mjs +2 -3
- package/dist/color/space/hsl.d.mts +1 -3
- package/dist/color/space/hsl.mjs +2 -3
- package/dist/color/space/hwb.d.mts +1 -3
- package/dist/color/space/hwb.mjs +3 -4
- package/dist/color/space/rgb.d.mts +1 -3
- package/dist/color/space/rgb.mjs +1 -2
- package/dist/function/limit.d.mts +1 -3
- package/dist/function/limit.mjs +2 -3
- package/dist/function/once.d.mts +1 -3
- package/dist/function/once.mjs +8 -9
- package/dist/function/retry.d.mts +1 -3
- package/dist/function/retry.mjs +11 -12
- package/dist/herald.d.mts +2 -2
- package/dist/herald.mjs +1 -1
- package/dist/index.d.mts +81 -359
- package/dist/index.mjs +514 -661
- package/dist/internal/aborter.d.mts +1 -3
- package/dist/internal/aborter.mjs +1 -2
- package/dist/internal/array/callbacks.d.mts +2 -4
- package/dist/internal/array/callbacks.mjs +1 -2
- package/dist/internal/array/chunk.d.mts +1 -3
- package/dist/internal/array/chunk.mjs +1 -2
- package/dist/internal/array/compact.d.mts +1 -3
- package/dist/internal/array/compact.mjs +1 -2
- package/dist/internal/array/find.d.mts +2 -8
- package/dist/internal/array/find.mjs +31 -124
- package/dist/internal/array/get.d.mts +1 -3
- package/dist/internal/array/get.mjs +1 -2
- package/dist/internal/array/group.d.mts +1 -3
- package/dist/internal/array/group.mjs +1 -2
- package/dist/internal/array/index-of.d.mts +1 -3
- package/dist/internal/array/index-of.mjs +10 -5
- package/dist/internal/array/insert.d.mts +1 -3
- package/dist/internal/array/insert.mjs +2 -3
- package/dist/internal/array/match.d.mts +2 -4
- package/dist/internal/array/match.mjs +2 -3
- package/dist/internal/array/overlap.d.mts +1 -3
- package/dist/internal/array/overlap.mjs +1 -2
- package/dist/internal/array/sets.d.mts +1 -3
- package/dist/internal/array/sets.mjs +5 -6
- package/dist/internal/array/shuffle.d.mts +1 -3
- package/dist/internal/array/shuffle.mjs +1 -2
- package/dist/internal/array/update.d.mts +1 -3
- package/dist/internal/array/update.mjs +1 -2
- package/dist/internal/defaults.d.mts +1 -3
- package/dist/internal/defaults.mjs +1 -2
- package/dist/internal/function/assert.d.mts +1 -3
- package/dist/internal/function/assert.mjs +1 -2
- package/dist/internal/function/limit.d.mts +2 -4
- package/dist/internal/function/limit.mjs +8 -9
- package/dist/internal/function/memoize.d.mts +1 -3
- package/dist/internal/function/memoize.mjs +4 -5
- package/dist/internal/function/misc.d.mts +1 -2
- package/dist/internal/function/misc.mjs +7 -3
- package/dist/internal/function/work.d.mts +1 -3
- package/dist/internal/function/work.mjs +5 -13
- package/dist/internal/herald.d.mts +2 -12
- package/dist/internal/herald.mjs +9 -33
- package/dist/internal/is.d.mts +1 -3
- package/dist/internal/is.mjs +1 -2
- package/dist/internal/math/aggregate.d.mts +1 -3
- package/dist/internal/math/aggregate.mjs +2 -3
- package/dist/internal/math/misc.d.mts +1 -3
- package/dist/internal/math/misc.mjs +1 -2
- package/dist/internal/number.d.mts +1 -3
- package/dist/internal/number.mjs +2 -3
- package/dist/internal/plan/index.d.mts +1 -3
- package/dist/internal/plan/index.mjs +2 -3
- package/dist/internal/plan/plan.generate.d.mts +1 -3
- package/dist/internal/plan/plan.generate.mjs +67 -22
- package/dist/internal/random.d.mts +1 -3
- package/dist/internal/random.mjs +1 -2
- package/dist/internal/result/attempt.d.mts +1 -3
- package/dist/internal/result/attempt.mjs +1 -2
- package/dist/internal/result/misc.d.mts +1 -3
- package/dist/internal/result/misc.mjs +1 -2
- package/dist/internal/sized/map.d.mts +4 -3
- package/dist/internal/sized/map.mjs +4 -2
- package/dist/internal/sized/misc.d.mts +1 -3
- package/dist/internal/sized/misc.mjs +1 -2
- package/dist/internal/string/case.d.mts +1 -3
- package/dist/internal/string/case.mjs +3 -4
- package/dist/internal/string/misc.d.mts +1 -3
- package/dist/internal/string/misc.mjs +1 -2
- package/dist/internal/subscription.d.mts +1 -3
- package/dist/internal/subscription.mjs +16 -29
- package/dist/internal/value/compare.d.mts +1 -3
- package/dist/internal/value/compare.mjs +2 -3
- package/dist/internal/value/equal.d.mts +1 -3
- package/dist/internal/value/equal.mjs +3 -4
- package/dist/internal/value/get.d.mts +1 -3
- package/dist/internal/value/get.mjs +1 -2
- package/dist/internal/value/handlers.d.mts +1 -3
- package/dist/internal/value/handlers.mjs +1 -2
- package/dist/internal/value/has.d.mts +1 -3
- package/dist/internal/value/has.mjs +1 -2
- package/dist/internal/value/misc.d.mts +1 -3
- package/dist/internal/value/misc.mjs +2 -3
- package/dist/internal/value/partial.d.mts +1 -3
- package/dist/internal/value/partial.mjs +1 -2
- package/dist/internal/value/set.d.mts +1 -3
- package/dist/internal/value/set.mjs +2 -3
- package/dist/is.d.mts +0 -2
- package/dist/is.mjs +2 -3
- package/dist/logger.d.mts +0 -2
- package/dist/logger.mjs +7 -7
- package/dist/math.d.mts +0 -2
- package/dist/math.mjs +2 -3
- package/dist/models/aborter.model.d.mts +1 -3
- package/dist/models/aborter.model.mjs +1 -2
- package/dist/models/array/array.match.model.d.mts +1 -3
- package/dist/models/array/array.match.model.mjs +1 -2
- package/dist/models/array/array.misc.model.d.mts +11 -2
- package/dist/models/array/array.misc.model.mjs +3 -3
- package/dist/models/array/array.sort.model.d.mts +1 -3
- package/dist/models/array/array.sort.model.mjs +1 -2
- package/dist/models/beacon.model.d.mts +4 -6
- package/dist/models/beacon.model.mjs +3 -10
- package/dist/models/color.model.d.mts +2 -4
- package/dist/models/function/assert.model.d.mts +1 -3
- package/dist/models/function/assert.model.mjs +1 -2
- package/dist/models/function/limiter.model.d.mts +2 -4
- package/dist/models/function/limiter.model.mjs +2 -4
- package/dist/models/function/memoize.model.d.mts +2 -4
- package/dist/models/function/memoize.model.mjs +1 -2
- package/dist/models/function/once.model.d.mts +0 -3
- package/dist/models/function/once.model.mjs +3 -5
- package/dist/models/function/retry.model.d.mts +1 -3
- package/dist/models/function/retry.model.mjs +1 -2
- package/dist/models/function/work.model.d.mts +2 -4
- package/dist/models/function/work.model.mjs +1 -2
- package/dist/models/herald.model.d.mts +8 -7
- package/dist/models/herald.model.mjs +3 -10
- package/dist/models/index.d.mts +0 -2
- package/dist/models/logger.model.d.mts +1 -4
- package/dist/models/logger.model.mjs +3 -5
- package/dist/models/math.model.d.mts +1 -3
- package/dist/models/math.model.mjs +1 -2
- package/dist/models/misc.model.d.mts +1 -3
- package/dist/models/misc.model.mjs +1 -2
- package/dist/models/plan.model.d.mts +35 -37
- package/dist/models/plan.model.mjs +1 -2
- package/dist/models/promise.model.d.mts +8 -10
- package/dist/models/promise.model.mjs +4 -5
- package/dist/models/query.model.d.mts +1 -3
- package/dist/models/query.model.mjs +1 -2
- package/dist/models/queue.model.d.mts +0 -3
- package/dist/models/queue.model.mjs +3 -5
- package/dist/models/random.model.d.mts +1 -3
- package/dist/models/random.model.mjs +1 -2
- package/dist/models/result.model.d.mts +0 -2
- package/dist/models/string/string.case.model.d.mts +1 -3
- package/dist/models/string/string.case.model.mjs +1 -2
- package/dist/models/string/string.fuzzy.model.d.mts +0 -3
- package/dist/models/string/string.fuzzy.model.mjs +3 -5
- package/dist/models/string/string.misc.model.d.mts +1 -3
- package/dist/models/string/string.misc.model.mjs +1 -2
- package/dist/models/string/string.normalize.model.d.mts +1 -3
- package/dist/models/string/string.normalize.model.mjs +1 -2
- package/dist/models/string/string.template.model.d.mts +1 -3
- package/dist/models/string/string.template.model.mjs +1 -2
- package/dist/models/subscription.model.d.mts +4 -23
- package/dist/models/subscription.model.mjs +3 -5
- package/dist/models/value/value.clone.model.d.mts +1 -3
- package/dist/models/value/value.clone.model.mjs +1 -2
- package/dist/models/value/value.diff.model.d.mts +1 -3
- package/dist/models/value/value.diff.model.mjs +1 -2
- package/dist/models/value/value.equal.model.d.mts +0 -2
- package/dist/models/value/value.equal.model.mjs +1 -2
- package/dist/models/value/value.handler.model.d.mts +1 -3
- package/dist/models/value/value.merge.model.d.mts +0 -2
- package/dist/models/value/value.merge.model.mjs +1 -2
- package/dist/models/value/value.misc.model.d.mts +0 -2
- package/dist/models/value/value.misc.model.mjs +1 -2
- package/dist/models/value/value.transform.model.d.mts +1 -3
- package/dist/models/value/value.transform.model.mjs +1 -2
- package/dist/plan/index.d.mts +1 -3
- package/dist/plan/index.mjs +2 -3
- package/dist/plan/is.d.mts +1 -3
- package/dist/plan/is.mjs +1 -2
- package/dist/plan/misc.d.mts +1 -3
- package/dist/plan/misc.mjs +2 -3
- package/dist/plan/models.d.mts +2 -2
- package/dist/plan/result.d.mts +8 -10
- package/dist/plan/result.mjs +2 -3
- package/dist/plan/run.d.mts +8 -10
- package/dist/plan/run.mjs +2 -3
- package/dist/plan/use.d.mts +1 -3
- package/dist/plan/use.mjs +14 -9
- package/dist/promise/delay.d.mts +1 -3
- package/dist/promise/delay.mjs +2 -3
- package/dist/promise/helpers.d.mts +1 -3
- package/dist/promise/helpers.mjs +2 -3
- package/dist/promise/index.d.mts +0 -2
- package/dist/promise/index.mjs +5 -6
- package/dist/promise/misc.d.mts +1 -3
- package/dist/promise/misc.mjs +2 -3
- package/dist/promise/models.d.mts +2 -2
- package/dist/promise/models.mjs +1 -1
- package/dist/promise/timed.d.mts +1 -3
- package/dist/promise/timed.mjs +4 -5
- package/dist/query.d.mts +1 -3
- package/dist/query.mjs +2 -3
- package/dist/queue.d.mts +0 -2
- package/dist/queue.mjs +11 -12
- package/dist/random.d.mts +0 -2
- package/dist/random.mjs +2 -3
- package/dist/result/match.d.mts +1 -3
- package/dist/result/match.mjs +1 -2
- package/dist/result/misc.d.mts +0 -2
- package/dist/result/misc.mjs +1 -2
- package/dist/result/work/flow.d.mts +1 -3
- package/dist/result/work/flow.mjs +5 -12
- package/dist/result/work/pipe.d.mts +0 -2
- package/dist/result/work/pipe.mjs +2 -3
- package/dist/sized/set.d.mts +4 -3
- package/dist/sized/set.mjs +4 -2
- package/dist/string/fuzzy.d.mts +0 -2
- package/dist/string/fuzzy.mjs +5 -7
- package/dist/string/index.d.mts +0 -2
- package/dist/string/index.mjs +2 -3
- package/dist/string/match.d.mts +1 -3
- package/dist/string/match.mjs +2 -3
- package/dist/string/normalize.d.mts +0 -2
- package/dist/string/normalize.mjs +3 -4
- package/dist/string/template.d.mts +0 -2
- package/dist/string/template.mjs +1 -2
- package/dist/subscription.d.mts +2 -2
- package/dist/value/clone.d.mts +1 -3
- package/dist/value/clone.mjs +2 -3
- package/dist/value/collection.d.mts +1 -3
- package/dist/value/collection.mjs +1 -2
- package/dist/value/diff.d.mts +0 -2
- package/dist/value/diff.mjs +1 -2
- package/dist/value/freeze.d.mts +1 -3
- package/dist/value/freeze.mjs +1 -2
- package/dist/value/handle.mjs +1 -1
- package/dist/value/merge.d.mts +0 -2
- package/dist/value/merge.mjs +1 -2
- package/dist/value/omit.d.mts +1 -3
- package/dist/value/omit.mjs +1 -2
- package/dist/value/pick.d.mts +1 -3
- package/dist/value/pick.mjs +1 -2
- package/dist/value/shake.d.mts +0 -2
- package/dist/value/shake.mjs +1 -2
- package/dist/value/smush.d.mts +0 -2
- package/dist/value/smush.mjs +2 -3
- package/dist/value/transform.d.mts +0 -2
- package/dist/value/transform.mjs +1 -2
- package/dist/value/unsmush.d.mts +0 -2
- package/dist/value/unsmush.mjs +1 -2
- package/package.json +6 -6
- package/dist/models/array/array.find.model.d.mts +0 -48
- package/dist/models/array/array.find.model.mjs +0 -8
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Subscription,
|
|
2
|
-
//#region src/models/beacon.model.d.ts
|
|
1
|
+
import { Subscription, Subscriptions } from "./subscription.model.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* A beacon is a lighthouse, holding an observable value that can be subscribed to and emitted from
|
|
5
4
|
*/
|
|
@@ -55,6 +54,7 @@ export type BeaconState<Value> = {
|
|
|
55
54
|
observable?: Observable<Value>;
|
|
56
55
|
options: Required<BeaconOptions<Value>>;
|
|
57
56
|
subscriptions?: Subscriptions<Observer<unknown>>;
|
|
57
|
+
name: typeof BEACON_NAME;
|
|
58
58
|
value: Value;
|
|
59
59
|
};
|
|
60
60
|
export type InternalBeacon = {
|
|
@@ -92,6 +92,7 @@ export type Observable<Value> = {
|
|
|
92
92
|
export type ObservableState<Value> = {
|
|
93
93
|
active: boolean;
|
|
94
94
|
beacon: BeaconState<Value>;
|
|
95
|
+
name: typeof BEACON_OBSERVABLE;
|
|
95
96
|
};
|
|
96
97
|
export type Observer<Value> = {
|
|
97
98
|
/**
|
|
@@ -109,11 +110,8 @@ export type Observer<Value> = {
|
|
|
109
110
|
};
|
|
110
111
|
export declare const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
111
112
|
export declare const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
112
|
-
export declare const BEACON_PROPERTY = "$beacon";
|
|
113
113
|
export declare const BEACON_NAME = "beacon";
|
|
114
114
|
export declare const BEACON_OBSERVABLE = "observable";
|
|
115
115
|
export declare const BEACON_SYMBOL: unique symbol;
|
|
116
116
|
export declare const BEACON_TYPE_ERROR = "error";
|
|
117
|
-
export declare const BEACON_TYPE_NEXT = "next";
|
|
118
|
-
export declare const beaconSubscription: SubscriptionProperty;
|
|
119
|
-
//#endregion
|
|
117
|
+
export declare const BEACON_TYPE_NEXT = "next";
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/models/beacon.model.ts
|
|
1
|
+
// src/models/beacon.model.ts
|
|
3
2
|
const BEACON_MESSAGE_RETRIEVE = "Cannot retrieve observable from a closed beacon";
|
|
4
3
|
const BEACON_MESSAGE_SUBSCRIBE = "Cannot subscribe to a closed observable";
|
|
5
|
-
const BEACON_PROPERTY = "$beacon";
|
|
6
4
|
const BEACON_NAME = "beacon";
|
|
7
5
|
const BEACON_OBSERVABLE = "observable";
|
|
8
|
-
const BEACON_SYMBOL = Symbol(
|
|
6
|
+
const BEACON_SYMBOL = Symbol("beacon");
|
|
9
7
|
const BEACON_TYPE_ERROR = "error";
|
|
10
8
|
const BEACON_TYPE_NEXT = "next";
|
|
11
|
-
|
|
12
|
-
key: BEACON_PROPERTY,
|
|
13
|
-
value: SUBSCRIPTION_NAME
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { BEACON_MESSAGE_RETRIEVE, BEACON_MESSAGE_SUBSCRIBE, BEACON_NAME, BEACON_OBSERVABLE, BEACON_PROPERTY, BEACON_SYMBOL, BEACON_TYPE_ERROR, BEACON_TYPE_NEXT, beaconSubscription };
|
|
9
|
+
export { BEACON_MESSAGE_RETRIEVE, BEACON_MESSAGE_SUBSCRIBE, BEACON_NAME, BEACON_OBSERVABLE, BEACON_SYMBOL, BEACON_TYPE_ERROR, BEACON_TYPE_NEXT };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Subscription } from "./subscription.model.mjs";
|
|
2
|
-
import { Herald, HeraldEvents } from "./herald.model.mjs";
|
|
3
1
|
import { COLOR_SYMBOL } from "../color/constants.mjs";
|
|
4
|
-
|
|
2
|
+
import { Herald, HeraldEvents } from "./herald.model.mjs";
|
|
3
|
+
import { Subscription } from "./subscription.model.mjs";
|
|
5
4
|
export type Alpha = {
|
|
6
5
|
hex: string;
|
|
7
6
|
value: number;
|
|
@@ -307,5 +306,4 @@ export type ColorValue = string | HSLColor | HWBColor | RGBColor;
|
|
|
307
306
|
* Extended color values
|
|
308
307
|
*/
|
|
309
308
|
export type ColorValueExtended = ColorValue | HSLAColor | HWBAColor | RGBAColor;
|
|
310
|
-
//#endregion
|
|
311
309
|
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NestedKeys, PlainObject } from "../index.mjs";
|
|
2
|
-
//#region src/models/function/assert.model.d.ts
|
|
3
2
|
export type AssertNestedPick<Value, Path extends string> = Value extends PlainObject ? Path extends `${infer Head}.${infer Rest}` ? Head extends keyof Value ? { [Key in Head]: AssertNestedPick<Value[Key], Rest>; } : never : Path extends keyof Value ? { [Key in Path]: Value[Key]; } : never : never;
|
|
4
3
|
/**
|
|
5
4
|
* Asserter for a property of a value
|
|
@@ -9,5 +8,4 @@ export type AssertProperty<Value extends PlainObject, Path extends NestedKeys<Va
|
|
|
9
8
|
* A function that asserts a value is of a specific type, throwing an error if it is not
|
|
10
9
|
*/
|
|
11
10
|
export type Asserter<Value> = (value: unknown) => asserts value is Value;
|
|
12
|
-
export declare const ASSERT_MESSAGE_VALUE_DEFINED = "Expected value to be defined";
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare const ASSERT_MESSAGE_VALUE_DEFINED = "Expected value to be defined";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GenericAsyncCallback, GenericCallback } from "../index.mjs";
|
|
2
|
-
//#region src/models/function/limiter.model.d.ts
|
|
3
2
|
export type AsyncLimiterItem = {
|
|
4
3
|
parameters: unknown[];
|
|
5
4
|
promise: Promise<unknown>;
|
|
@@ -51,6 +50,7 @@ export type Limiter<Callback extends GenericCallback> = {
|
|
|
51
50
|
export type LimiterState<Callback = GenericCallback> = {
|
|
52
51
|
callback: Callback;
|
|
53
52
|
interval: number;
|
|
53
|
+
name: string;
|
|
54
54
|
parameters: unknown[];
|
|
55
55
|
start?: number;
|
|
56
56
|
throttle: boolean;
|
|
@@ -61,11 +61,9 @@ export type LimiterType = "debounce" | "throttle" | "wait";
|
|
|
61
61
|
export declare const LIMITER_DEBOUNCE: LimiterType;
|
|
62
62
|
export declare const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
63
63
|
export declare const LIMITER_NAME_SYNC = "limiter";
|
|
64
|
-
export declare const LIMITER_PROPERTY = "$limiter";
|
|
65
64
|
export declare const LIMITER_OFFSET = 5;
|
|
66
65
|
export declare const LIMITER_SYMBOL: unique symbol;
|
|
67
66
|
export declare const LIMITER_THROTTLE: LimiterType;
|
|
68
67
|
export declare const LIMITER_WAIT: LimiterType;
|
|
69
68
|
export declare const clearTimer: (handle: number) => void;
|
|
70
|
-
export declare const startTimer: (callback: FrameRequestCallback) => number;
|
|
71
|
-
//#endregion
|
|
69
|
+
export declare const startTimer: (callback: FrameRequestCallback) => number;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/function/limiter.model.ts
|
|
2
2
|
const LIMITER_DEBOUNCE = "debounce";
|
|
3
3
|
const LIMITER_NAME_ASYNC = "asyncLimiter";
|
|
4
4
|
const LIMITER_NAME_SYNC = "limiter";
|
|
5
|
-
const LIMITER_PROPERTY = "$limiter";
|
|
6
5
|
const LIMITER_OFFSET = 5;
|
|
7
6
|
const LIMITER_SYMBOL = Symbol("limiter");
|
|
8
7
|
const LIMITER_THROTTLE = "throttle";
|
|
@@ -11,5 +10,4 @@ const LIMITER_WAIT = "wait";
|
|
|
11
10
|
const clearTimer = typeof cancelAnimationFrame === "function" ? cancelAnimationFrame : clearTimeout;
|
|
12
11
|
// istanbul ignore next
|
|
13
12
|
const startTimer = typeof requestAnimationFrame === "function" ? requestAnimationFrame : setTimeout;
|
|
14
|
-
|
|
15
|
-
export { LIMITER_DEBOUNCE, LIMITER_NAME_ASYNC, LIMITER_NAME_SYNC, LIMITER_OFFSET, LIMITER_PROPERTY, LIMITER_SYMBOL, LIMITER_THROTTLE, LIMITER_WAIT, clearTimer, startTimer };
|
|
13
|
+
export { LIMITER_DEBOUNCE, LIMITER_NAME_ASYNC, LIMITER_NAME_SYNC, LIMITER_OFFSET, LIMITER_SYMBOL, LIMITER_THROTTLE, LIMITER_WAIT, clearTimer, startTimer };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { GenericCallback } from "../index.mjs";
|
|
2
1
|
import { SizedMap } from "../../internal/sized/map.mjs";
|
|
3
|
-
|
|
2
|
+
import { GenericCallback } from "../index.mjs";
|
|
4
3
|
export type InternalMemoized = {
|
|
5
4
|
[MEMOIZED_SYMBOL]: MemoizedState;
|
|
6
5
|
} & Memoized<GenericCallback>;
|
|
@@ -84,5 +83,4 @@ export type MemoizedStateOptions = {
|
|
|
84
83
|
export declare const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
85
84
|
export declare const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
86
85
|
export declare const MEMOIZED_KEY_SEPARATOR = "_";
|
|
87
|
-
export declare const MEMOIZED_SYMBOL: unique symbol;
|
|
88
|
-
//#endregion
|
|
86
|
+
export declare const MEMOIZED_SYMBOL: unique symbol;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/function/memoize.model.ts
|
|
2
2
|
const MEMOIZED_CACHE_SIZE_DEFAULT = 1024;
|
|
3
3
|
const MEMOIZED_CALLBACK = "Memoized requires a callback function";
|
|
4
4
|
const MEMOIZED_KEY_SEPARATOR = "_";
|
|
5
5
|
const MEMOIZED_SYMBOL = Symbol("memoized");
|
|
6
|
-
//#endregion
|
|
7
6
|
export { MEMOIZED_CACHE_SIZE_DEFAULT, MEMOIZED_CALLBACK, MEMOIZED_KEY_SEPARATOR, MEMOIZED_SYMBOL };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { GenericAsyncCallback, GenericCallback } from "../index.mjs";
|
|
2
|
-
//#region src/models/function/once.model.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* An asynchronous function that can only be called once, returning the same value on subsequent calls
|
|
5
4
|
*/
|
|
@@ -69,9 +68,7 @@ export type OnceState<Value, Callback = GenericCallback> = {
|
|
|
69
68
|
};
|
|
70
69
|
export declare const ONCE_NAME_ASYNC = "asyncOnce";
|
|
71
70
|
export declare const ONCE_NAME_SYNC = "once";
|
|
72
|
-
export declare const ONCE_PROPERTY = "$once";
|
|
73
71
|
export declare const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
74
72
|
export declare const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
75
73
|
export declare const ONCE_SYMBOL: unique symbol;
|
|
76
|
-
//#endregion
|
|
77
74
|
export {};
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/function/once.model.ts
|
|
2
2
|
const ONCE_NAME_ASYNC = "asyncOnce";
|
|
3
3
|
const ONCE_NAME_SYNC = "once";
|
|
4
|
-
const ONCE_PROPERTY = "$once";
|
|
5
4
|
const ONCE_MESSAGE_CLEARED = "Once has been cleared";
|
|
6
5
|
const ONCE_MESSAGE_EXPECTATION = "Once expected a function";
|
|
7
|
-
const ONCE_SYMBOL = Symbol(
|
|
8
|
-
|
|
9
|
-
export { ONCE_MESSAGE_CLEARED, ONCE_MESSAGE_EXPECTATION, ONCE_NAME_ASYNC, ONCE_NAME_SYNC, ONCE_PROPERTY, ONCE_SYMBOL };
|
|
6
|
+
const ONCE_SYMBOL = Symbol("once");
|
|
7
|
+
export { ONCE_MESSAGE_CLEARED, ONCE_MESSAGE_EXPECTATION, ONCE_NAME_ASYNC, ONCE_NAME_SYNC, ONCE_SYMBOL };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/function/retry.model.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* An error thrown when a retry fails
|
|
4
3
|
*/
|
|
@@ -13,5 +12,4 @@ export type RetryOptions = {
|
|
|
13
12
|
};
|
|
14
13
|
export declare const RETRY_ERROR_NAME = "RetryError";
|
|
15
14
|
export declare const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
16
|
-
export declare const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/function/retry.model.ts
|
|
2
2
|
/**
|
|
3
3
|
* An error thrown when a retry fails
|
|
4
4
|
*/
|
|
@@ -13,5 +13,4 @@ var RetryError = class extends Error {
|
|
|
13
13
|
const RETRY_ERROR_NAME = "RetryError";
|
|
14
14
|
const RETRY_MESSAGE_EXPECTATION = "Retry expected a function";
|
|
15
15
|
const RETRY_MESSAGE_FAILED = "Retry failed";
|
|
16
|
-
//#endregion
|
|
17
16
|
export { RETRY_ERROR_NAME, RETRY_MESSAGE_EXPECTATION, RETRY_MESSAGE_FAILED, RetryError };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { GenericCallback } from "../index.mjs";
|
|
2
|
-
import { Asserter } from "./assert.model.mjs";
|
|
3
2
|
import { UnwrapValue } from "../result.model.mjs";
|
|
4
|
-
|
|
3
|
+
import { Asserter } from "./assert.model.mjs";
|
|
5
4
|
/**
|
|
6
5
|
* An asynchronous _Flow_, a function that pipes a value through a series of functions
|
|
7
6
|
*/
|
|
@@ -16,5 +15,4 @@ export declare const WORK_MESSAGE_NESTING = "Return values are too deeply nested
|
|
|
16
15
|
export declare const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions";
|
|
17
16
|
export declare const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
18
17
|
export declare const assertFlowFunctions: Asserter<Function[]>;
|
|
19
|
-
export declare const assertPipeFunctions: Asserter<Function[]>;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare const assertPipeFunctions: Asserter<Function[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../internal/function/assert.mjs";
|
|
2
|
-
|
|
2
|
+
// src/models/function/work.model.ts
|
|
3
3
|
const WORK_MESSAGE_FLOW_ARRAY = "Flow expected to receive an array of functions";
|
|
4
4
|
const WORK_MESSAGE_FLOW_PROMISE = "Synchronous Flow received a promise. Use `flow.async` instead.";
|
|
5
5
|
const WORK_MESSAGE_NESTING = "Return values are too deeply nested.";
|
|
@@ -7,5 +7,4 @@ const WORK_MESSAGE_PIPE_ARRAY = "Pipe expected to receive an array of functions"
|
|
|
7
7
|
const WORK_MESSAGE_PIPE_PROMISE = "Synchronous Pipe received a promise. Use `pipe.async` instead.";
|
|
8
8
|
const assertFlowFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_FLOW_ARRAY, TypeError);
|
|
9
9
|
const assertPipeFunctions = assert.condition((value) => Array.isArray(value) && value.every((item) => typeof item === "function"), WORK_MESSAGE_PIPE_ARRAY, TypeError);
|
|
10
|
-
//#endregion
|
|
11
10
|
export { WORK_MESSAGE_FLOW_ARRAY, WORK_MESSAGE_FLOW_PROMISE, WORK_MESSAGE_NESTING, WORK_MESSAGE_PIPE_ARRAY, WORK_MESSAGE_PIPE_PROMISE, assertFlowFunctions, assertPipeFunctions };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericCallback } from "./index.mjs";
|
|
2
|
-
import { Subscription,
|
|
3
|
-
//#region src/models/herald.model.d.ts
|
|
2
|
+
import { Subscription, Subscriptions } from "./subscription.model.mjs";
|
|
4
3
|
export type Herald<Events extends Record<string, GenericCallback>> = {
|
|
5
4
|
readonly events: HeraldEvents<Events>;
|
|
6
5
|
/**
|
|
@@ -35,7 +34,6 @@ export type HeraldEvents<Events extends Record<string, GenericCallback>> = { [Ke
|
|
|
35
34
|
export type HeraldOnCreate<Events extends Record<string, GenericCallback>> = <Event extends keyof Events>(event: Event, callback: Events[Event], subscription: Subscription) => void;
|
|
36
35
|
export type HeraldOptions<Events extends Record<string, GenericCallback>> = {
|
|
37
36
|
names: Array<keyof Events>;
|
|
38
|
-
property?: SubscriptionProperty;
|
|
39
37
|
onCreate?: HeraldOnCreate<Events>;
|
|
40
38
|
};
|
|
41
39
|
export type HeraldState = {
|
|
@@ -46,15 +44,18 @@ export type HeraldState = {
|
|
|
46
44
|
export type InternalHerald = {
|
|
47
45
|
[HERALD_SYMBOL]: {
|
|
48
46
|
events: HeraldEvents<Record<string, GenericCallback>>;
|
|
47
|
+
name: typeof HERALD_NAME_HERALD;
|
|
49
48
|
state: HeraldState;
|
|
50
49
|
};
|
|
51
50
|
} & Herald<Record<string, GenericCallback>>;
|
|
51
|
+
export type InternalHeraldEvents = {
|
|
52
|
+
[HERALD_SYMBOL]: {
|
|
53
|
+
name: typeof HERALD_NAME_EVENTS;
|
|
54
|
+
};
|
|
55
|
+
} & HeraldEvents<Record<string, GenericCallback>>;
|
|
52
56
|
export declare const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
53
57
|
export declare const HERALD_MESSAGE_ONCREATE = "Herald requires a valid onCreate callback for subscription creation";
|
|
54
58
|
export declare const HERALD_MESSAGE_PROPERTY = "Herald requires valid property information for subscription identification";
|
|
55
59
|
export declare const HERALD_NAME_EVENTS = "events";
|
|
56
60
|
export declare const HERALD_NAME_HERALD = "herald";
|
|
57
|
-
export declare const
|
|
58
|
-
export declare const HERALD_SYMBOL: unique symbol;
|
|
59
|
-
export declare const heraldSubscription: SubscriptionProperty;
|
|
60
|
-
//#endregion
|
|
61
|
+
export declare const HERALD_SYMBOL: unique symbol;
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/models/herald.model.ts
|
|
1
|
+
// src/models/herald.model.ts
|
|
3
2
|
const HERALD_MESSAGE_ARRAY = "Herald requires an array of event names.";
|
|
4
3
|
const HERALD_MESSAGE_ONCREATE = `Herald requires a valid onCreate callback for subscription creation`;
|
|
5
4
|
const HERALD_MESSAGE_PROPERTY = `Herald requires valid property information for subscription identification`;
|
|
6
5
|
const HERALD_NAME_EVENTS = "events";
|
|
7
6
|
const HERALD_NAME_HERALD = "herald";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const heraldSubscription = {
|
|
11
|
-
key: HERALD_PROPERTY,
|
|
12
|
-
value: SUBSCRIPTION_NAME
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
export { HERALD_MESSAGE_ARRAY, HERALD_MESSAGE_ONCREATE, HERALD_MESSAGE_PROPERTY, HERALD_NAME_EVENTS, HERALD_NAME_HERALD, HERALD_PROPERTY, HERALD_SYMBOL, heraldSubscription };
|
|
7
|
+
const HERALD_SYMBOL = Symbol("herald");
|
|
8
|
+
export { HERALD_MESSAGE_ARRAY, HERALD_MESSAGE_ONCREATE, HERALD_MESSAGE_PROPERTY, HERALD_NAME_EVENTS, HERALD_NAME_HERALD, HERALD_SYMBOL };
|
package/dist/models/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/index.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* A generic array or object
|
|
4
3
|
*/
|
|
@@ -124,5 +123,4 @@ export type UnionToIntersection<Union> = (Union extends unknown ? (distributedUn
|
|
|
124
123
|
* A function that unsubscribes from a subscription
|
|
125
124
|
*/
|
|
126
125
|
export type Unsubscriber = () => void;
|
|
127
|
-
//#endregion
|
|
128
126
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/logger.model.d.ts
|
|
2
1
|
export type InternalTimeLogger = {
|
|
3
2
|
[LOGGER_SYMBOL]: TimeLoggerState;
|
|
4
3
|
} & TimeLogger;
|
|
@@ -78,6 +77,4 @@ export type TimeLoggerState = {
|
|
|
78
77
|
};
|
|
79
78
|
export declare const LOGGER_NAME = "Logger";
|
|
80
79
|
export declare const LOGGER_NAME_TIMED = "TimedLogger";
|
|
81
|
-
export declare const
|
|
82
|
-
export declare const LOGGER_SYMBOL: unique symbol;
|
|
83
|
-
//#endregion
|
|
80
|
+
export declare const LOGGER_SYMBOL: unique symbol;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/logger.model.ts
|
|
2
2
|
const LOGGER_NAME = "Logger";
|
|
3
3
|
const LOGGER_NAME_TIMED = "TimedLogger";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
//#endregion
|
|
7
|
-
export { LOGGER_NAME, LOGGER_NAME_TIMED, LOGGER_PROPERTY, LOGGER_SYMBOL };
|
|
4
|
+
const LOGGER_SYMBOL = Symbol("logger");
|
|
5
|
+
export { LOGGER_NAME, LOGGER_NAME_TIMED, LOGGER_SYMBOL };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/math.model.d.ts
|
|
2
1
|
export type Aggregation = {
|
|
3
2
|
array: boolean;
|
|
4
3
|
count: number;
|
|
@@ -12,5 +11,4 @@ export type NonAverageAggregationType = "max" | "min" | "sum";
|
|
|
12
11
|
export declare const AGGREGATION_AVERAGE = "average";
|
|
13
12
|
export declare const AGGREGATION_MAX = "max";
|
|
14
13
|
export declare const AGGREGATION_MIN = "min";
|
|
15
|
-
export declare const AGGREGATION_SUM = "sum";
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare const AGGREGATION_SUM = "sum";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/math.model.ts
|
|
2
2
|
const AGGREGATION_AVERAGE = "average";
|
|
3
3
|
const AGGREGATION_MAX = "max";
|
|
4
4
|
const AGGREGATION_MIN = "min";
|
|
5
5
|
const AGGREGATION_SUM = "sum";
|
|
6
|
-
//#endregion
|
|
7
6
|
export { AGGREGATION_AVERAGE, AGGREGATION_MAX, AGGREGATION_MIN, AGGREGATION_SUM };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/models/misc.model.d.ts
|
|
2
1
|
export declare const EXPRESSION_INTEGER: RegExp;
|
|
3
2
|
export declare const EXPRESSION_NUMBER_BINARY: RegExp;
|
|
4
3
|
export declare const EXPRESSION_NUMBER_OCTAL: RegExp;
|
|
@@ -6,5 +5,4 @@ export declare const EXPRESSION_NUMBER_ZEROISH: RegExp;
|
|
|
6
5
|
export declare const EXPRESSION_NUMERICAL_PREFIX: RegExp;
|
|
7
6
|
export declare const EXPRESSION_WHITESPACE_MULTIPLE: RegExp;
|
|
8
7
|
export declare const EXPRESSION_WHITESPACE_ONLY: RegExp;
|
|
9
|
-
export declare const NUMBER_OCTAL_VALUE = 8;
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare const NUMBER_OCTAL_VALUE = 8;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/misc.model.ts
|
|
2
2
|
const EXPRESSION_INTEGER = /^\d+$/;
|
|
3
3
|
const EXPRESSION_NUMBER_BINARY = /^0b[01]+$/i;
|
|
4
4
|
const EXPRESSION_NUMBER_OCTAL = /^0o[0-7]+$/i;
|
|
@@ -7,5 +7,4 @@ const EXPRESSION_NUMERICAL_PREFIX = /^\d/;
|
|
|
7
7
|
const EXPRESSION_WHITESPACE_MULTIPLE = /\s+/g;
|
|
8
8
|
const EXPRESSION_WHITESPACE_ONLY = /^\s*$/;
|
|
9
9
|
const NUMBER_OCTAL_VALUE = 8;
|
|
10
|
-
//#endregion
|
|
11
10
|
export { EXPRESSION_INTEGER, EXPRESSION_NUMBER_BINARY, EXPRESSION_NUMBER_OCTAL, EXPRESSION_NUMBER_ZEROISH, EXPRESSION_NUMERICAL_PREFIX, EXPRESSION_WHITESPACE_MULTIPLE, EXPRESSION_WHITESPACE_ONLY, NUMBER_OCTAL_VALUE };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Err, Ok, Result } from "./result.model.mjs";
|
|
2
|
-
//#region src/models/plan.model.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* An immediately failing asynchronous plan
|
|
5
4
|
*/
|
|
@@ -11,6 +10,10 @@ export type AsyncFailure<Value> = {
|
|
|
11
10
|
*/
|
|
12
11
|
[Symbol.asyncIterator]: () => AsyncGenerator<Err<Value>, never>;
|
|
13
12
|
};
|
|
13
|
+
export type AsyncImmediateState = {
|
|
14
|
+
generator: () => AsyncGenerator;
|
|
15
|
+
type: typeof PLAN_FAILURE_ASYNC | typeof PLAN_SUCCESS_ASYNC;
|
|
16
|
+
};
|
|
14
17
|
/**
|
|
15
18
|
* An asynchronous plan of execution that can yield intermediate results and eventually return a result
|
|
16
19
|
*/
|
|
@@ -28,23 +31,19 @@ export type AsyncPlan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
28
31
|
*
|
|
29
32
|
* @returns Attempted result
|
|
30
33
|
*/
|
|
31
|
-
attempt: Parameters extends [infer _, ...(infer _)[]] ? (parameters: Parameters, signal?: AbortSignal) => Promise<Result<
|
|
34
|
+
attempt: Parameters extends [infer _, ...(infer _)[]] ? (parameters: Parameters, signal?: AbortSignal) => Promise<Result<PlannedOk<Returned>, PlannedError<Yielded, Returned>>> : (signal?: AbortSignal) => Promise<Result<PlannedOk<Returned>, PlannedError<Yielded, Returned>>>;
|
|
32
35
|
/**
|
|
33
36
|
* Run the plan to completion
|
|
34
37
|
*
|
|
35
|
-
* @throws {
|
|
38
|
+
* @throws {PlannedError<Yielded, Returned>}
|
|
36
39
|
* @returns Result
|
|
37
40
|
*/
|
|
38
|
-
run: Parameters extends [infer _, ...(infer _)[]] ? (parameters: Parameters, signal?: AbortSignal) => Promise<
|
|
41
|
+
run: Parameters extends [infer _, ...(infer _)[]] ? (parameters: Parameters, signal?: AbortSignal) => Promise<PlannedReturned<Returned>> : (signal?: AbortSignal) => Promise<PlannedReturned<Returned>>;
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* An immediately succeeding or failing asynchronous plan
|
|
42
45
|
*/
|
|
43
|
-
export type
|
|
44
|
-
export type AsyncPlannedState = {
|
|
45
|
-
generator: () => AsyncGenerator;
|
|
46
|
-
type: typeof PLAN_FAILURE_ASYNC | typeof PLAN_SUCCESS_ASYNC;
|
|
47
|
-
};
|
|
46
|
+
export type AsyncImmediate<Value, Error> = AsyncSuccess<Value> | AsyncFailure<Error>;
|
|
48
47
|
export type AsyncPlanState = {
|
|
49
48
|
generator(...parameters: unknown[]): AsyncGenerator;
|
|
50
49
|
type: typeof PLAN_TYPE_ASYNC;
|
|
@@ -102,10 +101,19 @@ export type GenericPlanItem = {
|
|
|
102
101
|
};
|
|
103
102
|
export type GenericPlanItemState = {
|
|
104
103
|
generator: () => AsyncGenerator | Generator;
|
|
105
|
-
type: PlanType |
|
|
104
|
+
type: PlanType | ImmediateType | StepType;
|
|
106
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* An immediately succeeding or failing plan
|
|
108
|
+
*/
|
|
109
|
+
export type Immediate<Value, Error> = Success<Value> | Failure<Error>;
|
|
110
|
+
export type ImmediateState = {
|
|
111
|
+
generator: () => Generator;
|
|
112
|
+
type: typeof PLAN_FAILURE_SYNC | typeof PLAN_SUCCESS_SYNC;
|
|
113
|
+
};
|
|
114
|
+
export type ImmediateType = "asyncFailure" | "asyncSuccess" | "failure" | "success";
|
|
107
115
|
export type InternalAsyncFailure = {
|
|
108
|
-
[PLAN_SYMBOL]:
|
|
116
|
+
[PLAN_SYMBOL]: AsyncImmediateState;
|
|
109
117
|
} & AsyncFailure<never>;
|
|
110
118
|
export type InternalAsyncPlan = {
|
|
111
119
|
[PLAN_SYMBOL]: AsyncPlanState;
|
|
@@ -114,16 +122,16 @@ export type InternalAsyncStep = {
|
|
|
114
122
|
[PLAN_SYMBOL]: AsyncStepState;
|
|
115
123
|
} & AsyncStep<never>;
|
|
116
124
|
export type InternalAsyncSuccess = {
|
|
117
|
-
[PLAN_SYMBOL]:
|
|
125
|
+
[PLAN_SYMBOL]: AsyncImmediateState;
|
|
118
126
|
} & AsyncSuccess<never>;
|
|
119
127
|
export type InternalFailure = {
|
|
120
|
-
[PLAN_SYMBOL]:
|
|
128
|
+
[PLAN_SYMBOL]: ImmediateState;
|
|
121
129
|
} & Failure<never>;
|
|
122
130
|
export type InternalPlan = {
|
|
123
131
|
[PLAN_SYMBOL]: PlanState;
|
|
124
132
|
} & Plan<never, never, unknown[]>;
|
|
125
133
|
export type InternalSuccess = {
|
|
126
|
-
[PLAN_SYMBOL]:
|
|
134
|
+
[PLAN_SYMBOL]: ImmediateState;
|
|
127
135
|
} & Success<never>;
|
|
128
136
|
export type InternalStep = {
|
|
129
137
|
[PLAN_SYMBOL]: StepState;
|
|
@@ -154,42 +162,33 @@ export type Plan<Yielded, Returned, Parameters extends unknown[]> = {
|
|
|
154
162
|
*
|
|
155
163
|
* @returns Attempted result
|
|
156
164
|
*/
|
|
157
|
-
attempt(...parameters: Parameters): Result<
|
|
165
|
+
attempt(...parameters: Parameters): Result<PlannedOk<Returned>, PlannedError<Yielded, Returned>>;
|
|
158
166
|
/**
|
|
159
167
|
* Run the plan to completion
|
|
160
168
|
*
|
|
161
|
-
* @throws {
|
|
169
|
+
* @throws {PlannedError<Yielded, Returned>}
|
|
162
170
|
* @returns Result
|
|
163
171
|
*/
|
|
164
|
-
run(...parameters: Parameters):
|
|
172
|
+
run(...parameters: Parameters): PlannedReturned<Returned>;
|
|
173
|
+
};
|
|
174
|
+
export type PlanState = {
|
|
175
|
+
generator(...parameters: unknown[]): Generator;
|
|
176
|
+
type: typeof PLAN_TYPE_SYNC;
|
|
165
177
|
};
|
|
166
|
-
/**
|
|
167
|
-
* An OK result of a plan execution
|
|
168
|
-
*/
|
|
169
|
-
export type PlanOk<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned extends Ok<infer Value> ? Value : Returned;
|
|
170
|
-
type PlanErrors<Yielded, Returned> = PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
171
178
|
/**
|
|
172
179
|
* An error result of a plan execution
|
|
173
180
|
*/
|
|
174
|
-
export type
|
|
181
|
+
export type PlannedError<Yielded, Returned> = [PlannedErrors<Yielded, Returned>] extends [never] ? Error : PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
182
|
+
type PlannedErrors<Yielded, Returned> = PlanErrorValues<Yielded> | PlanErrorValues<Returned>;
|
|
175
183
|
type PlanErrorValues<Original> = Original extends Error ? Original : Original extends Err<infer E> ? E : Original extends Failure<infer E> ? E : never;
|
|
176
184
|
/**
|
|
177
|
-
*
|
|
185
|
+
* An OK result of a plan execution
|
|
178
186
|
*/
|
|
179
|
-
export type
|
|
187
|
+
export type PlannedOk<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned extends Ok<infer Value> ? Value : Returned;
|
|
180
188
|
/**
|
|
181
|
-
*
|
|
189
|
+
* The returned result of a plan execution _(excluding errors, which are thrown)_
|
|
182
190
|
*/
|
|
183
|
-
export type
|
|
184
|
-
export type PlannedState = {
|
|
185
|
-
generator: () => Generator;
|
|
186
|
-
type: typeof PLAN_FAILURE_SYNC | typeof PLAN_SUCCESS_SYNC;
|
|
187
|
-
};
|
|
188
|
-
export type PlannedType = "asyncFailure" | "asyncSuccess" | "failure" | "success";
|
|
189
|
-
export type PlanState = {
|
|
190
|
-
generator(...parameters: unknown[]): Generator;
|
|
191
|
-
type: typeof PLAN_TYPE_SYNC;
|
|
192
|
-
};
|
|
191
|
+
export type PlannedReturned<Returned> = Returned extends Error ? never : Returned extends Err<infer _> ? never : Returned;
|
|
193
192
|
/**
|
|
194
193
|
* A single step within a plan of execution
|
|
195
194
|
*/
|
|
@@ -242,5 +241,4 @@ export declare const PLAN_SUCCESS_SYNC: "success";
|
|
|
242
241
|
export declare const PLAN_SYMBOL: unique symbol;
|
|
243
242
|
export declare const PLAN_TYPE_ASYNC: "asyncPlan";
|
|
244
243
|
export declare const PLAN_TYPE_SYNC: "plan";
|
|
245
|
-
//#endregion
|
|
246
244
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/plan.model.ts
|
|
2
2
|
const GENERATOR_FUNCTION_TYPE_ASYNC = "[object AsyncGeneratorFunction]";
|
|
3
3
|
const GENERATOR_FUNCTION_TYPE_SYNC = "[object GeneratorFunction]";
|
|
4
4
|
const GENERATOR_TYPE_ASYNC = "[object AsyncGenerator]";
|
|
@@ -16,5 +16,4 @@ const PLAN_SUCCESS_SYNC = "success";
|
|
|
16
16
|
const PLAN_SYMBOL = Symbol("plan");
|
|
17
17
|
const PLAN_TYPE_ASYNC = "asyncPlan";
|
|
18
18
|
const PLAN_TYPE_SYNC = "plan";
|
|
19
|
-
//#endregion
|
|
20
19
|
export { GENERATOR_FUNCTION_TYPE_ASYNC, GENERATOR_FUNCTION_TYPE_SYNC, GENERATOR_TYPE_ASYNC, GENERATOR_TYPE_SYNC, PLAN_FAILURE_ASYNC, PLAN_FAILURE_SYNC, PLAN_MESSAGE_PLAN_INPUT, PLAN_MESSAGE_RUN_INPUT, PLAN_MESSAGE_USE_NESTED_FN, PLAN_MESSAGE_USE_SYNC_ASYNC, PLAN_STEP_ASYNC, PLAN_STEP_SYNC, PLAN_SUCCESS_ASYNC, PLAN_SUCCESS_SYNC, PLAN_SYMBOL, PLAN_TYPE_ASYNC, PLAN_TYPE_SYNC };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { ArrayOrPlainObject, GenericCallback, Key } from "./index.mjs";
|
|
2
2
|
import { Aborter } from "./aborter.model.mjs";
|
|
3
3
|
import { Result } from "./result.model.mjs";
|
|
4
|
-
//#region src/models/promise.model.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* A _Promise_ that can be canceled
|
|
7
6
|
*/
|
|
@@ -65,12 +64,6 @@ export type PromiseParameters = {
|
|
|
65
64
|
* - `first`: rejects on the first rejected _Promise_, and returns an array of values
|
|
66
65
|
*/
|
|
67
66
|
export type PromiseStrategy = "complete" | "first";
|
|
68
|
-
/**
|
|
69
|
-
* An error thrown when a promise times out
|
|
70
|
-
*/
|
|
71
|
-
export declare class PromiseTimeoutError extends Error {
|
|
72
|
-
constructor();
|
|
73
|
-
}
|
|
74
67
|
export type PromisesItems<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]>; };
|
|
75
68
|
/**
|
|
76
69
|
* Options for handling multiple _Promises_
|
|
@@ -102,11 +95,17 @@ export type RejectedPromise = {
|
|
|
102
95
|
*/
|
|
103
96
|
reason: unknown;
|
|
104
97
|
};
|
|
98
|
+
/**
|
|
99
|
+
* An error thrown when a promise times out
|
|
100
|
+
*/
|
|
101
|
+
export declare class TimedError extends Error {
|
|
102
|
+
constructor();
|
|
103
|
+
}
|
|
105
104
|
export declare const PROMISE_ABORT_EVENT = "abort";
|
|
106
105
|
export declare const PROMISE_ABORT_OPTIONS: {
|
|
107
106
|
once: boolean;
|
|
108
107
|
};
|
|
109
|
-
export declare const PROMISE_ERROR_NAME = "
|
|
108
|
+
export declare const PROMISE_ERROR_NAME = "TimedError";
|
|
110
109
|
export declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
111
110
|
export declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
112
111
|
export declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
@@ -115,5 +114,4 @@ export declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
|
115
114
|
export declare const PROMISE_STRATEGY_ALL: Set<PromiseStrategy>;
|
|
116
115
|
export declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
|
|
117
116
|
export declare const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
118
|
-
export declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
119
|
-
//#endregion
|
|
117
|
+
export declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/models/promise.model.ts
|
|
2
2
|
/**
|
|
3
3
|
* A _Promise_ that can be canceled
|
|
4
4
|
*/
|
|
@@ -25,7 +25,7 @@ var CancelablePromise = class extends Promise {
|
|
|
25
25
|
/**
|
|
26
26
|
* An error thrown when a promise times out
|
|
27
27
|
*/
|
|
28
|
-
var
|
|
28
|
+
var TimedError = class extends Error {
|
|
29
29
|
constructor() {
|
|
30
30
|
super(PROMISE_MESSAGE_TIMEOUT);
|
|
31
31
|
this.name = PROMISE_ERROR_NAME;
|
|
@@ -33,7 +33,7 @@ var PromiseTimeoutError = class extends Error {
|
|
|
33
33
|
};
|
|
34
34
|
const PROMISE_ABORT_EVENT = "abort";
|
|
35
35
|
const PROMISE_ABORT_OPTIONS = { once: true };
|
|
36
|
-
const PROMISE_ERROR_NAME = "
|
|
36
|
+
const PROMISE_ERROR_NAME = "TimedError";
|
|
37
37
|
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
38
38
|
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
39
39
|
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
@@ -43,5 +43,4 @@ const PROMISE_STRATEGY_ALL = /* @__PURE__ */ new Set(["complete", "first"]);
|
|
|
43
43
|
const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
44
44
|
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
45
45
|
const PROMISE_TYPE_REJECTED = "rejected";
|
|
46
|
-
|
|
47
|
-
export { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, 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, PromiseTimeoutError };
|
|
46
|
+
export { CancelablePromise, PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, 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, TimedError };
|