@modern-js/plugin 2.0.0-beta.2 → 2.0.0-beta.4

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/js/modern/farrow-pipeline/context.js +8 -10
  3. package/dist/js/modern/farrow-pipeline/counter.js +6 -8
  4. package/dist/js/modern/farrow-pipeline/index.js +1 -5
  5. package/dist/js/modern/farrow-pipeline/pipeline.js +37 -21
  6. package/dist/js/modern/index.js +1 -1
  7. package/dist/js/modern/manager/async.js +77 -38
  8. package/dist/js/modern/manager/index.js +1 -1
  9. package/dist/js/modern/manager/shared.js +20 -11
  10. package/dist/js/modern/manager/sync.js +80 -49
  11. package/dist/js/modern/utils/pluginDagSort.js +28 -21
  12. package/dist/js/modern/waterfall/async.js +63 -20
  13. package/dist/js/modern/waterfall/index.js +1 -1
  14. package/dist/js/modern/waterfall/sync.js +35 -18
  15. package/dist/js/modern/workflow/async.js +59 -17
  16. package/dist/js/modern/workflow/index.js +1 -1
  17. package/dist/js/modern/workflow/parallel.js +53 -11
  18. package/dist/js/modern/workflow/sync.js +30 -12
  19. package/dist/js/node/farrow-pipeline/context.js +25 -15
  20. package/dist/js/node/farrow-pipeline/counter.js +23 -13
  21. package/dist/js/node/farrow-pipeline/index.js +17 -16
  22. package/dist/js/node/farrow-pipeline/pipeline.js +54 -30
  23. package/dist/js/node/index.js +20 -49
  24. package/dist/js/node/manager/async.js +92 -47
  25. package/dist/js/node/manager/index.js +19 -38
  26. package/dist/js/node/manager/shared.js +38 -21
  27. package/dist/js/node/manager/sync.js +92 -71
  28. package/dist/js/node/utils/pluginDagSort.js +45 -26
  29. package/dist/js/node/waterfall/async.js +79 -28
  30. package/dist/js/node/waterfall/index.js +18 -27
  31. package/dist/js/node/waterfall/sync.js +54 -27
  32. package/dist/js/node/workflow/async.js +75 -24
  33. package/dist/js/node/workflow/index.js +19 -38
  34. package/dist/js/node/workflow/parallel.js +72 -19
  35. package/dist/js/node/workflow/sync.js +49 -20
  36. package/dist/js/treeshaking/farrow-pipeline/context.js +30 -34
  37. package/dist/js/treeshaking/farrow-pipeline/counter.js +16 -20
  38. package/dist/js/treeshaking/farrow-pipeline/index.js +1 -5
  39. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +106 -59
  40. package/dist/js/treeshaking/index.js +1 -1
  41. package/dist/js/treeshaking/manager/async.js +297 -115
  42. package/dist/js/treeshaking/manager/index.js +1 -1
  43. package/dist/js/treeshaking/manager/shared.js +29 -29
  44. package/dist/js/treeshaking/manager/sync.js +213 -168
  45. package/dist/js/treeshaking/manager/types.js +1 -0
  46. package/dist/js/treeshaking/utils/pluginDagSort.js +67 -72
  47. package/dist/js/treeshaking/waterfall/async.js +266 -68
  48. package/dist/js/treeshaking/waterfall/index.js +1 -1
  49. package/dist/js/treeshaking/waterfall/sync.js +122 -46
  50. package/dist/js/treeshaking/workflow/async.js +285 -84
  51. package/dist/js/treeshaking/workflow/index.js +1 -1
  52. package/dist/js/treeshaking/workflow/parallel.js +244 -49
  53. package/dist/js/treeshaking/workflow/sync.js +110 -32
  54. package/dist/types/manager/async.d.ts +9 -0
  55. package/dist/types/manager/sync.d.ts +9 -0
  56. package/dist/types/manager/types.d.ts +9 -2
  57. package/package.json +3 -3
