@duplojs/utils 1.6.1 → 1.6.3
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/types/createTuple.d.ts +1 -1
- package/dist/clean/constraint/base.cjs +7 -0
- package/dist/clean/constraint/base.d.ts +26 -6
- package/dist/clean/constraint/base.mjs +7 -0
- package/dist/clean/constraint/cast.cjs +18 -0
- package/dist/clean/constraint/cast.d.ts +29 -0
- package/dist/clean/constraint/cast.mjs +16 -0
- package/dist/clean/constraint/defaultConstraint/number.cjs +2 -10
- package/dist/clean/constraint/defaultConstraint/number.d.ts +12 -37
- package/dist/clean/constraint/defaultConstraint/number.mjs +3 -10
- package/dist/clean/constraint/defaultConstraint/string.d.ts +9 -5
- package/dist/clean/constraint/index.d.ts +1 -0
- package/dist/clean/constraint/set.cjs +7 -1
- package/dist/clean/constraint/set.d.ts +25 -5
- package/dist/clean/constraint/set.mjs +7 -1
- package/dist/clean/entity/index.cjs +14 -4
- package/dist/clean/entity/index.d.ts +11 -1
- package/dist/clean/entity/index.mjs +15 -6
- package/dist/clean/index.cjs +5 -1
- package/dist/clean/index.d.ts +1 -0
- package/dist/clean/index.mjs +4 -2
- package/dist/clean/newType.cjs +6 -1
- package/dist/clean/newType.d.ts +20 -5
- package/dist/clean/newType.mjs +6 -1
- package/dist/clean/primitive/operations/equal.cjs +3 -0
- package/dist/clean/primitive/operations/equal.d.ts +2 -2
- package/dist/clean/primitive/operations/equal.mjs +3 -0
- package/dist/clean/toMapDataParser.cjs +52 -0
- package/dist/clean/toMapDataParser.d.ts +53 -0
- package/dist/clean/toMapDataParser.mjs +50 -0
- package/dist/common/asserts.cjs +12 -0
- package/dist/common/asserts.d.ts +26 -0
- package/dist/common/asserts.mjs +12 -1
- package/dist/common/callThen.cjs +14 -0
- package/dist/common/callThen.d.ts +35 -0
- package/dist/common/callThen.mjs +12 -0
- package/dist/common/index.d.ts +3 -0
- package/dist/common/printer.cjs +73 -0
- package/dist/common/printer.d.ts +139 -0
- package/dist/common/printer.mjs +73 -0
- package/dist/common/queue.cjs +90 -0
- package/dist/common/queue.d.ts +46 -0
- package/dist/common/queue.mjs +87 -0
- package/dist/common/types/and.d.ts +1 -2
- package/dist/common/types/or.d.ts +1 -2
- package/dist/dataParser/base.cjs +12 -35
- package/dist/dataParser/base.d.ts +6 -9
- package/dist/dataParser/base.mjs +8 -30
- package/dist/dataParser/error.cjs +39 -21
- package/dist/dataParser/error.d.ts +19 -19
- package/dist/dataParser/error.mjs +37 -18
- package/dist/dataParser/extended/index.cjs +3 -4
- package/dist/dataParser/extended/index.mjs +1 -1
- package/dist/dataParser/identifier.d.ts +6 -6
- package/dist/dataParser/index.cjs +3 -6
- package/dist/dataParser/index.mjs +2 -2
- package/dist/dataParser/parsers/array/checkers/max.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/max.mjs +4 -7
- package/dist/dataParser/parsers/array/checkers/min.cjs +3 -6
- package/dist/dataParser/parsers/array/checkers/min.mjs +4 -7
- package/dist/dataParser/parsers/array/index.cjs +8 -8
- package/dist/dataParser/parsers/array/index.mjs +4 -4
- package/dist/dataParser/parsers/bigint/checkers/max.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/min.cjs +2 -2
- package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/bigint/index.cjs +2 -2
- package/dist/dataParser/parsers/bigint/index.mjs +3 -3
- package/dist/dataParser/parsers/boolean.cjs +3 -3
- package/dist/dataParser/parsers/boolean.mjs +4 -4
- package/dist/dataParser/parsers/date.cjs +4 -4
- package/dist/dataParser/parsers/date.mjs +5 -5
- package/dist/dataParser/parsers/empty.cjs +2 -2
- package/dist/dataParser/parsers/empty.mjs +3 -3
- package/dist/dataParser/parsers/literal.cjs +2 -2
- package/dist/dataParser/parsers/literal.mjs +3 -3
- package/dist/dataParser/parsers/nil.cjs +2 -2
- package/dist/dataParser/parsers/nil.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/int.cjs +2 -2
- package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/number/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/number/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/number/index.cjs +2 -2
- package/dist/dataParser/parsers/number/index.mjs +3 -3
- package/dist/dataParser/parsers/object/index.cjs +8 -8
- package/dist/dataParser/parsers/object/index.mjs +4 -4
- package/dist/dataParser/parsers/pipe.cjs +25 -10
- package/dist/dataParser/parsers/pipe.mjs +22 -7
- package/dist/dataParser/parsers/record/index.cjs +18 -16
- package/dist/dataParser/parsers/record/index.mjs +8 -6
- package/dist/dataParser/parsers/recover.cjs +7 -6
- package/dist/dataParser/parsers/recover.mjs +2 -1
- package/dist/dataParser/parsers/refine.cjs +3 -1
- package/dist/dataParser/parsers/refine.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/email.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/string/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/string/checkers/regex.cjs +2 -2
- package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/url.cjs +4 -4
- package/dist/dataParser/parsers/string/checkers/url.mjs +5 -5
- package/dist/dataParser/parsers/string/index.cjs +2 -2
- package/dist/dataParser/parsers/string/index.mjs +3 -3
- package/dist/dataParser/parsers/templateLiteral/index.cjs +2 -2
- package/dist/dataParser/parsers/templateLiteral/index.mjs +3 -3
- package/dist/dataParser/parsers/time/checkers/max.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/max.mjs +4 -2
- package/dist/dataParser/parsers/time/checkers/min.cjs +3 -1
- package/dist/dataParser/parsers/time/checkers/min.mjs +4 -2
- package/dist/dataParser/parsers/time/index.cjs +4 -4
- package/dist/dataParser/parsers/time/index.mjs +5 -5
- package/dist/dataParser/parsers/transform.cjs +6 -6
- package/dist/dataParser/parsers/transform.d.ts +2 -2
- package/dist/dataParser/parsers/transform.mjs +4 -4
- package/dist/dataParser/parsers/tuple.cjs +14 -14
- package/dist/dataParser/parsers/tuple.mjs +4 -4
- package/dist/dataParser/parsers/union.cjs +26 -8
- package/dist/dataParser/parsers/union.mjs +26 -8
- package/dist/flow/calledByNext.cjs +13 -0
- package/dist/flow/calledByNext.d.ts +47 -0
- package/dist/flow/calledByNext.mjs +11 -0
- package/dist/flow/debounce.cjs +16 -0
- package/dist/flow/debounce.d.ts +63 -0
- package/dist/flow/debounce.mjs +14 -0
- package/dist/flow/exec.cjs +101 -0
- package/dist/flow/exec.d.ts +4 -3
- package/dist/flow/exec.mjs +101 -0
- package/dist/flow/index.cjs +28 -0
- package/dist/flow/index.d.ts +5 -0
- package/dist/flow/index.mjs +10 -1
- package/dist/flow/queue.cjs +19 -0
- package/dist/flow/queue.d.ts +47 -0
- package/dist/flow/queue.mjs +17 -0
- package/dist/flow/run.cjs +118 -0
- package/dist/flow/run.d.ts +6 -4
- package/dist/flow/run.mjs +113 -1
- package/dist/flow/theFlow/calledByNext.cjs +11 -0
- package/dist/flow/theFlow/calledByNext.d.ts +5 -0
- package/dist/flow/theFlow/calledByNext.mjs +8 -0
- package/dist/flow/theFlow/debounce.cjs +11 -0
- package/dist/flow/theFlow/debounce.d.ts +9 -0
- package/dist/flow/theFlow/debounce.mjs +8 -0
- package/dist/flow/theFlow/index.d.ts +11 -3
- package/dist/flow/theFlow/queue.cjs +11 -0
- package/dist/flow/theFlow/queue.d.ts +9 -0
- package/dist/flow/theFlow/queue.mjs +8 -0
- package/dist/flow/theFlow/throttling.cjs +11 -0
- package/dist/flow/theFlow/throttling.d.ts +10 -0
- package/dist/flow/theFlow/throttling.mjs +8 -0
- package/dist/flow/throttling.cjs +27 -0
- package/dist/flow/throttling.d.ts +60 -0
- package/dist/flow/throttling.mjs +25 -0
- package/dist/flow/toFunction.cjs +15 -0
- package/dist/flow/toFunction.d.ts +56 -0
- package/dist/flow/toFunction.mjs +13 -0
- package/dist/index.cjs +11 -0
- package/dist/index.mjs +4 -1
- package/dist/metadata.json +126 -0
- package/dist/number/types/isGreater.d.ts +26 -3
- package/dist/object/types/getPropsWithValue.d.ts +1 -1
- package/dist/object/types/getPropsWithValueExtends.d.ts +1 -1
- package/dist/string/length.d.ts +2 -2
- package/dist/string/types/split.d.ts +6 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { dataParserInit
|
|
2
|
-
import {
|
|
1
|
+
import { dataParserInit } from '../base.mjs';
|
|
2
|
+
import { setErrorPath, SymbolDataParserError, addIssue } from '../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../kind.mjs';
|
|
4
4
|
import { some } from '../../array/some.mjs';
|
|
5
5
|
import { createOverride } from '../../common/override.mjs';
|
|
@@ -15,22 +15,40 @@ function union(options, definition) {
|
|
|
15
15
|
options,
|
|
16
16
|
}, {
|
|
17
17
|
sync: (data, error, self) => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
const unionError = {
|
|
19
|
+
...error,
|
|
20
|
+
currentPath: [...error.currentPath],
|
|
21
|
+
issues: [],
|
|
22
|
+
};
|
|
23
|
+
const currentIndexPath = unionError.currentPath.length;
|
|
24
|
+
for (let index = 0; index < self.definition.options.length; index++) {
|
|
25
|
+
setErrorPath(unionError, `(option: ${index})`, currentIndexPath);
|
|
26
|
+
const dataParser = self.definition.options[index];
|
|
27
|
+
const result = dataParser.exec(data, unionError);
|
|
20
28
|
if (result !== SymbolDataParserError) {
|
|
21
29
|
return result;
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
|
-
|
|
32
|
+
error.issues.push(...unionError.issues);
|
|
33
|
+
return addIssue(error, "respect at least one union value", data, self.definition.errorMessage);
|
|
25
34
|
},
|
|
26
35
|
async: async (data, error, self) => {
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
const unionError = {
|
|
37
|
+
...error,
|
|
38
|
+
currentPath: [...error.currentPath],
|
|
39
|
+
issues: [],
|
|
40
|
+
};
|
|
41
|
+
const currentIndexPath = unionError.currentPath.length;
|
|
42
|
+
for (let index = 0; index < self.definition.options.length; index++) {
|
|
43
|
+
setErrorPath(unionError, `(option: ${index})`, currentIndexPath);
|
|
44
|
+
const dataParser = self.definition.options[index];
|
|
45
|
+
const result = await dataParser.asyncExec(data, unionError);
|
|
29
46
|
if (result !== SymbolDataParserError) {
|
|
30
47
|
return result;
|
|
31
48
|
}
|
|
32
49
|
}
|
|
33
|
-
|
|
50
|
+
error.issues.push(...unionError.issues);
|
|
51
|
+
return addIssue(error, "respect at least one union value", data, self.definition.errorMessage);
|
|
34
52
|
},
|
|
35
53
|
isAsynchronous: (self) => some(self.definition.options, (element) => element.isAsynchronous()),
|
|
36
54
|
}, union.overrideHandler);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var calledByNext$1 = require('./theFlow/calledByNext.cjs');
|
|
4
|
+
|
|
5
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
6
|
+
/**
|
|
7
|
+
* {@include flow/calledByNext/index.md}
|
|
8
|
+
*/
|
|
9
|
+
async function* calledByNext(theFunction) {
|
|
10
|
+
yield calledByNext$1.createCalledByNext(theFunction);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.calledByNext = calledByNext;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers a callback that the flow runner can execute before the next overlapping async run of the same flow continues.
|
|
3
|
+
*
|
|
4
|
+
* **Supported call styles:**
|
|
5
|
+
* - Classic: `calledByNext(theFunction)` -> yields a `called-by-next` effect
|
|
6
|
+
*
|
|
7
|
+
* `calledByNext` declares a side callback on the current flow execution.
|
|
8
|
+
* When the same async flow starts again while a previous callback is still registered, the runner executes the previous callback and replaces it with the new one.
|
|
9
|
+
* This helper is mainly useful for cross-run invalidation or deferred refresh logic tied to async flow re-entry.
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const loadUsersFlow = F.create(
|
|
13
|
+
* async function *(page: number) {
|
|
14
|
+
* const controller = new AbortController();
|
|
15
|
+
*
|
|
16
|
+
* yield *F.calledByNext(() => void controller.abort());
|
|
17
|
+
*
|
|
18
|
+
* const response = await fetch(
|
|
19
|
+
* `/api/users?page=${page}`,
|
|
20
|
+
* {
|
|
21
|
+
* signal: controller.signal,
|
|
22
|
+
* },
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* return response.json();
|
|
26
|
+
* },
|
|
27
|
+
* );
|
|
28
|
+
* const loadUsers = F.toFunction(loadUsersFlow);
|
|
29
|
+
*
|
|
30
|
+
* const firstRequest = loadUsers(1);
|
|
31
|
+
* const secondRequest = loadUsers(2);
|
|
32
|
+
* // The second call aborts the first pending fetch.
|
|
33
|
+
*
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* - `calledByNext` is only observable through the async flow runner behavior
|
|
38
|
+
* - Use a stable flow reference such as `F.create(...)` or `F.toFunction(...)` when you expect cross-run behavior
|
|
39
|
+
* - If the same flow execution yields `calledByNext(...)` multiple times, only the first yielded effect is applied by the runner
|
|
40
|
+
*
|
|
41
|
+
* @see [`F.run`](https://utils.duplojs.dev/en/v1/api/flow/run) For the runtime behavior that consumes this effect
|
|
42
|
+
* @see https://utils.duplojs.dev/en/v1/api/flow/calledByNext
|
|
43
|
+
*
|
|
44
|
+
* @namespace F
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export declare function calledByNext<GenericOutput extends unknown>(theFunction: () => GenericOutput): AsyncGenerator<import("./theFlow").CalledByNext<GenericOutput>, void, unknown>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCalledByNext } from './theFlow/calledByNext.mjs';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
4
|
+
/**
|
|
5
|
+
* {@include flow/calledByNext/index.md}
|
|
6
|
+
*/
|
|
7
|
+
async function* calledByNext(theFunction) {
|
|
8
|
+
yield createCalledByNext(theFunction);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { calledByNext };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var debounce$1 = require('./theFlow/debounce.cjs');
|
|
4
|
+
|
|
5
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
6
|
+
/**
|
|
7
|
+
* {@include flow/debounce/index.md}
|
|
8
|
+
*/
|
|
9
|
+
async function* debounce(time, params) {
|
|
10
|
+
yield debounce$1.createDebounce({
|
|
11
|
+
time,
|
|
12
|
+
returnValue: params?.returnValue,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.debounce = debounce;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delays a flow execution and cancels the previous run when a new one arrives before the delay ends.
|
|
3
|
+
*
|
|
4
|
+
* **Supported call styles:**
|
|
5
|
+
* - Classic: `debounce(time)` -> yields a debounce effect
|
|
6
|
+
* - Classic with options: `debounce(time, params)` -> yields a debounce effect with a fallback return value
|
|
7
|
+
*
|
|
8
|
+
* `debounce` lets the runner wait before continuing the current run of the same flow.
|
|
9
|
+
* If another run starts during that delay, the previous run is cancelled and can return `params.returnValue`.
|
|
10
|
+
* This makes it useful for search inputs, refresh triggers, or any async flow where only the latest call should continue.
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* const searchFlow = F.create(
|
|
14
|
+
* async function *(query: string) {
|
|
15
|
+
* yield *F.debounce(
|
|
16
|
+
* 300,
|
|
17
|
+
* { returnValue: "skipped" as const },
|
|
18
|
+
* );
|
|
19
|
+
* return Promise.resolve(query);
|
|
20
|
+
* },
|
|
21
|
+
* );
|
|
22
|
+
* const runSearch = F.toFunction(searchFlow);
|
|
23
|
+
*
|
|
24
|
+
* void runSearch("first"); // Promise<"first" | "skipped">
|
|
25
|
+
*
|
|
26
|
+
* void runSearch("second"); // Promise<"second" | "skipped">
|
|
27
|
+
*
|
|
28
|
+
* const refreshFlow = F.create(
|
|
29
|
+
* async function *(section: string) {
|
|
30
|
+
* yield *F.debounce(500);
|
|
31
|
+
* return Promise.resolve(section);
|
|
32
|
+
* },
|
|
33
|
+
* );
|
|
34
|
+
* const runRefresh = F.toFunction(refreshFlow);
|
|
35
|
+
* await runRefresh("users"); // Promise<"users" | undefined>
|
|
36
|
+
*
|
|
37
|
+
* const saveFlow = F.create(
|
|
38
|
+
* async function *(name: string) {
|
|
39
|
+
* yield *F.debounce(
|
|
40
|
+
* 200,
|
|
41
|
+
* { returnValue: "cancelled" as const },
|
|
42
|
+
* );
|
|
43
|
+
* return Promise.resolve(`saved:${name}` as const);
|
|
44
|
+
* },
|
|
45
|
+
* );
|
|
46
|
+
* const runSave = F.toFunction(saveFlow);
|
|
47
|
+
* await runSave("alice"); // Promise<`saved:${string}` | "cancelled">
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* - `debounce` is an async generator because the runner always waits before continuing the preserved run
|
|
52
|
+
* - Debounce state is attached to the flow reference, so examples should reuse the same created flow or wrapped function
|
|
53
|
+
* - If the same flow execution yields `debounce(...)` multiple times, only the first yielded effect is applied by the runner
|
|
54
|
+
*
|
|
55
|
+
* @see [`F.run`](https://utils.duplojs.dev/en/v1/api/flow/run) For the debounce behavior implemented by the runner
|
|
56
|
+
* @see https://utils.duplojs.dev/en/v1/api/flow/debounce
|
|
57
|
+
*
|
|
58
|
+
* @namespace F
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
export declare function debounce<GenericValue extends unknown = undefined>(time: number, params?: {
|
|
62
|
+
returnValue?: GenericValue;
|
|
63
|
+
}): AsyncGenerator<import("./theFlow").Debounce<GenericValue | undefined>, void, unknown>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createDebounce } from './theFlow/debounce.mjs';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
4
|
+
/**
|
|
5
|
+
* {@include flow/debounce/index.md}
|
|
6
|
+
*/
|
|
7
|
+
async function* debounce(time, params) {
|
|
8
|
+
yield createDebounce({
|
|
9
|
+
time,
|
|
10
|
+
returnValue: params?.returnValue,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { debounce };
|
package/dist/flow/exec.cjs
CHANGED
|
@@ -3,12 +3,19 @@
|
|
|
3
3
|
var index = require('./theFlow/index.cjs');
|
|
4
4
|
var defer = require('./theFlow/defer.cjs');
|
|
5
5
|
var finalizer = require('./theFlow/finalizer.cjs');
|
|
6
|
+
var run = require('./run.cjs');
|
|
6
7
|
var justExec = require('../common/justExec.cjs');
|
|
7
8
|
var _break = require('./theFlow/break.cjs');
|
|
8
9
|
var exit = require('./theFlow/exit.cjs');
|
|
9
10
|
var step = require('./theFlow/step.cjs');
|
|
10
11
|
var injection = require('./theFlow/injection.cjs');
|
|
11
12
|
var dependence = require('./theFlow/dependence.cjs');
|
|
13
|
+
var throttling = require('./theFlow/throttling.cjs');
|
|
14
|
+
var externalPromise = require('../common/externalPromise.cjs');
|
|
15
|
+
var calledByNext = require('./theFlow/calledByNext.cjs');
|
|
16
|
+
var queue = require('./theFlow/queue.cjs');
|
|
17
|
+
var queue$1 = require('../common/queue.cjs');
|
|
18
|
+
var debounce = require('./theFlow/debounce.cjs');
|
|
12
19
|
var forward = require('../common/forward.cjs');
|
|
13
20
|
|
|
14
21
|
/**
|
|
@@ -17,6 +24,10 @@ var forward = require('../common/forward.cjs');
|
|
|
17
24
|
function exec(theFlow, ...[params]) {
|
|
18
25
|
let result = undefined;
|
|
19
26
|
let deferFunctions = undefined;
|
|
27
|
+
let alreadyUseThrottling = undefined;
|
|
28
|
+
let alreadyUseDebounce = undefined;
|
|
29
|
+
let alreadyUseCalledByNext = undefined;
|
|
30
|
+
let alreadyUseQueue = undefined;
|
|
20
31
|
const generator = justExec.justExec(() => {
|
|
21
32
|
if (Symbol.asyncIterator in theFlow || Symbol.iterator in theFlow) {
|
|
22
33
|
return forward.forward(theFlow);
|
|
@@ -64,10 +75,90 @@ function exec(theFlow, ...[params]) {
|
|
|
64
75
|
injectionProperties.inject(params.dependencies[dependenceName]);
|
|
65
76
|
}
|
|
66
77
|
}
|
|
78
|
+
else if (throttling.throttlingKind.has(result.value)) {
|
|
79
|
+
if (alreadyUseThrottling) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
alreadyUseThrottling = true;
|
|
83
|
+
const { time, keepLast, returnValue } = throttling.throttlingKind.getValue(result.value);
|
|
84
|
+
const lastTime = run.throttlingLastTimeWeakStore.get(theFlow);
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
run.throttlingLastTimeWeakStore.set(theFlow, now);
|
|
87
|
+
if (typeof lastTime === "number" && (lastTime + time) > now) {
|
|
88
|
+
if (keepLast === true) {
|
|
89
|
+
const resumer = run.throttlingResumerWeakStore.get(theFlow);
|
|
90
|
+
resumer?.(false);
|
|
91
|
+
const externalPromise$1 = externalPromise.createExternalPromise();
|
|
92
|
+
run.throttlingResumerWeakStore.set(theFlow, externalPromise$1.resolve);
|
|
93
|
+
if (await externalPromise$1.promise) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
result = await generator.return(returnValue);
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
else if (keepLast === true) {
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
const resumer = run.throttlingResumerWeakStore.get(theFlow);
|
|
103
|
+
resumer?.(true);
|
|
104
|
+
}, time);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
else if (calledByNext.calledByNextKind.has(result.value)) {
|
|
108
|
+
if (alreadyUseCalledByNext) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
alreadyUseCalledByNext = calledByNext.calledByNextKind.getValue(result.value);
|
|
112
|
+
const lastFunction = run.calledByNextFunctionWeakStore.get(theFlow);
|
|
113
|
+
const lastResult = lastFunction?.();
|
|
114
|
+
if (lastResult instanceof Promise) {
|
|
115
|
+
await lastResult;
|
|
116
|
+
}
|
|
117
|
+
run.calledByNextFunctionWeakStore.set(theFlow, alreadyUseCalledByNext);
|
|
118
|
+
}
|
|
119
|
+
else if (queue.queueKind.has(result.value)) {
|
|
120
|
+
if (alreadyUseQueue) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
const { concurrency, injectResolver } = queue.queueKind.getValue(result.value);
|
|
124
|
+
let queue$2 = run.queuesWeakStore.get(theFlow);
|
|
125
|
+
if (queue$2 === undefined) {
|
|
126
|
+
queue$2 = queue$1.createQueue({ concurrency });
|
|
127
|
+
run.queuesWeakStore.set(theFlow, queue$2);
|
|
128
|
+
}
|
|
129
|
+
alreadyUseQueue = await queue$2.addExternal();
|
|
130
|
+
injectResolver(alreadyUseQueue);
|
|
131
|
+
}
|
|
132
|
+
else if (debounce.debounceKind.has(result.value)) {
|
|
133
|
+
if (alreadyUseDebounce) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
alreadyUseDebounce = true;
|
|
137
|
+
const { time, returnValue } = debounce.debounceKind.getValue(result.value);
|
|
138
|
+
const lastTimeout = run.debounceTimeoutIdWeakStore.get(theFlow);
|
|
139
|
+
clearTimeout(lastTimeout);
|
|
140
|
+
const lastResumer = run.debounceResumerWeakStore.get(theFlow);
|
|
141
|
+
lastResumer?.(false);
|
|
142
|
+
const externalPromise$1 = externalPromise.createExternalPromise();
|
|
143
|
+
run.debounceTimeoutIdWeakStore.set(theFlow, setTimeout(() => void externalPromise$1.resolve(true), time));
|
|
144
|
+
run.debounceResumerWeakStore.set(theFlow, externalPromise$1.resolve);
|
|
145
|
+
if (await externalPromise$1.promise) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
result = await generator.return(returnValue);
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
67
151
|
} while (true);
|
|
68
152
|
return result.value;
|
|
69
153
|
}
|
|
70
154
|
finally {
|
|
155
|
+
if (alreadyUseCalledByNext
|
|
156
|
+
&& run.calledByNextFunctionWeakStore.get(theFlow) === alreadyUseCalledByNext) {
|
|
157
|
+
run.calledByNextFunctionWeakStore.delete(theFlow);
|
|
158
|
+
}
|
|
159
|
+
if (alreadyUseQueue) {
|
|
160
|
+
alreadyUseQueue();
|
|
161
|
+
}
|
|
71
162
|
await generator.return(undefined);
|
|
72
163
|
if (deferFunctions) {
|
|
73
164
|
await Promise.all(deferFunctions.map(justExec.justExec));
|
|
@@ -110,6 +201,16 @@ function exec(theFlow, ...[params]) {
|
|
|
110
201
|
injectionProperties.inject(params.dependencies[dependenceName]);
|
|
111
202
|
}
|
|
112
203
|
}
|
|
204
|
+
else if (throttling.throttlingKind.has(result.value)) {
|
|
205
|
+
const { time, returnValue } = throttling.throttlingKind.getValue(result.value);
|
|
206
|
+
const lastTime = run.throttlingLastTimeWeakStore.get(theFlow);
|
|
207
|
+
const now = Date.now();
|
|
208
|
+
run.throttlingLastTimeWeakStore.set(theFlow, now);
|
|
209
|
+
if (typeof lastTime === "number" && (lastTime + time) > now) {
|
|
210
|
+
result = generator.return(returnValue);
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
113
214
|
} while (true);
|
|
114
215
|
return result.value;
|
|
115
216
|
}
|
package/dist/flow/exec.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type SimplifyTopLevel, type IsEqual, type IsExtends, type Or } from "../common";
|
|
2
|
-
import { type TheFlowGenerator, type TheFlow, type TheFlowFunction, type FlowInput, type WrapFlow, type Exit, type Break, type Injection, type Step, type FlowDependencies } from "./theFlow";
|
|
2
|
+
import { type TheFlowGenerator, type TheFlow, type TheFlowFunction, type FlowInput, type WrapFlow, type Exit, type Break, type Injection, type Step, type FlowDependencies, type Throttling, type Debounce } from "./theFlow";
|
|
3
|
+
import { type Defer } from "./theFlow/defer";
|
|
3
4
|
import { type Finalizer } from "./theFlow/finalizer";
|
|
4
5
|
type ComputeExecParams<GenericInput extends unknown, GenericDependencies extends Record<string, unknown>> = SimplifyTopLevel<(Or<[
|
|
5
6
|
IsEqual<GenericInput, unknown>,
|
|
@@ -13,7 +14,7 @@ type ComputeExecParams<GenericInput extends unknown, GenericDependencies extends
|
|
|
13
14
|
dependencies?: GenericDependencies;
|
|
14
15
|
}>;
|
|
15
16
|
export type ExecResult<GenericFlow extends TheFlow> = GenericFlow extends TheFlow<infer InferredFunction> ? InferredFunction extends TheFlowFunction<any, infer InferredGenerator> ? InferredGenerator extends TheFlowGenerator<infer InferredOutput, infer InferredEffect> ? [
|
|
16
|
-
((InferredEffect extends Break<infer InferredValue> ? InferredValue : never) | InferredOutput),
|
|
17
|
+
((InferredEffect extends Break<infer InferredValue> ? InferredValue : InferredEffect extends Throttling<infer InferredValue> ? InferredValue : InferredEffect extends Debounce<infer InferredValue> ? InferredValue : never) | InferredOutput),
|
|
17
18
|
Extract<InferredEffect, Exit | Injection | Finalizer | Step>
|
|
18
19
|
] extends [
|
|
19
20
|
infer InferredOutput,
|
|
@@ -79,5 +80,5 @@ export type ExecResult<GenericFlow extends TheFlow> = GenericFlow extends TheFlo
|
|
|
79
80
|
* @namespace F
|
|
80
81
|
*
|
|
81
82
|
*/
|
|
82
|
-
export declare function exec<GenericFlow extends (TheFlowFunction | TheFlow | TheFlowGenerator), GenericWrapFlow extends WrapFlow<GenericFlow>, const GenericParams extends ComputeExecParams<FlowInput<GenericWrapFlow>, FlowDependencies<GenericWrapFlow>>>(theFlow: GenericFlow, ...[params]: ({} extends GenericParams ? [params?: GenericParams] : [params: GenericParams])): ExecResult<WrapFlow<GenericFlow>>;
|
|
83
|
+
export declare function exec<GenericFlow extends (TheFlowFunction<any, TheFlowGenerator<unknown, Injection | Step | Exit | Break | Defer | Finalizer>> | TheFlow | TheFlowGenerator<unknown, Injection | Step | Exit | Break | Defer | Finalizer>), GenericWrapFlow extends WrapFlow<GenericFlow>, const GenericParams extends ComputeExecParams<FlowInput<GenericWrapFlow>, FlowDependencies<GenericWrapFlow>>>(theFlow: GenericFlow, ...[params]: ({} extends GenericParams ? [params?: GenericParams] : [params: GenericParams])): ExecResult<WrapFlow<GenericFlow>>;
|
|
83
84
|
export {};
|
package/dist/flow/exec.mjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { theFlowKind } from './theFlow/index.mjs';
|
|
2
2
|
import { deferKind } from './theFlow/defer.mjs';
|
|
3
3
|
import { finalizerKind } from './theFlow/finalizer.mjs';
|
|
4
|
+
import { throttlingLastTimeWeakStore, throttlingResumerWeakStore, calledByNextFunctionWeakStore, queuesWeakStore, debounceTimeoutIdWeakStore, debounceResumerWeakStore } from './run.mjs';
|
|
4
5
|
import { justExec } from '../common/justExec.mjs';
|
|
5
6
|
import { breakKind } from './theFlow/break.mjs';
|
|
6
7
|
import { exitKind } from './theFlow/exit.mjs';
|
|
7
8
|
import { stepKind } from './theFlow/step.mjs';
|
|
8
9
|
import { injectionKind } from './theFlow/injection.mjs';
|
|
9
10
|
import { dependenceHandlerKind } from './theFlow/dependence.mjs';
|
|
11
|
+
import { throttlingKind } from './theFlow/throttling.mjs';
|
|
12
|
+
import { createExternalPromise } from '../common/externalPromise.mjs';
|
|
13
|
+
import { calledByNextKind } from './theFlow/calledByNext.mjs';
|
|
14
|
+
import { queueKind } from './theFlow/queue.mjs';
|
|
15
|
+
import { createQueue } from '../common/queue.mjs';
|
|
16
|
+
import { debounceKind } from './theFlow/debounce.mjs';
|
|
10
17
|
import { forward } from '../common/forward.mjs';
|
|
11
18
|
|
|
12
19
|
/**
|
|
@@ -15,6 +22,10 @@ import { forward } from '../common/forward.mjs';
|
|
|
15
22
|
function exec(theFlow, ...[params]) {
|
|
16
23
|
let result = undefined;
|
|
17
24
|
let deferFunctions = undefined;
|
|
25
|
+
let alreadyUseThrottling = undefined;
|
|
26
|
+
let alreadyUseDebounce = undefined;
|
|
27
|
+
let alreadyUseCalledByNext = undefined;
|
|
28
|
+
let alreadyUseQueue = undefined;
|
|
18
29
|
const generator = justExec(() => {
|
|
19
30
|
if (Symbol.asyncIterator in theFlow || Symbol.iterator in theFlow) {
|
|
20
31
|
return forward(theFlow);
|
|
@@ -62,10 +73,90 @@ function exec(theFlow, ...[params]) {
|
|
|
62
73
|
injectionProperties.inject(params.dependencies[dependenceName]);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
76
|
+
else if (throttlingKind.has(result.value)) {
|
|
77
|
+
if (alreadyUseThrottling) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
alreadyUseThrottling = true;
|
|
81
|
+
const { time, keepLast, returnValue } = throttlingKind.getValue(result.value);
|
|
82
|
+
const lastTime = throttlingLastTimeWeakStore.get(theFlow);
|
|
83
|
+
const now = Date.now();
|
|
84
|
+
throttlingLastTimeWeakStore.set(theFlow, now);
|
|
85
|
+
if (typeof lastTime === "number" && (lastTime + time) > now) {
|
|
86
|
+
if (keepLast === true) {
|
|
87
|
+
const resumer = throttlingResumerWeakStore.get(theFlow);
|
|
88
|
+
resumer?.(false);
|
|
89
|
+
const externalPromise = createExternalPromise();
|
|
90
|
+
throttlingResumerWeakStore.set(theFlow, externalPromise.resolve);
|
|
91
|
+
if (await externalPromise.promise) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
result = await generator.return(returnValue);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
else if (keepLast === true) {
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
const resumer = throttlingResumerWeakStore.get(theFlow);
|
|
101
|
+
resumer?.(true);
|
|
102
|
+
}, time);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (calledByNextKind.has(result.value)) {
|
|
106
|
+
if (alreadyUseCalledByNext) {
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
alreadyUseCalledByNext = calledByNextKind.getValue(result.value);
|
|
110
|
+
const lastFunction = calledByNextFunctionWeakStore.get(theFlow);
|
|
111
|
+
const lastResult = lastFunction?.();
|
|
112
|
+
if (lastResult instanceof Promise) {
|
|
113
|
+
await lastResult;
|
|
114
|
+
}
|
|
115
|
+
calledByNextFunctionWeakStore.set(theFlow, alreadyUseCalledByNext);
|
|
116
|
+
}
|
|
117
|
+
else if (queueKind.has(result.value)) {
|
|
118
|
+
if (alreadyUseQueue) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const { concurrency, injectResolver } = queueKind.getValue(result.value);
|
|
122
|
+
let queue = queuesWeakStore.get(theFlow);
|
|
123
|
+
if (queue === undefined) {
|
|
124
|
+
queue = createQueue({ concurrency });
|
|
125
|
+
queuesWeakStore.set(theFlow, queue);
|
|
126
|
+
}
|
|
127
|
+
alreadyUseQueue = await queue.addExternal();
|
|
128
|
+
injectResolver(alreadyUseQueue);
|
|
129
|
+
}
|
|
130
|
+
else if (debounceKind.has(result.value)) {
|
|
131
|
+
if (alreadyUseDebounce) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
alreadyUseDebounce = true;
|
|
135
|
+
const { time, returnValue } = debounceKind.getValue(result.value);
|
|
136
|
+
const lastTimeout = debounceTimeoutIdWeakStore.get(theFlow);
|
|
137
|
+
clearTimeout(lastTimeout);
|
|
138
|
+
const lastResumer = debounceResumerWeakStore.get(theFlow);
|
|
139
|
+
lastResumer?.(false);
|
|
140
|
+
const externalPromise = createExternalPromise();
|
|
141
|
+
debounceTimeoutIdWeakStore.set(theFlow, setTimeout(() => void externalPromise.resolve(true), time));
|
|
142
|
+
debounceResumerWeakStore.set(theFlow, externalPromise.resolve);
|
|
143
|
+
if (await externalPromise.promise) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
result = await generator.return(returnValue);
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
65
149
|
} while (true);
|
|
66
150
|
return result.value;
|
|
67
151
|
}
|
|
68
152
|
finally {
|
|
153
|
+
if (alreadyUseCalledByNext
|
|
154
|
+
&& calledByNextFunctionWeakStore.get(theFlow) === alreadyUseCalledByNext) {
|
|
155
|
+
calledByNextFunctionWeakStore.delete(theFlow);
|
|
156
|
+
}
|
|
157
|
+
if (alreadyUseQueue) {
|
|
158
|
+
alreadyUseQueue();
|
|
159
|
+
}
|
|
69
160
|
await generator.return(undefined);
|
|
70
161
|
if (deferFunctions) {
|
|
71
162
|
await Promise.all(deferFunctions.map(justExec));
|
|
@@ -108,6 +199,16 @@ function exec(theFlow, ...[params]) {
|
|
|
108
199
|
injectionProperties.inject(params.dependencies[dependenceName]);
|
|
109
200
|
}
|
|
110
201
|
}
|
|
202
|
+
else if (throttlingKind.has(result.value)) {
|
|
203
|
+
const { time, returnValue } = throttlingKind.getValue(result.value);
|
|
204
|
+
const lastTime = throttlingLastTimeWeakStore.get(theFlow);
|
|
205
|
+
const now = Date.now();
|
|
206
|
+
throttlingLastTimeWeakStore.set(theFlow, now);
|
|
207
|
+
if (typeof lastTime === "number" && (lastTime + time) > now) {
|
|
208
|
+
result = generator.return(returnValue);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
111
212
|
} while (true);
|
|
112
213
|
return result.value;
|
|
113
214
|
}
|
package/dist/flow/index.cjs
CHANGED
|
@@ -11,6 +11,11 @@ var inject = require('./inject.cjs');
|
|
|
11
11
|
var step$1 = require('./step.cjs');
|
|
12
12
|
var initializer = require('./initializer.cjs');
|
|
13
13
|
var kind = require('./kind.cjs');
|
|
14
|
+
var calledByNext$1 = require('./calledByNext.cjs');
|
|
15
|
+
var queue$1 = require('./queue.cjs');
|
|
16
|
+
var throttling$1 = require('./throttling.cjs');
|
|
17
|
+
var toFunction = require('./toFunction.cjs');
|
|
18
|
+
var debounce$1 = require('./debounce.cjs');
|
|
14
19
|
var step = require('./theFlow/step.cjs');
|
|
15
20
|
var exit = require('./theFlow/exit.cjs');
|
|
16
21
|
var _break = require('./theFlow/break.cjs');
|
|
@@ -18,11 +23,21 @@ var injection = require('./theFlow/injection.cjs');
|
|
|
18
23
|
var defer = require('./theFlow/defer.cjs');
|
|
19
24
|
var finalizer = require('./theFlow/finalizer.cjs');
|
|
20
25
|
var dependence = require('./theFlow/dependence.cjs');
|
|
26
|
+
var throttling = require('./theFlow/throttling.cjs');
|
|
27
|
+
var calledByNext = require('./theFlow/calledByNext.cjs');
|
|
28
|
+
var queue = require('./theFlow/queue.cjs');
|
|
29
|
+
var debounce = require('./theFlow/debounce.cjs');
|
|
21
30
|
|
|
22
31
|
|
|
23
32
|
|
|
24
33
|
exports.MissingDependenceError = run.MissingDependenceError;
|
|
34
|
+
exports.calledByNextFunctionWeakStore = run.calledByNextFunctionWeakStore;
|
|
35
|
+
exports.debounceResumerWeakStore = run.debounceResumerWeakStore;
|
|
36
|
+
exports.debounceTimeoutIdWeakStore = run.debounceTimeoutIdWeakStore;
|
|
37
|
+
exports.queuesWeakStore = run.queuesWeakStore;
|
|
25
38
|
exports.run = run.run;
|
|
39
|
+
exports.throttlingLastTimeWeakStore = run.throttlingLastTimeWeakStore;
|
|
40
|
+
exports.throttlingResumerWeakStore = run.throttlingResumerWeakStore;
|
|
26
41
|
exports.create = index.create;
|
|
27
42
|
exports.theFlowKind = index.theFlowKind;
|
|
28
43
|
exports.breakIf = breakIf.breakIf;
|
|
@@ -34,6 +49,11 @@ exports.inject = inject.inject;
|
|
|
34
49
|
exports.step = step$1.step;
|
|
35
50
|
exports.createInitializer = initializer.createInitializer;
|
|
36
51
|
exports.createFlowKind = kind.createFlowKind;
|
|
52
|
+
exports.calledByNext = calledByNext$1.calledByNext;
|
|
53
|
+
exports.queue = queue$1.queue;
|
|
54
|
+
exports.throttling = throttling$1.throttling;
|
|
55
|
+
exports.toFunction = toFunction.toFunction;
|
|
56
|
+
exports.debounce = debounce$1.debounce;
|
|
37
57
|
exports.createStep = step.createStep;
|
|
38
58
|
exports.stepKind = step.stepKind;
|
|
39
59
|
exports.createExit = exit.createExit;
|
|
@@ -48,3 +68,11 @@ exports.createFinalizer = finalizer.createFinalizer;
|
|
|
48
68
|
exports.finalizerKind = finalizer.finalizerKind;
|
|
49
69
|
exports.createDependence = dependence.createDependence;
|
|
50
70
|
exports.dependenceHandlerKind = dependence.dependenceHandlerKind;
|
|
71
|
+
exports.createThrottling = throttling.createThrottling;
|
|
72
|
+
exports.throttlingKind = throttling.throttlingKind;
|
|
73
|
+
exports.calledByNextKind = calledByNext.calledByNextKind;
|
|
74
|
+
exports.createCalledByNext = calledByNext.createCalledByNext;
|
|
75
|
+
exports.createQueue = queue.createQueue;
|
|
76
|
+
exports.queueKind = queue.queueKind;
|
|
77
|
+
exports.createDebounce = debounce.createDebounce;
|
|
78
|
+
exports.debounceKind = debounce.debounceKind;
|
package/dist/flow/index.d.ts
CHANGED
|
@@ -10,3 +10,8 @@ export * from "./inject";
|
|
|
10
10
|
export * from "./step";
|
|
11
11
|
export * from "./initializer";
|
|
12
12
|
export * from "./kind";
|
|
13
|
+
export * from "./calledByNext";
|
|
14
|
+
export * from "./queue";
|
|
15
|
+
export * from "./throttling";
|
|
16
|
+
export * from "./toFunction";
|
|
17
|
+
export * from "./debounce";
|
package/dist/flow/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { MissingDependenceError, run } from './run.mjs';
|
|
1
|
+
export { MissingDependenceError, calledByNextFunctionWeakStore, debounceResumerWeakStore, debounceTimeoutIdWeakStore, queuesWeakStore, run, throttlingLastTimeWeakStore, throttlingResumerWeakStore } from './run.mjs';
|
|
2
2
|
export { create, theFlowKind } from './theFlow/index.mjs';
|
|
3
3
|
export { breakIf } from './breakIf.mjs';
|
|
4
4
|
export { defer } from './defer.mjs';
|
|
@@ -9,6 +9,11 @@ export { inject } from './inject.mjs';
|
|
|
9
9
|
export { step } from './step.mjs';
|
|
10
10
|
export { createInitializer } from './initializer.mjs';
|
|
11
11
|
export { createFlowKind } from './kind.mjs';
|
|
12
|
+
export { calledByNext } from './calledByNext.mjs';
|
|
13
|
+
export { queue } from './queue.mjs';
|
|
14
|
+
export { throttling } from './throttling.mjs';
|
|
15
|
+
export { toFunction } from './toFunction.mjs';
|
|
16
|
+
export { debounce } from './debounce.mjs';
|
|
12
17
|
export { createStep, stepKind } from './theFlow/step.mjs';
|
|
13
18
|
export { createExit, exitKind } from './theFlow/exit.mjs';
|
|
14
19
|
export { breakKind, createBreak } from './theFlow/break.mjs';
|
|
@@ -16,3 +21,7 @@ export { createInjection, injectionKind } from './theFlow/injection.mjs';
|
|
|
16
21
|
export { createDefer, deferKind } from './theFlow/defer.mjs';
|
|
17
22
|
export { createFinalizer, finalizerKind } from './theFlow/finalizer.mjs';
|
|
18
23
|
export { createDependence, dependenceHandlerKind } from './theFlow/dependence.mjs';
|
|
24
|
+
export { createThrottling, throttlingKind } from './theFlow/throttling.mjs';
|
|
25
|
+
export { calledByNextKind, createCalledByNext } from './theFlow/calledByNext.mjs';
|
|
26
|
+
export { createQueue, queueKind } from './theFlow/queue.mjs';
|
|
27
|
+
export { createDebounce, debounceKind } from './theFlow/debounce.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var queue$1 = require('./theFlow/queue.cjs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@include flow/queue/index.md}
|
|
7
|
+
*/
|
|
8
|
+
async function* queue(params) {
|
|
9
|
+
let resolver = undefined;
|
|
10
|
+
yield queue$1.createQueue({
|
|
11
|
+
concurrency: params?.concurrency ?? 1,
|
|
12
|
+
injectResolver: (injectResolver) => {
|
|
13
|
+
resolver = injectResolver;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return resolver;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
exports.queue = queue;
|