1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _AbstractExecution = require("./AbstractExecution");
|
8 |
|
9 | var _AbstractExecution2 = _interopRequireDefault(_AbstractExecution);
|
10 |
|
11 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | class SerialBatch extends _AbstractExecution2.default {
|
19 | |
20 |
|
21 |
|
22 | execute(...args) {
|
23 | const zeroStage = Promise.resolve([]);
|
24 | return this._jobs.reduce((lastStage, currentStage) => lastStage.then(results => this._executeJob(currentStage, args).then(Array.prototype.concat.bind(results))), zeroStage);
|
25 | }
|
26 |
|
27 | _executeJob(stage, args) {
|
28 | let result = stage(...args);
|
29 |
|
30 | if (!(result instanceof Promise)) {
|
31 | result = Promise.resolve(result);
|
32 | }
|
33 |
|
34 | return result;
|
35 | }
|
36 |
|
37 | }
|
38 |
|
39 | exports.default = SerialBatch;
|
40 |
|
41 | typeof $IMA !== 'undefined' && $IMA !== null && $IMA.Loader && $IMA.Loader.register('ima/execution/SerialBatch', [], function (_export, _context) {
|
42 | 'use strict';
|
43 | return {
|
44 | setters: [],
|
45 | execute: function () {
|
46 | _export('default', exports.default);
|
47 | }
|
48 | };
|
49 | });
|