@modern-js/plugin 2.15.0 → 2.17.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/CHANGELOG.md +25 -0
- package/dist/cjs/farrow-pipeline/context.js +9 -27
- package/dist/cjs/farrow-pipeline/counter.js +7 -25
- package/dist/cjs/farrow-pipeline/index.js +25 -38
- package/dist/cjs/index.js +21 -20
- package/dist/cjs/manager/async.js +25 -41
- package/dist/cjs/manager/index.js +20 -19
- package/dist/cjs/manager/shared.js +16 -34
- package/dist/cjs/manager/sync.js +48 -60
- package/dist/cjs/manager/types.js +4 -15
- package/dist/cjs/waterfall/async.js +25 -34
- package/dist/cjs/waterfall/index.js +19 -18
- package/dist/cjs/waterfall/sync.js +24 -31
- package/dist/cjs/workflow/async.js +25 -33
- package/dist/cjs/workflow/index.js +20 -19
- package/dist/cjs/workflow/parallel.js +25 -33
- package/dist/cjs/workflow/sync.js +23 -29
- package/dist/esm/index.js +1123 -637
- package/dist/esm-node/farrow-pipeline/context.js +3 -6
- package/dist/esm-node/farrow-pipeline/counter.js +1 -4
- package/dist/esm-node/farrow-pipeline/index.js +11 -14
- package/dist/esm-node/manager/async.js +11 -18
- package/dist/esm-node/manager/shared.js +8 -17
- package/dist/esm-node/manager/sync.js +21 -42
- package/dist/esm-node/manager/types.js +1 -0
- package/dist/esm-node/waterfall/async.js +14 -16
- package/dist/esm-node/waterfall/sync.js +12 -10
- package/dist/esm-node/workflow/async.js +12 -13
- package/dist/esm-node/workflow/parallel.js +11 -10
- package/dist/esm-node/workflow/sync.js +10 -7
- package/package.json +10 -5
- package/dist/cjs/utils/pluginDagSort.js +0 -79
- package/dist/esm-node/utils/pluginDagSort.js +0 -56
- package/dist/types/utils/pluginDagSort.d.ts +0 -1
package/dist/cjs/manager/sync.js
CHANGED
@@ -1,33 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
6
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var sync_exports = {};
|
19
|
-
__export(sync_exports, {
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
20
13
|
DEFAULT_OPTIONS: () => DEFAULT_OPTIONS,
|
21
|
-
cloneHook: () => cloneHook,
|
22
|
-
cloneHooksMap: () => cloneHooksMap,
|
23
14
|
createManager: () => createManager,
|
24
|
-
generateRunner: () => generateRunner
|
15
|
+
generateRunner: () => generateRunner,
|
16
|
+
cloneHook: () => cloneHook,
|
17
|
+
cloneHooksMap: () => cloneHooksMap
|
25
18
|
});
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
var import_shared = require("./shared");
|
19
|
+
const _farrowpipeline = require("../farrow-pipeline");
|
20
|
+
const _waterfall = require("../waterfall");
|
21
|
+
const _workflow = require("../workflow");
|
22
|
+
const _shared = require("./shared");
|
31
23
|
const SYNC_PLUGIN_SYMBOL = "SYNC_PLUGIN_SYMBOL";
|
32
24
|
const DEFAULT_OPTIONS = {
|
33
25
|
name: "untitled",
|
@@ -41,7 +33,9 @@ const DEFAULT_OPTIONS = {
|
|
41
33
|
const createManager = (hooks, api) => {
|
42
34
|
let index = 0;
|
43
35
|
let runners;
|
44
|
-
let currentHooks = {
|
36
|
+
let currentHooks = {
|
37
|
+
...hooks
|
38
|
+
};
|
45
39
|
const useRunner = () => runners;
|
46
40
|
const registerHook = (extraHooks) => {
|
47
41
|
currentHooks = {
|
@@ -49,7 +43,7 @@ const createManager = (hooks, api) => {
|
|
49
43
|
...currentHooks
|
50
44
|
};
|
51
45
|
};
|
52
|
-
const isPlugin = (input) => (0,
|
46
|
+
const isPlugin = (input) => (0, _shared.isObject)(input) && (0, _shared.hasOwnProperty)(input, SYNC_PLUGIN_SYMBOL) && input[SYNC_PLUGIN_SYMBOL] === SYNC_PLUGIN_SYMBOL;
|
53
47
|
const pluginAPI = {
|
54
48
|
...api,
|
55
49
|
useHookRunners: useRunner
|
@@ -57,8 +51,10 @@ const createManager = (hooks, api) => {
|
|
57
51
|
const clone = (overrideAPI) => {
|
58
52
|
let plugins = [];
|
59
53
|
const addPlugin = (plugin) => {
|
60
|
-
if (!(0,
|
61
|
-
plugins.push({
|
54
|
+
if (!(0, _shared.includePlugin)(plugins, plugin)) {
|
55
|
+
plugins.push({
|
56
|
+
...plugin
|
57
|
+
});
|
62
58
|
}
|
63
59
|
};
|
64
60
|
const usePlugin = (...input) => {
|
@@ -68,7 +64,7 @@ const createManager = (hooks, api) => {
|
|
68
64
|
} else if (typeof plugin === "function") {
|
69
65
|
const options = plugin();
|
70
66
|
addPlugin(createPlugin(options.setup, options));
|
71
|
-
} else if ((0,
|
67
|
+
} else if ((0, _shared.isObject)(plugin)) {
|
72
68
|
addPlugin(createPlugin(plugin.setup, plugin));
|
73
69
|
} else if (process.env.NODE_ENV !== "production") {
|
74
70
|
console.warn(`Unknown plugin: ${JSON.stringify(plugin)}`);
|
@@ -78,8 +74,8 @@ const createManager = (hooks, api) => {
|
|
78
74
|
};
|
79
75
|
const createPlugin = (setup = () => {
|
80
76
|
}, options = {}) => {
|
81
|
-
var
|
82
|
-
if ((
|
77
|
+
var _options_usePlugins;
|
78
|
+
if ((_options_usePlugins = options.usePlugins) === null || _options_usePlugins === void 0 ? void 0 : _options_usePlugins.length) {
|
83
79
|
options.usePlugins.forEach((plugin) => {
|
84
80
|
usePlugin(createPlugin(plugin.setup, plugin));
|
85
81
|
});
|
@@ -99,15 +95,13 @@ const createManager = (hooks, api) => {
|
|
99
95
|
plugins = [];
|
100
96
|
};
|
101
97
|
const init = () => {
|
102
|
-
const sortedPlugins = (0,
|
98
|
+
const sortedPlugins = (0, _shared.sortPlugins)(plugins);
|
103
99
|
const mergedPluginAPI = {
|
104
100
|
...pluginAPI,
|
105
101
|
...overrideAPI
|
106
102
|
};
|
107
|
-
(0,
|
108
|
-
const hooksList = sortedPlugins.map(
|
109
|
-
(plugin) => plugin.setup(mergedPluginAPI)
|
110
|
-
);
|
103
|
+
(0, _shared.checkPlugins)(sortedPlugins);
|
104
|
+
const hooksList = sortedPlugins.map((plugin) => plugin.setup(mergedPluginAPI));
|
111
105
|
runners = generateRunner(hooksList, currentHooks);
|
112
106
|
return runners;
|
113
107
|
};
|
@@ -133,33 +127,35 @@ const generateRunner = (hooksList, hooksMap) => {
|
|
133
127
|
if (hooksMap) {
|
134
128
|
for (const key in cloneShape) {
|
135
129
|
hooksList.forEach((hooks) => {
|
136
|
-
if (hooks
|
130
|
+
if (hooks === null || hooks === void 0 ? void 0 : hooks[key]) {
|
137
131
|
cloneShape[key].use(hooks[key]);
|
138
132
|
}
|
139
133
|
});
|
140
|
-
runner[key] = (input, options) => cloneShape[key].run(input, {
|
134
|
+
runner[key] = (input, options) => cloneShape[key].run(input, {
|
135
|
+
...options
|
136
|
+
});
|
141
137
|
}
|
142
138
|
}
|
143
139
|
return runner;
|
144
140
|
};
|
145
141
|
const cloneHook = (hook) => {
|
146
|
-
if ((0,
|
147
|
-
return (0,
|
142
|
+
if ((0, _waterfall.isWaterfall)(hook)) {
|
143
|
+
return (0, _waterfall.createWaterfall)();
|
148
144
|
}
|
149
|
-
if ((0,
|
150
|
-
return (0,
|
145
|
+
if ((0, _waterfall.isAsyncWaterfall)(hook)) {
|
146
|
+
return (0, _waterfall.createAsyncWaterfall)();
|
151
147
|
}
|
152
|
-
if ((0,
|
153
|
-
return (0,
|
148
|
+
if ((0, _workflow.isWorkflow)(hook)) {
|
149
|
+
return (0, _workflow.createWorkflow)();
|
154
150
|
}
|
155
|
-
if ((0,
|
156
|
-
return (0,
|
151
|
+
if ((0, _workflow.isAsyncWorkflow)(hook)) {
|
152
|
+
return (0, _workflow.createAsyncWorkflow)();
|
157
153
|
}
|
158
|
-
if ((0,
|
159
|
-
return (0,
|
154
|
+
if ((0, _workflow.isParallelWorkflow)(hook)) {
|
155
|
+
return (0, _workflow.createParallelWorkflow)();
|
160
156
|
}
|
161
|
-
if ((0,
|
162
|
-
return (0,
|
157
|
+
if ((0, _farrowpipeline.isPipeline)(hook)) {
|
158
|
+
return (0, _farrowpipeline.createPipeline)();
|
163
159
|
}
|
164
160
|
throw new Error(`Unknown hook: ${hook}`);
|
165
161
|
};
|
@@ -173,11 +169,3 @@ const cloneHooksMap = (record) => {
|
|
173
169
|
}
|
174
170
|
return result;
|
175
171
|
};
|
176
|
-
// Annotate the CommonJS export names for ESM import in node:
|
177
|
-
0 && (module.exports = {
|
178
|
-
DEFAULT_OPTIONS,
|
179
|
-
cloneHook,
|
180
|
-
cloneHooksMap,
|
181
|
-
createManager,
|
182
|
-
generateRunner
|
183
|
-
});
|
@@ -1,15 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
-
for (let key of __getOwnPropNames(from))
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
-
}
|
11
|
-
return to;
|
12
|
-
};
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
-
var types_exports = {};
|
15
|
-
module.exports = __toCommonJS(types_exports);
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
@@ -1,28 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
6
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var async_exports = {};
|
19
|
-
__export(async_exports, {
|
20
|
-
createAsyncWaterfall: () => createAsyncWaterfall,
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
21
13
|
getAsyncBrook: () => getAsyncBrook,
|
14
|
+
createAsyncWaterfall: () => createAsyncWaterfall,
|
22
15
|
isAsyncWaterfall: () => isAsyncWaterfall
|
23
16
|
});
|
24
|
-
|
25
|
-
var import_farrow_pipeline = require("../farrow-pipeline");
|
17
|
+
const _farrowpipeline = require("../farrow-pipeline");
|
26
18
|
const ASYNC_WATERFALL_SYMBOL = Symbol.for("MODERN_ASYNC_WATERFALL");
|
27
19
|
const getAsyncBrook = (input) => {
|
28
20
|
if (typeof input === "function") {
|
@@ -34,16 +26,19 @@ const getAsyncBrook = (input) => {
|
|
34
26
|
throw new Error(`${input} is not a AsyncBrook or { brook: AsyncBrook }`);
|
35
27
|
};
|
36
28
|
const createAsyncWaterfall = () => {
|
37
|
-
const pipeline = (0,
|
29
|
+
const pipeline = (0, _farrowpipeline.createAsyncPipeline)();
|
38
30
|
const use = (...input) => {
|
39
|
-
pipeline.use(
|
40
|
-
...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware)
|
41
|
-
);
|
31
|
+
pipeline.use(...input.map(getAsyncBrook).map(mapAsyncBrookToAsyncMiddleware));
|
42
32
|
return waterfall;
|
43
33
|
};
|
44
|
-
const run = (input, options) => pipeline.run(input, {
|
34
|
+
const run = (input, options) => pipeline.run(input, {
|
35
|
+
...options,
|
36
|
+
onLast: (input2) => input2
|
37
|
+
});
|
45
38
|
const middleware = (input) => {
|
46
|
-
return pipeline.run(input, {
|
39
|
+
return pipeline.run(input, {
|
40
|
+
onLast: (input2) => input2
|
41
|
+
});
|
47
42
|
};
|
48
43
|
const waterfall = {
|
49
44
|
...pipeline,
|
@@ -54,11 +49,7 @@ const createAsyncWaterfall = () => {
|
|
54
49
|
};
|
55
50
|
return waterfall;
|
56
51
|
};
|
57
|
-
const isAsyncWaterfall = (input) =>
|
52
|
+
const isAsyncWaterfall = (input) => {
|
53
|
+
return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WATERFALL_SYMBOL]);
|
54
|
+
};
|
58
55
|
const mapAsyncBrookToAsyncMiddleware = (brook) => (input, next) => Promise.resolve(brook(input)).then((result) => next(result));
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
60
|
-
0 && (module.exports = {
|
61
|
-
createAsyncWaterfall,
|
62
|
-
getAsyncBrook,
|
63
|
-
isAsyncWaterfall
|
64
|
-
});
|
@@ -1,18 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
_export_star(require("./sync"), exports);
|
6
|
+
_export_star(require("./async"), exports);
|
7
|
+
function _export_star(from, to) {
|
8
|
+
Object.keys(from).forEach(function(k) {
|
9
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
10
|
+
Object.defineProperty(to, k, {
|
11
|
+
enumerable: true,
|
12
|
+
get: function() {
|
13
|
+
return from[k];
|
14
|
+
}
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
return from;
|
19
|
+
}
|
@@ -1,28 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
6
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
-
}
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var sync_exports = {};
|
19
|
-
__export(sync_exports, {
|
20
|
-
createWaterfall: () => createWaterfall,
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
21
13
|
getBrook: () => getBrook,
|
14
|
+
createWaterfall: () => createWaterfall,
|
22
15
|
isWaterfall: () => isWaterfall
|
23
16
|
});
|
24
|
-
|
25
|
-
var import_farrow_pipeline = require("../farrow-pipeline");
|
17
|
+
const _farrowpipeline = require("../farrow-pipeline");
|
26
18
|
const WATERFALL_SYMBOL = Symbol.for("MODERN_WATERFALL");
|
27
19
|
const getBrook = (input) => {
|
28
20
|
if (typeof input === "function") {
|
@@ -33,14 +25,19 @@ const getBrook = (input) => {
|
|
33
25
|
throw new Error(`${input} is not a Brook or { brook: Brook }`);
|
34
26
|
};
|
35
27
|
const createWaterfall = () => {
|
36
|
-
const pipeline = (0,
|
28
|
+
const pipeline = (0, _farrowpipeline.createPipeline)();
|
37
29
|
const use = (...brooks) => {
|
38
30
|
pipeline.use(...brooks.map(getBrook).map(mapBrookToMiddleware));
|
39
31
|
return waterfall;
|
40
32
|
};
|
41
|
-
const run = (input, options) => pipeline.run(input, {
|
33
|
+
const run = (input, options) => pipeline.run(input, {
|
34
|
+
...options,
|
35
|
+
onLast: (input2) => input2
|
36
|
+
});
|
42
37
|
const middleware = (input) => {
|
43
|
-
return pipeline.run(input, {
|
38
|
+
return pipeline.run(input, {
|
39
|
+
onLast: (input2) => input2
|
40
|
+
});
|
44
41
|
};
|
45
42
|
const waterfall = {
|
46
43
|
...pipeline,
|
@@ -51,11 +48,7 @@ const createWaterfall = () => {
|
|
51
48
|
};
|
52
49
|
return waterfall;
|
53
50
|
};
|
54
|
-
const isWaterfall = (input) =>
|
51
|
+
const isWaterfall = (input) => {
|
52
|
+
return Boolean(input === null || input === void 0 ? void 0 : input[WATERFALL_SYMBOL]);
|
53
|
+
};
|
55
54
|
const mapBrookToMiddleware = (brook) => (input, next) => next(brook(input));
|
56
|
-
// Annotate the CommonJS export names for ESM import in node:
|
57
|
-
0 && (module.exports = {
|
58
|
-
createWaterfall,
|
59
|
-
getBrook,
|
60
|
-
isWaterfall
|
61
|
-
});
|
@@ -1,37 +1,33 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
6
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var async_exports = {};
|
19
|
-
__export(async_exports, {
|
20
|
-
createAsyncWorkflow: () => createAsyncWorkflow,
|
21
|
-
isAsyncWorkflow: () => isAsyncWorkflow
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
13
|
+
isAsyncWorkflow: () => isAsyncWorkflow,
|
14
|
+
createAsyncWorkflow: () => createAsyncWorkflow
|
22
15
|
});
|
23
|
-
|
24
|
-
var import_farrow_pipeline = require("../farrow-pipeline");
|
16
|
+
const _farrowpipeline = require("../farrow-pipeline");
|
25
17
|
const ASYNC_WORKFLOW_SYMBOL = Symbol.for("MODERN_ASYNC_WORKFLOW");
|
26
|
-
const isAsyncWorkflow = (input) =>
|
18
|
+
const isAsyncWorkflow = (input) => {
|
19
|
+
return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
|
20
|
+
};
|
27
21
|
const createAsyncWorkflow = () => {
|
28
|
-
const pipeline = (0,
|
22
|
+
const pipeline = (0, _farrowpipeline.createAsyncPipeline)();
|
29
23
|
const use = (...input) => {
|
30
24
|
pipeline.use(...input.map(mapAsyncWorkerToAsyncMiddleware));
|
31
25
|
return workflow;
|
32
26
|
};
|
33
27
|
const run = (input) => {
|
34
|
-
const result = pipeline.run(input, {
|
28
|
+
const result = pipeline.run(input, {
|
29
|
+
onLast: () => []
|
30
|
+
});
|
35
31
|
if (isPromise(result)) {
|
36
32
|
return result.then((result2) => result2.filter(Boolean));
|
37
33
|
}
|
@@ -45,14 +41,10 @@ const createAsyncWorkflow = () => {
|
|
45
41
|
};
|
46
42
|
return workflow;
|
47
43
|
};
|
48
|
-
const mapAsyncWorkerToAsyncMiddleware = (worker) => (input, next) => Promise.resolve(worker(input)).then(
|
49
|
-
|
50
|
-
|
44
|
+
const mapAsyncWorkerToAsyncMiddleware = (worker) => (input, next) => Promise.resolve(worker(input)).then((result) => Promise.resolve(next(input)).then((nextResult) => [
|
45
|
+
result,
|
46
|
+
...nextResult
|
47
|
+
]));
|
51
48
|
function isPromise(obj) {
|
52
49
|
return obj && typeof obj.then === "function";
|
53
50
|
}
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
55
|
-
0 && (module.exports = {
|
56
|
-
createAsyncWorkflow,
|
57
|
-
isAsyncWorkflow
|
58
|
-
});
|
@@ -1,19 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
_export_star(require("./sync"), exports);
|
6
|
+
_export_star(require("./parallel"), exports);
|
7
|
+
_export_star(require("./async"), exports);
|
8
|
+
function _export_star(from, to) {
|
9
|
+
Object.keys(from).forEach(function(k) {
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
11
|
+
Object.defineProperty(to, k, {
|
12
|
+
enumerable: true,
|
13
|
+
get: function() {
|
14
|
+
return from[k];
|
15
|
+
}
|
16
|
+
});
|
17
|
+
}
|
18
|
+
});
|
19
|
+
return from;
|
20
|
+
}
|
@@ -1,38 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
function _export(target, all) {
|
6
6
|
for (var name in all)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
return to;
|
16
|
-
};
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
-
var parallel_exports = {};
|
19
|
-
__export(parallel_exports, {
|
20
|
-
createParallelWorkflow: () => createParallelWorkflow,
|
21
|
-
isParallelWorkflow: () => isParallelWorkflow
|
7
|
+
Object.defineProperty(target, name, {
|
8
|
+
enumerable: true,
|
9
|
+
get: all[name]
|
10
|
+
});
|
11
|
+
}
|
12
|
+
_export(exports, {
|
13
|
+
isParallelWorkflow: () => isParallelWorkflow,
|
14
|
+
createParallelWorkflow: () => createParallelWorkflow
|
22
15
|
});
|
23
|
-
|
24
|
-
var import_farrow_pipeline = require("../farrow-pipeline");
|
16
|
+
const _farrowpipeline = require("../farrow-pipeline");
|
25
17
|
const PARALLEL_WORKFLOW_SYMBOL = Symbol.for("MODERN_PARALLEL_WORKFLOW");
|
26
|
-
const isParallelWorkflow = (input) =>
|
18
|
+
const isParallelWorkflow = (input) => {
|
19
|
+
return Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
|
20
|
+
};
|
27
21
|
const createParallelWorkflow = () => {
|
28
|
-
const pipeline = (0,
|
22
|
+
const pipeline = (0, _farrowpipeline.createPipeline)();
|
29
23
|
const use = (...input) => {
|
30
24
|
pipeline.use(...input.map(mapParallelWorkerToAsyncMiddleware));
|
31
25
|
return workflow;
|
32
26
|
};
|
33
|
-
const run = (input) => Promise.all(pipeline.run(input, {
|
34
|
-
(
|
35
|
-
);
|
27
|
+
const run = (input) => Promise.all(pipeline.run(input, {
|
28
|
+
onLast: () => []
|
29
|
+
})).then((result) => result.filter(Boolean));
|
36
30
|
const workflow = {
|
37
31
|
...pipeline,
|
38
32
|
run,
|
@@ -41,9 +35,7 @@ const createParallelWorkflow = () => {
|
|
41
35
|
};
|
42
36
|
return workflow;
|
43
37
|
};
|
44
|
-
const mapParallelWorkerToAsyncMiddleware = (worker) => (input, next) => [
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
isParallelWorkflow
|
49
|
-
});
|
38
|
+
const mapParallelWorkerToAsyncMiddleware = (worker) => (input, next) => [
|
39
|
+
worker(input),
|
40
|
+
...next(input)
|
41
|
+
];
|