taskbuffer/dist/taskbuffer.classes.taskchain.js

54 lines
4.2 KiB
JavaScript

"use strict";
const plugins = require("./taskbuffer.plugins");
const taskbuffer_classes_task_1 = require("./taskbuffer.classes.task");
class Taskchain extends taskbuffer_classes_task_1.Task {
constructor(optionsArg) {
let options = plugins.lodash.merge({
name: "unnamed Taskchain",
log: false
}, optionsArg, {
taskFunction: (x) => {
let done = plugins.Q.defer(); // this is the starting Deferred object
let taskCounter = 0; // counter for iterating async over the taskArray
let iterateTasks = (x) => {
if (typeof this.taskArray[taskCounter] != "undefined") {
this._oraObject.text(this.name + " running: Task" + this.taskArray[taskCounter].name);
this.taskArray[taskCounter].trigger(x)
.then((x) => {
plugins.beautylog.ok(this.taskArray[taskCounter].name);
taskCounter++;
iterateTasks(x);
});
}
else {
this._oraObject.endOk("Taskchain \"" + this.name + "\" completed successfully");
done.resolve(x);
}
};
iterateTasks(x);
return done.promise;
}
});
super(options);
this.taskArray = optionsArg.taskArray;
this._oraObject = new plugins.beautylog.Ora("Taskchain idle", "blue");
if (optionsArg.log === true) {
this._oraObject.start();
}
;
}
addTask(taskArg) {
this.taskArray.push(taskArg);
}
;
removeTask(taskArg) {
//TODO
}
;
shiftTask() {
}
;
}
exports.Taskchain = Taskchain;
;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHNCQUFzQixDQUFDLENBQUE7QUFDaEQsMENBQW1CLDJCQUEyQixDQUFDLENBQUE7QUFHL0Msd0JBQStCLDhCQUFJO0lBRy9CLFlBQVksVUFNWDtRQUNHLElBQUksT0FBTyxHQUFHLE9BQU8sQ0FBQyxNQU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