@@ -1,92 +1,293 @@
1
- import _typeof from "@babel/runtime/helpers/esm/typeof";
2
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
5
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
7
- import { createAsyncPipeline } from "../farrow-pipeline";
8
- var ASYNC_WORKFLOW_SYMBOL = Symbol["for"]('MODERN_ASYNC_WORKFLOW');
9
- export var isAsyncWorkflow = function isAsyncWorkflow(input) {
10
- return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
11
- };
12
- export var createAsyncWorkflow = function createAsyncWorkflow() {
13
- var pipeline = createAsyncPipeline();
14
- var use = function use() {
15
- for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
16
- input[_key] = arguments[_key];
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
17
16
  }
18
- pipeline.use.apply(pipeline, _toConsumableArray(input.map(mapAsyncWorkerToAsyncMiddleware)));
19
- return workflow;
20
- };
21
- var run = /*#__PURE__*/function () {
22
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
23
- var result;
24
- return _regeneratorRuntime().wrap(function _callee$(_context) {
25
- while (1) {
26
- switch (_context.prev = _context.next) {
27
- case 0:
28
- result = pipeline.run(input, {
29
- onLast: function onLast() {
30
- return [];
31
- }
32
- });
33
- if (!isPromise(result)) {
34
- _context.next = 5;
35
- break;
36
- }
37
- return _context.abrupt("return", result.then(function (result) {
38
- return result.filter(Boolean);
39
- }));
40
- case 5:
41
- return _context.abrupt("return", result.filter(Boolean));
42
- case 6:
43
- case "end":
44
- return _context.stop();
45
- }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _asyncToGenerator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _defineProperty(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
51
+ function _iterableToArray(iter) {
52
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
53
+ }
54
+ function _nonIterableSpread() {
55
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
+ }
57
+ function _objectSpread(target) {
58
+ for(var i = 1; i < arguments.length; i++){
59
+ var source = arguments[i] != null ? arguments[i] : {};
60
+ var ownKeys = Object.keys(source);
61
+ if (typeof Object.getOwnPropertySymbols === "function") {
62
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
63
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
64
+ }));
46
65
  }
47
- }, _callee);
48
- }));
49
- return function run(_x) {
50
- return _ref.apply(this, arguments);
66
+ ownKeys.forEach(function(key) {
67
+ _defineProperty(target, key, source[key]);
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ function ownKeys(object, enumerableOnly) {
73
+ var keys = Object.keys(object);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var symbols = Object.getOwnPropertySymbols(object);
76
+ if (enumerableOnly) {
77
+ symbols = symbols.filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
79
+ });
80
+ }
81
+ keys.push.apply(keys, symbols);
82
+ }
83
+ return keys;
84
+ }
85
+ function _objectSpreadProps(target, source) {
86
+ source = source != null ? source : {};
87
+ if (Object.getOwnPropertyDescriptors) {
88
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
89
+ } else {
90
+ ownKeys(Object(source)).forEach(function(key) {
91
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
92
+ });
93
+ }
94
+ return target;
95
+ }
96
+ function _toConsumableArray(arr) {
97
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
98
+ }
99
+ function _unsupportedIterableToArray(o, minLen) {
100
+ if (!o) return;
101
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
102
+ var n = Object.prototype.toString.call(o).slice(8, -1);
103
+ if (n === "Object" && o.constructor) n = o.constructor.name;
104
+ if (n === "Map" || n === "Set") return Array.from(n);
105
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
106
+ }
107
+ var __generator = this && this.__generator || function(thisArg, body) {
108
+ var f, y, t, g, _ = {
109
+ label: 0,
110
+ sent: function() {
111
+ if (t[0] & 1) throw t[1];
112
+ return t[1];
113
+ },
114
+ trys: [],
115
+ ops: []
51
116
  };
52
- }();
53
- var workflow = _objectSpread(_objectSpread({}, pipeline), {}, _defineProperty({
54
- use: use,
55
- run: run
56
- }, ASYNC_WORKFLOW_SYMBOL, true));
57
- return workflow;
117
+ return(g = {
118
+ next: verb(0),
119
+ "throw": verb(1),
120
+ "return": verb(2)
121
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
122
+ return this;
123
+ }), g);
124
+ function verb(n) {
125
+ return function(v) {
126
+ return step([
127
+ n,
128
+ v
129
+ ]);
130
+ };
131
+ }
132
+ function step(op) {
133
+ if (f) throw new TypeError("Generator is already executing.");
134
+ while(_)try {
135
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
136
+ if (y = 0, t) op = [
137
+ op[0] & 2,
138
+ t.value
139
+ ];
140
+ switch(op[0]){
141
+ case 0:
142
+ case 1:
143
+ t = op;
144
+ break;
145
+ case 4:
146
+ _.label++;
147
+ return {
148
+ value: op[1],
149
+ done: false
150
+ };
151
+ case 5:
152
+ _.label++;
153
+ y = op[1];
154
+ op = [
155
+ 0
156
+ ];
157
+ continue;
158
+ case 7:
159
+ op = _.ops.pop();
160
+ _.trys.pop();
161
+ continue;
162
+ default:
163
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
164
+ _ = 0;
165
+ continue;
166
+ }
167
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
168
+ _.label = op[1];
169
+ break;
170
+ }
171
+ if (op[0] === 6 && _.label < t[1]) {
172
+ _.label = t[1];
173
+ t = op;
174
+ break;
175
+ }
176
+ if (t && _.label < t[2]) {
177
+ _.label = t[2];
178
+ _.ops.push(op);
179
+ break;
180
+ }
181
+ if (t[2]) _.ops.pop();
182
+ _.trys.pop();
183
+ continue;
184
+ }
185
+ op = body.call(thisArg, _);
186
+ } catch (e) {
187
+ op = [
188
+ 6,
189
+ e
190
+ ];
191
+ y = 0;
192
+ } finally{
193
+ f = t = 0;
194
+ }
195
+ if (op[0] & 5) throw op[1];
196
+ return {
197
+ value: op[0] ? op[1] : void 0,
198
+ done: true
199
+ };
200
+ }
201
+ };
202
+ import { createAsyncPipeline } from "../farrow-pipeline";
203
+ var ASYNC_WORKFLOW_SYMBOL = Symbol.for("MODERN_ASYNC_WORKFLOW");
204
+ var isAsyncWorkflow = function(input) {
205
+ return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
58
206
  };
