@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
package/dist/plan/run.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { AsyncPlan, Plan,
|
|
1
|
+
import { AsyncPlan, Plan, PlannedReturned } from "../models/plan.model.mjs";
|
|
2
2
|
import { asyncAttemptRun, attemptRun } from "./result.mjs";
|
|
3
|
-
//#region src/plan/run.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Run an asynchronous generator to completion
|
|
6
5
|
*
|
|
@@ -9,7 +8,7 @@ import { asyncAttemptRun, attemptRun } from "./result.mjs";
|
|
|
9
8
|
* @param signal Optional abort signal
|
|
10
9
|
* @returns Result
|
|
11
10
|
*/
|
|
12
|
-
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<
|
|
11
|
+
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<PlannedReturned<Returned>>;
|
|
13
12
|
/**
|
|
14
13
|
* Run an asynchronous generator to completion
|
|
15
14
|
*
|
|
@@ -17,7 +16,7 @@ export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]
|
|
|
17
16
|
* @param signal Optional abort signal
|
|
18
17
|
* @returns Result
|
|
19
18
|
*/
|
|
20
|
-
export declare function asyncRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<
|
|
19
|
+
export declare function asyncRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<PlannedReturned<Returned>>;
|
|
21
20
|
/**
|
|
22
21
|
* Run an asynchronous plan to completion
|
|
23
22
|
*
|
|
@@ -26,7 +25,7 @@ export declare function asyncRun<Yielded, Returned>(generator: () => AsyncGenera
|
|
|
26
25
|
* @param signal Optional abort signal
|
|
27
26
|
* @returns Result
|
|
28
27
|
*/
|
|
29
|
-
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<
|
|
28
|
+
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<PlannedReturned<Returned>>;
|
|
30
29
|
/**
|
|
31
30
|
* Run an asynchronous plan to completion
|
|
32
31
|
*
|
|
@@ -34,7 +33,7 @@ export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]
|
|
|
34
33
|
* @param signal Optional abort signal
|
|
35
34
|
* @returns Result
|
|
36
35
|
*/
|
|
37
|
-
export declare function asyncRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<
|
|
36
|
+
export declare function asyncRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<PlannedReturned<Returned>>;
|
|
38
37
|
/**
|
|
39
38
|
* Run a generator to completion
|
|
40
39
|
*
|
|
@@ -42,7 +41,7 @@ export declare function asyncRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Ret
|
|
|
42
41
|
* @param parameters Parameters for starting the run
|
|
43
42
|
* @returns Result
|
|
44
43
|
*/
|
|
45
|
-
export declare function run<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters):
|
|
44
|
+
export declare function run<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters): PlannedReturned<Returned>;
|
|
46
45
|
/**
|
|
47
46
|
* Run a plan to completion
|
|
48
47
|
*
|
|
@@ -50,12 +49,11 @@ export declare function run<Yielded, Returned, Parameters extends unknown[]>(gen
|
|
|
50
49
|
* @param parameters Parameters for starting the run
|
|
51
50
|
* @returns Result
|
|
52
51
|
*/
|
|
53
|
-
export declare function run<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters):
|
|
52
|
+
export declare function run<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters): PlannedReturned<Returned>;
|
|
54
53
|
export declare namespace asyncRun {
|
|
55
54
|
export var attempt: typeof asyncAttemptRun;
|
|
56
55
|
}
|
|
57
56
|
export declare namespace run {
|
|
58
57
|
export var async: typeof asyncRun;
|
|
59
58
|
export var attempt: typeof attemptRun;
|
|
60
|
-
}
|
|
61
|
-
//#endregion
|
|
59
|
+
}
|
package/dist/plan/run.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PLAN_MESSAGE_RUN_INPUT, PLAN_SYMBOL } from "../models/plan.model.mjs";
|
|
2
1
|
import { asyncGenerate, generate } from "../internal/plan/plan.generate.mjs";
|
|
2
|
+
import { PLAN_MESSAGE_RUN_INPUT, PLAN_SYMBOL } from "../models/plan.model.mjs";
|
|
3
3
|
import { isAsyncGeneratorFunction, isAsyncPlan, isGeneratorFunction, isPlan } from "./is.mjs";
|
|
4
4
|
import { asyncAttemptRun, attemptRun } from "./result.mjs";
|
|
5
|
-
|
|
5
|
+
// src/plan/run.ts
|
|
6
6
|
function asyncRun(input, first, second) {
|
|
7
7
|
if (isAsyncPlan(input)) return asyncGenerate(input[PLAN_SYMBOL], false, first, second);
|
|
8
8
|
if (isAsyncGeneratorFunction(input)) return asyncGenerate(input, false, first, second);
|
|
@@ -16,5 +16,4 @@ function run(input, ...parameters) {
|
|
|
16
16
|
asyncRun.attempt = asyncAttemptRun;
|
|
17
17
|
run.async = asyncRun;
|
|
18
18
|
run.attempt = attemptRun;
|
|
19
|
-
//#endregion
|
|
20
19
|
export { asyncRun, run };
|
package/dist/plan/use.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AsyncStep, AsyncStepValue, Step, StepValue } from "../models/plan.model.mjs";
|
|
2
|
-
//#region src/plan/use.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Create an asynchronous step from a callback
|
|
5
4
|
*
|
|
@@ -32,5 +31,4 @@ export declare function use<Value>(callback: () => Value & StepValue<Value>): St
|
|
|
32
31
|
export declare function use<Value>(value: Value & StepValue<Value>): Step<Value>;
|
|
33
32
|
export declare namespace use {
|
|
34
33
|
export var async: typeof asyncUse;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
34
|
+
}
|
package/dist/plan/use.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { getGenerator } from "../internal/plan/index.mjs";
|
|
1
2
|
import { isError, isOk } from "../internal/result/misc.mjs";
|
|
2
3
|
import { PLAN_MESSAGE_USE_NESTED_FN, PLAN_MESSAGE_USE_SYNC_ASYNC, PLAN_STEP_ASYNC, PLAN_STEP_SYNC, PLAN_SYMBOL } from "../models/plan.model.mjs";
|
|
3
|
-
import { getGenerator } from "../internal/plan/index.mjs";
|
|
4
4
|
import { isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncPlan, isAsyncStep, isAsyncSuccess, isGenerator } from "./is.mjs";
|
|
5
5
|
import { fail } from "./misc.mjs";
|
|
6
|
-
|
|
6
|
+
// src/plan/use.ts
|
|
7
7
|
function AsyncStep(generator) {
|
|
8
8
|
this[PLAN_SYMBOL] = {
|
|
9
9
|
generator,
|
|
@@ -19,7 +19,10 @@ function Step(generator) {
|
|
|
19
19
|
}
|
|
20
20
|
Step.prototype[Symbol.iterator] = getGenerator;
|
|
21
21
|
function asyncUse(value) {
|
|
22
|
-
return new AsyncStep(
|
|
22
|
+
return new AsyncStep(getAsyncUseStep(value));
|
|
23
|
+
}
|
|
24
|
+
function getAsyncUseStep(value) {
|
|
25
|
+
return async function* () {
|
|
23
26
|
let actual = value;
|
|
24
27
|
if (typeof actual === "function") actual = actual();
|
|
25
28
|
actual = await actual;
|
|
@@ -36,11 +39,10 @@ function asyncUse(value) {
|
|
|
36
39
|
return;
|
|
37
40
|
}
|
|
38
41
|
return actual;
|
|
39
|
-
}
|
|
42
|
+
};
|
|
40
43
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
return new Step(function* () {
|
|
44
|
+
function getUseStep(value) {
|
|
45
|
+
return function* () {
|
|
44
46
|
let actual = value;
|
|
45
47
|
if (typeof actual === "function") {
|
|
46
48
|
actual = actual();
|
|
@@ -58,12 +60,15 @@ function use(value) {
|
|
|
58
60
|
return;
|
|
59
61
|
}
|
|
60
62
|
return actual;
|
|
61
|
-
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function use(value) {
|
|
66
|
+
validateUseInput(value, false);
|
|
67
|
+
return new Step(getUseStep(value));
|
|
62
68
|
}
|
|
63
69
|
function validateUseInput(value, resolved) {
|
|
64
70
|
if (value instanceof Promise || isAsyncFailure(value) || isAsyncGenerator(value) || isAsyncGeneratorFunction(value) || isAsyncPlan(value) || isAsyncStep(value) || isAsyncSuccess(value)) throw new Error(PLAN_MESSAGE_USE_SYNC_ASYNC);
|
|
65
71
|
if (resolved && typeof value === "function") throw new Error(PLAN_MESSAGE_USE_NESTED_FN);
|
|
66
72
|
}
|
|
67
73
|
use.async = asyncUse;
|
|
68
|
-
//#endregion
|
|
69
74
|
export { asyncUse, use };
|
package/dist/promise/delay.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PromiseOptions } from "../models/promise.model.mjs";
|
|
2
|
-
//#region src/promise/delay.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Create a delayed promise that resolves after a certain amount of time, or rejects if aborted
|
|
5
4
|
*
|
|
@@ -13,5 +12,4 @@ export declare function delay(options?: PromiseOptions): Promise<void>;
|
|
|
13
12
|
* @param time How long to wait for _(in milliseconds; defaults to `0`)_
|
|
14
13
|
* @returns Delayed promise
|
|
15
14
|
*/
|
|
16
|
-
export declare function delay(time?: number): Promise<void>;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function delay(time?: number): Promise<void>;
|
package/dist/promise/delay.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createAborter } from "../internal/aborter.mjs";
|
|
2
|
-
import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
|
|
3
2
|
import { getLimiter } from "../internal/function/limit.mjs";
|
|
3
|
+
import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
|
|
4
4
|
import { createPromiseOptions } from "./helpers.mjs";
|
|
5
5
|
import { settlePromise } from "./misc.mjs";
|
|
6
|
-
|
|
6
|
+
// src/promise/delay.ts
|
|
7
7
|
function delay(options) {
|
|
8
8
|
const { signal, time } = createPromiseOptions(options);
|
|
9
9
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
@@ -21,5 +21,4 @@ function delay(options) {
|
|
|
21
21
|
else limiter.run();
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
//#endregion
|
|
25
24
|
export { delay };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RequiredKeys } from "../models/index.mjs";
|
|
2
2
|
import { FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, PromisesValue, RejectedPromise } from "../models/promise.model.mjs";
|
|
3
|
-
//#region src/promise/helpers.d.ts
|
|
4
3
|
export declare function createPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, "time">;
|
|
5
4
|
export declare function createPromisesOptions(input: unknown): RequiredKeys<PromisesOptions, "strategy">;
|
|
6
5
|
export declare function getResultsFromPromises(promised: Array<PromisesValue<unknown>> | Record<string, PromisesValue<unknown>>): unknown;
|
|
@@ -18,5 +17,4 @@ export declare function isFulfilled<Value>(value: unknown): value is FulfilledPr
|
|
|
18
17
|
* @param value Value to check
|
|
19
18
|
* @returns `true` if the value is a rejected _Promise_ result, otherwise `false`
|
|
20
19
|
*/
|
|
21
|
-
export declare function isRejected(value: unknown): value is RejectedPromise;
|
|
22
|
-
//#endregion
|
|
20
|
+
export declare function isRejected(value: unknown): value is RejectedPromise;
|
package/dist/promise/helpers.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { getNumberOrDefault } from "../internal/defaults.mjs";
|
|
1
2
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
3
|
import { error, ok } from "../internal/result/misc.mjs";
|
|
3
|
-
import { getNumberOrDefault } from "../internal/defaults.mjs";
|
|
4
4
|
import { PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "../models/promise.model.mjs";
|
|
5
|
-
|
|
5
|
+
// src/promise/helpers.ts
|
|
6
6
|
function createPromiseOptions(input) {
|
|
7
7
|
if (typeof input === "number") return { time: getNumberOrDefault(input, 0) };
|
|
8
8
|
if (input instanceof AbortSignal) return {
|
|
@@ -62,5 +62,4 @@ function isPromiseResult(value, type) {
|
|
|
62
62
|
function isRejected(value) {
|
|
63
63
|
return isPromiseResult(value, PROMISE_TYPE_REJECTED);
|
|
64
64
|
}
|
|
65
|
-
//#endregion
|
|
66
65
|
export { createPromiseOptions, createPromisesOptions, getResultsFromPromises, getStrategyOrDefault, isFulfilled, isRejected };
|
package/dist/promise/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PlainObject } from "../models/index.mjs";
|
|
2
2
|
import { PromiseOptions, PromiseStrategy, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValues } from "../models/promise.model.mjs";
|
|
3
|
-
//#region src/promise/index.d.ts
|
|
4
3
|
type AttemptPromiseOptions = PromiseOptions | AbortSignal | number;
|
|
5
4
|
/**
|
|
6
5
|
* Wrap a _Promise_ with safety handlers
|
|
@@ -107,5 +106,4 @@ export declare function resultPromises<Items extends PlainObject>(items: Items,
|
|
|
107
106
|
export declare namespace promises {
|
|
108
107
|
export var result: typeof resultPromises;
|
|
109
108
|
}
|
|
110
|
-
//#endregion
|
|
111
109
|
export {};
|
package/dist/promise/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isArrayOrPlainObject } from "../internal/is.mjs";
|
|
2
1
|
import { createAborter } from "../internal/aborter.mjs";
|
|
2
|
+
import { isArrayOrPlainObject } from "../internal/is.mjs";
|
|
3
3
|
import { asyncAttempt } from "../internal/result/attempt.mjs";
|
|
4
4
|
import { PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "../models/promise.model.mjs";
|
|
5
5
|
import { createPromiseOptions, createPromisesOptions, getResultsFromPromises } from "./helpers.mjs";
|
|
6
6
|
import { handleResult, settlePromise } from "./misc.mjs";
|
|
7
7
|
import { getTimedPromise } from "./timed.mjs";
|
|
8
|
-
|
|
8
|
+
// src/promise/index.ts
|
|
9
9
|
async function attemptPromise(value, options) {
|
|
10
10
|
const isFunction = typeof value === "function";
|
|
11
11
|
if (!isFunction && !(value instanceof Promise)) throw new TypeError(PROMISE_MESSAGE_EXPECTATION_ATTEMPT);
|
|
@@ -15,13 +15,13 @@ async function attemptPromise(value, options) {
|
|
|
15
15
|
rejector(signal?.reason);
|
|
16
16
|
});
|
|
17
17
|
async function handler(resolve, reject) {
|
|
18
|
-
const
|
|
18
|
+
const attempted = await asyncAttempt(async () => {
|
|
19
19
|
let result = isFunction ? value() : await value;
|
|
20
20
|
if (result instanceof Promise) result = await result;
|
|
21
21
|
return result;
|
|
22
22
|
});
|
|
23
|
-
if (
|
|
24
|
-
else settlePromise(reject,
|
|
23
|
+
if (attempted.ok) settlePromise(resolve, attempted.value, aborter);
|
|
24
|
+
else settlePromise(reject, attempted.error, aborter);
|
|
25
25
|
}
|
|
26
26
|
let rejector;
|
|
27
27
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -75,5 +75,4 @@ async function resultPromises(items, signal) {
|
|
|
75
75
|
return promises(items, signal).then(getResultsFromPromises);
|
|
76
76
|
}
|
|
77
77
|
promises.result = resultPromises;
|
|
78
|
-
//#endregion
|
|
79
78
|
export { attemptPromise, promises, resultPromises };
|
package/dist/promise/misc.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Aborter } from "../models/aborter.model.mjs";
|
|
2
|
-
import { Result } from "../models/result.model.mjs";
|
|
3
2
|
import { CancelablePromise, PromiseParameters } from "../models/promise.model.mjs";
|
|
3
|
+
import { Result } from "../models/result.model.mjs";
|
|
4
4
|
import { toPromise } from "../result/misc.mjs";
|
|
5
5
|
import { isFulfilled, isRejected } from "./helpers.mjs";
|
|
6
|
-
//#region src/promise/misc.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Create a cancelable _Promise_
|
|
9
8
|
*
|
|
@@ -33,5 +32,4 @@ export declare function toResult<Value>(callback: () => Promise<Value>): Promise
|
|
|
33
32
|
* @returns Promised result
|
|
34
33
|
*/
|
|
35
34
|
export declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
|
|
36
|
-
//#endregion
|
|
37
35
|
export { toPromise as fromResult, isFulfilled, isRejected };
|
package/dist/promise/misc.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { error, ok } from "../internal/result/misc.mjs";
|
|
2
|
-
import { toPromise } from "../result/misc.mjs";
|
|
3
2
|
import { CancelablePromise, PROMISE_MESSAGE_EXPECTATION_RESULT } from "../models/promise.model.mjs";
|
|
3
|
+
import { toPromise } from "../result/misc.mjs";
|
|
4
4
|
import { isFulfilled, isRejected } from "./helpers.mjs";
|
|
5
|
-
|
|
5
|
+
// src/promise/misc.ts
|
|
6
6
|
/**
|
|
7
7
|
* Create a cancelable _Promise_
|
|
8
8
|
*
|
|
@@ -50,5 +50,4 @@ async function toResult(value) {
|
|
|
50
50
|
if (!(actual instanceof Promise)) throw new TypeError(PROMISE_MESSAGE_EXPECTATION_RESULT);
|
|
51
51
|
return actual.then((result) => ok(result)).catch((reason) => error(reason));
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { cancelable, toPromise as fromResult, handleResult, isFulfilled, isRejected, settlePromise, toResult };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CancelablePromise, FulfilledPromise, PromiseOptions, PromiseStrategy,
|
|
2
|
-
export { CancelablePromise, type FulfilledPromise, type PromiseOptions, type PromiseStrategy,
|
|
1
|
+
import { CancelablePromise, FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, RejectedPromise, TimedError } from "../models/promise.model.mjs";
|
|
2
|
+
export { CancelablePromise, type FulfilledPromise, type PromiseOptions, type PromiseStrategy, type PromisesOptions, type RejectedPromise, TimedError };
|
package/dist/promise/models.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { CancelablePromise,
|
|
1
|
+
export { CancelablePromise, TimedError } from "../models/promise.model.mjs";
|
package/dist/promise/timed.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RequiredKeys } from "../models/index.mjs";
|
|
2
2
|
import { PromiseOptions } from "../models/promise.model.mjs";
|
|
3
|
-
//#region src/promise/timed.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
@@ -20,5 +19,4 @@ export declare function timed<Value>(promise: Promise<Value>, options: RequiredK
|
|
|
20
19
|
* @param time How long to wait for _(in milliseconds; defaults to `0`)_
|
|
21
20
|
* @returns Timed _Promise_
|
|
22
21
|
*/
|
|
23
|
-
export declare function timed<Value>(promise: Promise<Value>, time: number): Promise<Value>;
|
|
24
|
-
//#endregion
|
|
22
|
+
export declare function timed<Value>(promise: Promise<Value>, time: number): Promise<Value>;
|
package/dist/promise/timed.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createAborter } from "../internal/aborter.mjs";
|
|
2
|
-
import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
|
|
3
2
|
import { getLimiter } from "../internal/function/limit.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { LIMITER_WAIT } from "../models/function/limiter.model.mjs";
|
|
4
|
+
import { PROMISE_MESSAGE_EXPECTATION_TIMED, TimedError } from "../models/promise.model.mjs";
|
|
5
5
|
import { createPromiseOptions } from "./helpers.mjs";
|
|
6
6
|
import { settlePromise } from "./misc.mjs";
|
|
7
|
-
|
|
7
|
+
// src/promise/timed.ts
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
@@ -13,7 +13,7 @@ async function getTimedPromise(promise, time, signal) {
|
|
|
13
13
|
limiter.cancel();
|
|
14
14
|
rejector(signal?.reason);
|
|
15
15
|
});
|
|
16
|
-
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new
|
|
16
|
+
const limiter = getLimiter(LIMITER_WAIT, () => settlePromise(rejector, new TimedError(), aborter), time);
|
|
17
17
|
let rejector;
|
|
18
18
|
return Promise.race([promise, new Promise((_, reject) => {
|
|
19
19
|
rejector = reject;
|
|
@@ -31,5 +31,4 @@ async function timed(promise, options) {
|
|
|
31
31
|
if (signal?.aborted ?? false) throw signal?.reason;
|
|
32
32
|
return time > 0 ? getTimedPromise(promise, time, signal) : promise;
|
|
33
33
|
}
|
|
34
|
-
//#endregion
|
|
35
34
|
export { getTimedPromise, timed };
|
package/dist/query.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PlainObject } from "./models/index.mjs";
|
|
2
|
-
//#region src/query.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Convert a query string to a plain _(nested)_ object
|
|
5
4
|
*
|
|
@@ -13,5 +12,4 @@ export declare function fromQuery(query: string): PlainObject;
|
|
|
13
12
|
* @param parameters Plain object to convert
|
|
14
13
|
* @returns Query string representation of the object
|
|
15
14
|
*/
|
|
16
|
-
export declare function toQuery(parameters: PlainObject): string;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function toQuery(parameters: PlainObject): string;
|
package/dist/query.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isPlainObject } from "./internal/is.mjs";
|
|
2
|
-
import { getString, ignoreKey, join, tryDecode, tryEncode } from "./internal/string/misc.mjs";
|
|
3
2
|
import { getNumber } from "./internal/number.mjs";
|
|
3
|
+
import { getString, ignoreKey, join, tryDecode, tryEncode } from "./internal/string/misc.mjs";
|
|
4
4
|
import { setValue } from "./internal/value/set.mjs";
|
|
5
5
|
import { QUERY_EXPRESSION_ARRAY_SUFFIX, QUERY_EXPRESSION_BOOLEAN, QUERY_TRUE, QUERY_TYPES } from "./models/query.model.mjs";
|
|
6
|
-
|
|
6
|
+
// src/query.ts
|
|
7
7
|
/**
|
|
8
8
|
* Convert a query string to a plain _(nested)_ object
|
|
9
9
|
*
|
|
@@ -73,5 +73,4 @@ function isDecodable(value) {
|
|
|
73
73
|
function toQuery(parameters) {
|
|
74
74
|
return isPlainObject(parameters) ? join(getParts(parameters, false).filter((part) => part.length > 0), "&") : "";
|
|
75
75
|
}
|
|
76
|
-
//#endregion
|
|
77
76
|
export { fromQuery, toQuery };
|
package/dist/queue.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericAsyncCallback, GenericCallback } from "./models/index.mjs";
|
|
2
2
|
import { KeyedQueue, Queue, QueueOptions, Queued } from "./models/queue.model.mjs";
|
|
3
|
-
//#region src/queue.d.ts
|
|
4
3
|
declare function KeyedQueue(this: any, callback: GenericAsyncCallback, options: Required<QueueOptions>): void;
|
|
5
4
|
declare function Queue(this: any, callback: GenericAsyncCallback, options: Required<QueueOptions>, key?: string): void;
|
|
6
5
|
/**
|
|
@@ -54,5 +53,4 @@ export declare function queue<Callback extends GenericCallback>(callback: Callba
|
|
|
54
53
|
export declare namespace queue {
|
|
55
54
|
export var keyed: typeof keyedQueue;
|
|
56
55
|
}
|
|
57
|
-
//#endregion
|
|
58
56
|
export type { KeyedQueue, Queue, QueueOptions, Queued };
|
package/dist/queue.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createAborter } from "./internal/aborter.mjs";
|
|
2
|
+
import { getBooleanOrDefault, getNumberOrDefault } from "./internal/defaults.mjs";
|
|
2
3
|
import { min } from "./internal/math/aggregate.mjs";
|
|
3
4
|
import { asyncAttempt } from "./internal/result/attempt.mjs";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
//#region src/queue.ts
|
|
5
|
+
import { QUEUE_HANDLE_CLEAR, QUEUE_HANDLE_PAUSE, QUEUE_HANDLE_RESUME, QUEUE_MESSAGE_CALLBACK, QUEUE_MESSAGE_CLEAR, QUEUE_MESSAGE_KEY, QUEUE_MESSAGE_MAXIMUM, QUEUE_MESSAGE_REMOVE, QUEUE_NAME_KEYED, QUEUE_NAME_QUEUE, QUEUE_STATUS_ACTIVE, QUEUE_STATUS_EMPTY, QUEUE_STATUS_FULL, QUEUE_STATUS_PAUSED, QUEUE_SYMBOL, QueueError } from "./models/queue.model.mjs";
|
|
6
|
+
// src/queue.ts
|
|
7
7
|
function KeyedQueue(callback, options) {
|
|
8
8
|
this[QUEUE_SYMBOL] = {
|
|
9
9
|
callback,
|
|
10
10
|
options: createQueueOptions(options),
|
|
11
|
-
queues: /* @__PURE__ */ new Map()
|
|
11
|
+
queues: /* @__PURE__ */ new Map(),
|
|
12
|
+
type: QUEUE_NAME_KEYED
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
|
-
KeyedQueue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_KEYED;
|
|
15
15
|
KeyedQueue.prototype.add = addKeyedQueue;
|
|
16
16
|
KeyedQueue.prototype.clear = clearQueues;
|
|
17
17
|
KeyedQueue.prototype.get = getQueue;
|
|
@@ -69,10 +69,10 @@ function Queue(callback, options, key) {
|
|
|
69
69
|
id: 0,
|
|
70
70
|
items: [],
|
|
71
71
|
paused: !options.autostart,
|
|
72
|
-
runners: 0
|
|
72
|
+
runners: 0,
|
|
73
|
+
type: QUEUE_NAME_QUEUE
|
|
73
74
|
};
|
|
74
75
|
}
|
|
75
|
-
Queue.prototype[QUEUE_PROPERTY] = QUEUE_NAME_QUEUE;
|
|
76
76
|
Queue.prototype.add = addToQueue;
|
|
77
77
|
Queue.prototype.clear = clearQueue;
|
|
78
78
|
Queue.prototype.pause = pauseQueue;
|
|
@@ -229,9 +229,9 @@ function getQueueSize() {
|
|
|
229
229
|
}
|
|
230
230
|
function getStatus(state, status) {
|
|
231
231
|
const queues = state.queues.entries();
|
|
232
|
-
const
|
|
233
|
-
for (const [key, queue] of queues) if (queue[status])
|
|
234
|
-
return
|
|
232
|
+
const queued = [];
|
|
233
|
+
for (const [key, queue] of queues) if (queue[status]) queued.push(key);
|
|
234
|
+
return queued;
|
|
235
235
|
}
|
|
236
236
|
function handleQueuedResult(item, error, result) {
|
|
237
237
|
item.aborter?.cancel();
|
|
@@ -276,7 +276,7 @@ function isQueue(value) {
|
|
|
276
276
|
return isQueueInstance(QUEUE_NAME_QUEUE, value);
|
|
277
277
|
}
|
|
278
278
|
function isQueueInstance(name, value) {
|
|
279
|
-
return typeof value === "object" && value != null &&
|
|
279
|
+
return typeof value === "object" && value != null && QUEUE_SYMBOL in value && value[QUEUE_SYMBOL].type === name;
|
|
280
280
|
}
|
|
281
281
|
function keyedQueue(callback, options) {
|
|
282
282
|
if (typeof callback !== "function") throw new TypeError(QUEUE_MESSAGE_CALLBACK);
|
|
@@ -359,5 +359,4 @@ async function run(state) {
|
|
|
359
359
|
state.runners -= 1;
|
|
360
360
|
}
|
|
361
361
|
queue.keyed = keyedQueue;
|
|
362
|
-
//#endregion
|
|
363
362
|
export { isKeyedQueue, isQueue, keyedQueue, queue };
|
package/dist/random.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { getRandom, getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
2
|
-
//#region src/random.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Get a random boolean
|
|
5
4
|
*
|
|
@@ -49,5 +48,4 @@ export declare function getRandomItems<Value>(array: Value[], amount: number): V
|
|
|
49
48
|
* @returns Shuffled version of the original array
|
|
50
49
|
*/
|
|
51
50
|
export declare function getRandomItems<Value>(array: Value[]): Value[];
|
|
52
|
-
//#endregion
|
|
53
51
|
export { getRandom, getRandomFloatingNumber as getRandomFloat, getRandomInteger };
|
package/dist/random.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getRandom, getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
2
1
|
import { shuffle } from "./internal/array/shuffle.mjs";
|
|
2
|
+
import { getRandom, getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
3
3
|
import { join } from "./internal/string/misc.mjs";
|
|
4
4
|
import { RANDOM_ALPHABET, RANDOM_BOOLEAN_MODIFIER, RANDOM_HEX_CHARACTERS } from "./models/random.model.mjs";
|
|
5
|
-
|
|
5
|
+
// src/random.ts
|
|
6
6
|
/**
|
|
7
7
|
* Get a random boolean
|
|
8
8
|
*
|
|
@@ -58,5 +58,4 @@ function getRandomItems(array, amount) {
|
|
|
58
58
|
if (amount === 1) return [array[getRandomInteger(0, array.length - 1)]];
|
|
59
59
|
return typeof amount !== "number" || amount <= 0 || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { getRandom, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
|
package/dist/result/match.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnyResult, ResultMatch } from "../models/result.model.mjs";
|
|
2
|
-
//#region src/result/match.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Handles a _Result_ with match callbacks
|
|
5
4
|
*
|
|
@@ -40,5 +39,4 @@ export declare function matchResult<Value, Returned, E = Error>(result: AnyResul
|
|
|
40
39
|
export declare function matchResult<Value, Returned, E = Error>(result: AnyResult<Value, E> | (() => AnyResult<Value, E>), ok: ResultMatch<Value, Returned, E>["ok"], error: ResultMatch<Value, Returned, E>["error"]): Returned;
|
|
41
40
|
export declare namespace matchResult {
|
|
42
41
|
export var async: typeof asyncMatchResult;
|
|
43
|
-
}
|
|
44
|
-
//#endregion
|
|
42
|
+
}
|
package/dist/result/match.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from "../internal/is.mjs";
|
|
2
2
|
import { isOk, isResult } from "../internal/result/misc.mjs";
|
|
3
|
-
|
|
3
|
+
// src/result/match.ts
|
|
4
4
|
async function asyncMatchResult(result, first, second) {
|
|
5
5
|
let value;
|
|
6
6
|
if (typeof result === "function") value = await result();
|
|
@@ -35,5 +35,4 @@ const MATCH_MESSAGE_ERROR = "`result.match` expected an Error callback";
|
|
|
35
35
|
const MATCH_MESSAGE_OK = "`result.match` expected an Ok callback";
|
|
36
36
|
const MATCH_MESSAGE_RESULT = "`result.match` expected a Result or a function that returns a Result";
|
|
37
37
|
matchResult.async = asyncMatchResult;
|
|
38
|
-
//#endregion
|
|
39
38
|
export { asyncMatchResult, matchResult };
|
package/dist/result/misc.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AnyResult } from "../models/result.model.mjs";
|
|
2
2
|
import { error, isError, isOk, isResult, ok, unwrap } from "../internal/result/misc.mjs";
|
|
3
|
-
//#region src/result/misc.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Converts a result to a _Promise_
|
|
6
5
|
*
|
|
@@ -19,5 +18,4 @@ export declare function toPromise<Value, E = Error>(callback: () => AnyResult<Va
|
|
|
19
18
|
* @returns Promised result
|
|
20
19
|
*/
|
|
21
20
|
export declare function toPromise<Value, E = Error>(result: AnyResult<Value, E>): Promise<Value>;
|
|
22
|
-
//#endregion
|
|
23
21
|
export { error, isError, isOk, isResult, ok, unwrap };
|
package/dist/result/misc.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error, isError, isOk, isResult, ok, unwrap } from "../internal/result/misc.mjs";
|
|
2
|
-
|
|
2
|
+
// src/result/misc.ts
|
|
3
3
|
async function toPromise(result) {
|
|
4
4
|
const actual = typeof result === "function" ? result() : result;
|
|
5
5
|
if (!isResult(actual)) throw new TypeError(RESULT_MESSAGE_PROMISE);
|
|
@@ -7,5 +7,4 @@ async function toPromise(result) {
|
|
|
7
7
|
throw actual.error;
|
|
8
8
|
}
|
|
9
9
|
const RESULT_MESSAGE_PROMISE = "toPromise expected to receive a Result";
|
|
10
|
-
//#endregion
|
|
11
10
|
export { error, isError, isOk, isResult, ok, toPromise, unwrap };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericCallback } from "../../models/index.mjs";
|
|
2
2
|
import { AttemptAsyncFlow, AttemptFlow, Result, UnwrapValue } from "../../models/result.model.mjs";
|
|
3
|
-
//#region src/result/work/flow.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Create an asynchronous _Flow_, a function that attempts to pipe a value through a series of functions
|
|
6
5
|
*
|
|
@@ -171,5 +170,4 @@ export declare function attemptFlow<First extends GenericCallback>(first: First,
|
|
|
171
170
|
export declare function attemptFlow(...fns: GenericCallback[]): (...args: unknown[]) => Result<unknown>;
|
|
172
171
|
export declare namespace attemptFlow {
|
|
173
172
|
export var async: typeof attemptAsyncFlow;
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
173
|
+
}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { asyncAttempt, attempt } from "../../internal/result/attempt.mjs";
|
|
1
|
+
import { unwrapWork } from "../../internal/function/misc.mjs";
|
|
3
2
|
import { asyncFlow, flow } from "../../internal/function/work.mjs";
|
|
4
|
-
|
|
3
|
+
import { asyncAttempt, attempt } from "../../internal/result/attempt.mjs";
|
|
4
|
+
// src/result/work/flow.ts
|
|
5
5
|
function attemptAsyncFlow(...fns) {
|
|
6
6
|
let Flow;
|
|
7
7
|
return (...args) => asyncAttempt(() => {
|
|
8
8
|
Flow ??= asyncFlow(...fns);
|
|
9
|
-
return Flow(...args.map(
|
|
10
|
-
if (isError(value)) throw value.error;
|
|
11
|
-
return isOk(value) ? value.value : value;
|
|
12
|
-
}));
|
|
9
|
+
return Flow(...args.map(unwrapWork));
|
|
13
10
|
});
|
|
14
11
|
}
|
|
15
12
|
function attemptFlow(...fns) {
|
|
16
13
|
let Flow;
|
|
17
14
|
return (...args) => attempt(() => {
|
|
18
15
|
Flow ??= flow(...fns);
|
|
19
|
-
return Flow(...args.map(
|
|
20
|
-
if (isError(value)) throw value.error;
|
|
21
|
-
return isOk(value) ? value.value : value;
|
|
22
|
-
}));
|
|
16
|
+
return Flow(...args.map(unwrapWork));
|
|
23
17
|
});
|
|
24
18
|
}
|
|
25
19
|
attemptFlow.async = attemptAsyncFlow;
|
|
26
|
-
//#endregion
|
|
27
20
|
export { attemptAsyncFlow, attemptFlow };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { GenericCallback } from "../../models/index.mjs";
|
|
2
2
|
import { Result, UnwrapValue } from "../../models/result.model.mjs";
|
|
3
|
-
//#region src/result/work/pipe.d.ts
|
|
4
3
|
type InitialAsyncPipeValue<Initial> = GenericCallback | Initial | Promise<Initial> | Result<Initial>;
|
|
5
4
|
type InitialPipeValue<Initial> = GenericCallback | Initial | Result<Initial>;
|
|
6
5
|
type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
@@ -183,5 +182,4 @@ export declare function attemptPipe<Initial>(initial: InitialPipeValue<Initial>,
|
|
|
183
182
|
export declare namespace attemptPipe {
|
|
184
183
|
export var async: typeof attemptAsyncPipe;
|
|
185
184
|
}
|
|
186
|
-
//#endregion
|
|
187
185
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { asyncPipe, pipe } from "../../internal/function/work.mjs";
|
|
1
2
|
import { isError, isOk } from "../../internal/result/misc.mjs";
|
|
2
3
|
import { asyncAttempt, attempt } from "../../internal/result/attempt.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/result/work/pipe.ts
|
|
4
|
+
// src/result/work/pipe.ts
|
|
5
5
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
6
6
|
return asyncAttempt(async () => {
|
|
7
7
|
if (isError(initial)) throw initial.error;
|
|
@@ -23,5 +23,4 @@ function attemptPipe(initial, first, ...seconds) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
attemptPipe.async = attemptAsyncPipe;
|
|
26
|
-
//#endregion
|
|
27
26
|
export { attemptAsyncPipe, attemptPipe };
|