taskbuffer/dist/taskbuffer.classes.taskparallel.js

24 lines
2.0 KiB
JavaScript
Raw Normal View History

"use strict";
2017-06-09 21:26:23 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
2016-07-31 22:53:27 +00:00
const plugins = require("./taskbuffer.plugins");
const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
class Taskparallel extends taskbuffer_classes_task_1.Task {
constructor(optionsArg) {
2016-08-01 11:17:15 +00:00
let options = plugins.lodash.merge(optionsArg, {
2016-07-31 22:53:27 +00:00
taskFunction: () => {
2017-01-19 16:26:35 +00:00
let done = plugins.q.defer();
2016-08-01 11:17:15 +00:00
let promiseArray = []; // stores promises of all tasks, since they run in parallel
2016-07-31 22:53:27 +00:00
this.taskArray.forEach(function (taskArg) {
promiseArray.push(taskArg.trigger());
});
2017-01-19 16:26:35 +00:00
Promise.all(promiseArray)
.then(done.resolve);
return done.promise;
}
});
2016-07-31 22:53:27 +00:00
super(options);
2016-08-01 11:17:15 +00:00
this.taskArray = optionsArg.taskArray;
}
2016-07-31 22:53:27 +00:00
}
exports.Taskparallel = Taskparallel;
2017-06-09 21:26:23 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2twYXJhbGxlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrcGFyYWxsZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxnREFBK0M7QUFFL0MsdUVBQWdEO0FBRWhELGtCQUEwQixTQUFRLDhCQUFJO0lBRWxDLFlBQVksVUFFWDtRQUNHLElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUM5QixVQUFVLEVBQ1Y7WUFDSSxZQUFZLEVBQUU7Z0JBQ1YsSUFBSSxJQUFJLEdBQUcsT0FBTy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