59
- var mapAsyncWorkerToAsyncMiddleware = function mapAsyncWorkerToAsyncMiddleware(worker) {
60
- return /*#__PURE__*/function () {
61
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(input, next) {
62
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
63
- while (1) {
64
- switch (_context2.prev = _context2.next) {
65
- case 0:
66
- _context2.next = 2;
67
- return worker(input);
68
- case 2:
69
- _context2.t1 = _context2.sent;
70
- _context2.t0 = [_context2.t1];
71
- _context2.t2 = _toConsumableArray;
72
- _context2.next = 7;
73
- return next(input);
74
- case 7:
75
- _context2.t3 = _context2.sent;
76
- _context2.t4 = (0, _context2.t2)(_context2.t3);
77
- return _context2.abrupt("return", _context2.t0.concat.call(_context2.t0, _context2.t4));
78
- case 10:
79
- case "end":
80
- return _context2.stop();
81
- }
207
+ var createAsyncWorkflow = function() {
208
+ var pipeline = createAsyncPipeline();
209
+ var use = function() {
210
+ for(var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++){
211
+ input[_key] = arguments[_key];
82
212
  }
83
- }, _callee2);
84
- }));
85
- return function (_x2, _x3) {
86
- return _ref2.apply(this, arguments);
213
+ var _pipeline;
214
+ (_pipeline = pipeline).use.apply(_pipeline, _toConsumableArray(input.map(mapAsyncWorkerToAsyncMiddleware)));
215
+ return workflow;
87
216
  };
88
- }();
217
+ var run = function() {
218
+ var _ref = _asyncToGenerator(function(input) {
219
+ var result;
220
+ return __generator(this, function(_state) {
221
+ result = pipeline.run(input, {
222
+ onLast: function() {
223
+ return [];
224
+ }
225
+ });
226
+ if (isPromise(result)) {
227
+ return [
228
+ 2,
229
+ result.then(function(result2) {
230
+ return result2.filter(Boolean);
231
+ })
232
+ ];
233
+ } else {
234
+ return [
235
+ 2,
236
+ result.filter(Boolean)
237
+ ];
238
+ }
239
+ return [
240
+ 2
241
+ ];
242
+ });
243
+ });
244
+ return function run(input) {
245
+ return _ref.apply(this, arguments);
246
+ };
247
+ }();
248
+ var workflow = _objectSpreadProps(_objectSpread({}, pipeline), _defineProperty({
249
+ use: use,
250
+ run: run
251
+ }, ASYNC_WORKFLOW_SYMBOL, true));
252
+ return workflow;
253
+ };
254
+ var mapAsyncWorkerToAsyncMiddleware = function(worker) {
255
+ return function() {
256
+ var _ref = _asyncToGenerator(function(input, next) {
257
+ var _, _1;
258
+ return __generator(this, function(_state) {
259
+ switch(_state.label){
260
+ case 0:
261
+ return [
262
+ 4,
263
+ worker(input)
264
+ ];
265
+ case 1:
266
+ _1 = (_ = [
267
+ _state.sent()
268
+ ]).concat;
269
+ return [
270
+ 4,
271
+ next(input)
272
+ ];
273
+ case 2:
274
+ return [
275
+ 2,
276
+ _1.apply(_, [
277
+ _toConsumableArray.apply(void 0, [
278
+ _state.sent()
279
+ ])
280
+ ])
281
+ ];
282
+ }
283
+ });
284
+ });
285
+ return function(input, next) {
286
+ return _ref.apply(this, arguments);
287
+ };
288
+ }();
89
289
  };
