"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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 = plugins.beautylog.ora; 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFza2J1ZmZlci5jbGFzc2VzLnRhc2tjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3Rhc2tidWZmZXIuY2xhc3Nlcy50YXNrY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxnREFBZ0Q7QUFDaEQsdUVBQWlEO0FBR2pELGVBQXVCLFNBQVEsOEJBQUk7SUFHakMsWUFBWSxVQU1YO1FBQ0MsSUFBSSxPQUFPLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQ2hDO1lBQ0UsSUFBSSxFQUFFLG1CQUFtQjtZQUN6QixHQUFHLEVBQUUsS0FBSztTQUNYLEVBQ0QsVUFBVSxFQUNWO1lBQ0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