taskbuffer/dist/taskbuffer.classes.taskparallel.js

23 lines
1.9 KiB
JavaScript
Raw Normal View History

"use strict";
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-01-19 16:26:35 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2twYXJhbGxlbC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrcGFyYWxsZWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLGdEQUErQztBQUUvQyx1RUFBZ0Q7QUFFaEQsa0JBQTBCLFNBQVEsOEJBQUk7SUFFbEMsWUFBWSxVQUVYO1FBQ0csSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQzlCLFVBQVUsRUFDVjtZQUNJLFlBQVksRUFBRTtnQkFDVixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO2dCQUM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