90
290
  function isPromise(obj) {
91
- return Boolean(obj) && (_typeof(obj) === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
92
- }
291
+ return Boolean(obj) && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
292
+ }
293
+ export { createAsyncWorkflow, isAsyncWorkflow };
@@ -1,3 +1,3 @@
1
1
  export * from "./sync";
2
2
  export * from "./parallel";
3
- export * from "./async";
3
+ export * from "./async";
@@ -1,54 +1,249 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
4
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
1
+ function _arrayLikeToArray(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _arrayWithoutHoles(arr) {
7
+ if (Array.isArray(arr)) return _arrayLikeToArray(arr);
8
+ }
9
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
10
+ try {
11
+ var info = gen[key](arg);
12
+ var value = info.value;
13
+ } catch (error) {
14
+ reject(error);
15
+ return;
16
+ }
17
+ if (info.done) {
18
+ resolve(value);
19
+ } else {
20
+ Promise.resolve(value).then(_next, _throw);
21
+ }
22
+ }
23
+ function _asyncToGenerator(fn) {
24
+ return function() {
25
+ var self = this, args = arguments;
26
+ return new Promise(function(resolve, reject) {
27
+ var gen = fn.apply(self, args);
28
+ function _next(value) {
29
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
30
+ }
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+ _next(undefined);
35
+ });
36
+ };
37
+ }
38
+ function _defineProperty(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
51
+ function _iterableToArray(iter) {
52
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
53
+ }
54
+ function _nonIterableSpread() {
55
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
56
+ }
57
+ function _objectSpread(target) {
58
+ for(var i = 1; i < arguments.length; i++){
59
+ var source = arguments[i] != null ? arguments[i] : {};
60
+ var ownKeys = Object.keys(source);
61
+ if (typeof Object.getOwnPropertySymbols === "function") {
62
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
63
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
64
+ }));
65
+ }
66
+ ownKeys.forEach(function(key) {
67
+ _defineProperty(target, key, source[key]);
68
+ });
69
+ }
70
+ return target;
71
+ }
72
+ function ownKeys(object, enumerableOnly) {
73
+ var keys = Object.keys(object);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var symbols = Object.getOwnPropertySymbols(object);
76
+ if (enumerableOnly) {
77
+ symbols = symbols.filter(function(sym) {
78
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
79
+ });
80
+ }
81
+ keys.push.apply(keys, symbols);
82
+ }
83
+ return keys;
84
+ }
85
+ function _objectSpreadProps(target, source) {
86
+ source = source != null ? source : {};
87
+ if (Object.getOwnPropertyDescriptors) {
88
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
89
+ } else {
90
+ ownKeys(Object(source)).forEach(function(key) {
91
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
92
+ });
93
+ }
94
+ return target;
95
+ }
96
+ function _toConsumableArray(arr) {
97
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
98
+ }
99
+ function _unsupportedIterableToArray(o, minLen) {
100
+ if (!o) return;
101
+ if (typeof o === "string") return _arrayLikeToArray(o, minLen);
102
+ var n = Object.prototype.toString.call(o).slice(8, -1);
103
+ if (n === "Object" && o.constructor) n = o.constructor.name;
104
+ if (n === "Map" || n === "Set") return Array.from(n);
105
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
106
+ }
107
+ var __generator = this && this.__generator || function(thisArg, body) {
108
+ var f, y, t, g, _ = {
109
+ label: 0,
110
+ sent: function() {
111
+ if (t[0] & 1) throw t[1];
112
+ return t[1];
113
+ },
114
+ trys: [],
115
+ ops: []
116
+ };
117
+ return(g = {
118
+ next: verb(0),
119
+ "throw": verb(1),
120
+ "return": verb(2)
121
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
122
+ return this;
123
+ }), g);
124
+ function verb(n) {
125
+ return function(v) {
126
+ return step([
127
+ n,
128
+ v
129
+ ]);
130
+ };
131
+ }
132
+ function step(op) {
133
+ if (f) throw new TypeError("Generator is already executing.");
134
+ while(_)try {
135
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
136
+ if (y = 0, t) op = [
137
+ op[0] & 2,
138
+ t.value
139
+ ];
140
+ switch(op[0]){
141
+ case 0:
142
+ case 1:
143
+ t = op;
144
+ break;
145
+ case 4:
146
+ _.label++;
147
+ return {
148
+ value: op[1],
149
+ done: false
150
+ };
151
+ case 5:
152
+ _.label++;
153
+ y = op[1];
154
+ op = [
155
+ 0
156
+ ];
157
+ continue;
158
+ case 7:
159
+ op = _.ops.pop();
160
+ _.trys.pop();
161
+ continue;
162
+ default:
163
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
164
+ _ = 0;
165
+ continue;
166
+ }
167
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
168
+ _.label = op[1];
169
+ break;
170
+ }
171
+ if (op[0] === 6 && _.label < t[1]) {
172
+ _.label = t[1];
173
+ t = op;
174
+ break;
175
+ }
176
+ if (t && _.label < t[2]) {
177
+ _.label = t[2];
178
+ _.ops.push(op);
179
+ break;
180
+ }
181
+ if (t[2]) _.ops.pop();
182
+ _.trys.pop();
183
+ continue;
184
+ }
185
+ op = body.call(thisArg, _);
186
+ } catch (e) {
187
+ op = [
188
+ 6,
189
+ e
190
+ ];
191
+ y = 0;
192
+ } finally{
193
+ f = t = 0;
194
+ }
195
+ if (op[0] & 5) throw op[1];
196
+ return {
197
+ value: op[0] ? op[1] : void 0,
198
+ done: true
199
+ };
200
+ }
201
+ };
6
202
  import { createPipeline } from "../farrow-pipeline";
