1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4 | return new (P || (P = Promise))(function (resolve, reject) {
|
5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9 | });
|
10 | };
|
11 | Object.defineProperty(exports, "__esModule", { value: true });
|
12 | const Operation_1 = require("./Operation");
|
13 | const OperationQueue_1 = require("./OperationQueue");
|
14 |
|
15 |
|
16 |
|
17 | class GroupOperation extends Operation_1.Operation {
|
18 | constructor() {
|
19 | super();
|
20 | this.queue = new OperationQueue_1.OperationQueue();
|
21 | this.operations = [];
|
22 | }
|
23 | |
24 |
|
25 |
|
26 |
|
27 |
|
28 | run() {
|
29 | return __awaiter(this, void 0, void 0, function* () {
|
30 | yield this.queue.addOperations(this.operations);
|
31 | const accum = [];
|
32 | return this.operations.reduce((accum, operation) => {
|
33 | accum.push(operation.result);
|
34 | return accum;
|
35 | }, accum);
|
36 | });
|
37 | }
|
38 | |
39 |
|
40 |
|
41 | start() {
|
42 | const _super = Object.create(null, {
|
43 | start: { get: () => super.start }
|
44 | });
|
45 | return __awaiter(this, void 0, void 0, function* () {
|
46 | this.dependencies = [];
|
47 | return _super.start.call(this);
|
48 | });
|
49 | }
|
50 | |
51 |
|
52 |
|
53 | addOperation(operation) {
|
54 | this.operations.push(operation);
|
55 | this.dependencies = [];
|
56 | }
|
57 | |
58 |
|
59 |
|
60 | addOperations(operations) {
|
61 | this.operations = this.operations.concat(operations);
|
62 | this.dependencies = [];
|
63 | }
|
64 | }
|
65 | exports.GroupOperation = GroupOperation;
|
66 |
|
\ | No newline at end of file |