7
- var PARALLEL_WORKFLOW_SYMBOL = Symbol["for"]('MODERN_PARALLEL_WORKFLOW');
8
- export var isParallelWorkflow = function isParallelWorkflow(input) {
9
- return Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
203
+ var PARALLEL_WORKFLOW_SYMBOL = Symbol.for("MODERN_PARALLEL_WORKFLOW");
204
+ var isParallelWorkflow = function(input) {
205
+ return Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
10
206
  };
11
- export var createParallelWorkflow = function createParallelWorkflow() {
12
- var pipeline = createPipeline();
13
- var use = function use() {
14
- for (var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++) {
15
- input[_key] = arguments[_key];
16
- }
17
- pipeline.use.apply(pipeline, _toConsumableArray(input.map(mapParallelWorkerToAsyncMiddleware)));
18
- return workflow;
19
- };
20
- var run = /*#__PURE__*/function () {
21
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input) {
22
- return _regeneratorRuntime().wrap(function _callee$(_context) {
23
- while (1) {
24
- switch (_context.prev = _context.next) {
25
- case 0:
26
- return _context.abrupt("return", Promise.all(pipeline.run(input, {
27
- onLast: function onLast() {
28
- return [];
29
- }
30
- })).then(function (result) {
31
- return result.filter(Boolean);
32
- }));
33
- case 1:
34
- case "end":
35
- return _context.stop();
36
- }
207
+ var createParallelWorkflow = function() {
208
+ var pipeline = createPipeline();
209
+ var use = function() {
210
+ for(var _len = arguments.length, input = new Array(_len), _key = 0; _key < _len; _key++){
211
+ input[_key] = arguments[_key];
37
212
  }
38
- }, _callee);
39
- }));
40
- return function run(_x) {
41
- return _ref.apply(this, arguments);
213
+ var _pipeline;
214
+ (_pipeline = pipeline).use.apply(_pipeline, _toConsumableArray(input.map(mapParallelWorkerToAsyncMiddleware)));
215
+ return workflow;
216
+ };
217
+ var run = function() {
218
+ var _ref = _asyncToGenerator(function(input) {
219
+ return __generator(this, function(_state) {
220
+ return [
221
+ 2,
222
+ Promise.all(pipeline.run(input, {
223
+ onLast: function() {
224
+ return [];
225
+ }
226
+ })).then(function(result) {
227
+ return result.filter(Boolean);
228
+ })
229
+ ];
230
+ });
231
+ });
232
+ return function run(input) {
233
+ return _ref.apply(this, arguments);
234
+ };
235
+ }();
236
+ var workflow = _objectSpreadProps(_objectSpread({}, pipeline), _defineProperty({
237
+ run: run,
238
+ use: use
239
+ }, PARALLEL_WORKFLOW_SYMBOL, true));
240
+ return workflow;
241
+ };
242
+ var mapParallelWorkerToAsyncMiddleware = function(worker) {
243
+ return function(input, next) {
244
+ return [
245
+ worker(input)
246
+ ].concat(_toConsumableArray(next(input)));
42
247
  };
43
- }();
44
- var workflow = _objectSpread(_objectSpread({}, pipeline), {}, _defineProperty({
45
- run: run,
46
- use: use
47
- }, PARALLEL_WORKFLOW_SYMBOL, true));
48
- return workflow;
49
248
  };
50
- var mapParallelWorkerToAsyncMiddleware = function mapParallelWorkerToAsyncMiddleware(worker) {
51
- return function (input, next) {
52
- return [worker(input)].concat(_toConsumableArray(next(input)));
53
- };
54
- };
249
+ export { createParallelWorkflow, isParallelWorkflow };