/** * QCObjects Framework SDK * ________________ * * Author: Jean Machuca * * Cross Browser Javascript Framework for MVC Patterns * QCObjects is licensed under the MIT License * [LICENSE] (https://github.com/QCObjects/qcobjects-sdk/blob/main/LICENSE.txt) * * Copyright (C) 2015 Jean Machuca, * * Everyone is permitted to copy and distribute verbatim copies of this * license document, but changing it is not allowed. */ "use strict"; import { Timer, Package, logger } from "qcobjects"; (function() { Package("org.qcobjects.tools",[ class Process extends Timer { alive:boolean; steps:any[] = []; currentStep = 0; duration: any; constructor ({steps = [], currentStep = 0, alive = false}) { super({steps, currentStep, alive}); this.alive = alive; } stop (){ this.alive=false; } start (){ this.alive=true; this.thread({ duration: this.duration, timing: (timeFraction:number) => { this.currentStep+=1; // eslint-disable-next-line @typescript-eslint/no-floating-promises this.steps.map((p:()=> void):Promise | undefined => { let _ret_; if (typeof p === "function"){ _ret_ = Promise.resolve().then( function (){ p.call(process); }); } return _ret_; }); return timeFraction; }, intervalInterceptor(progress:number) { logger.debug("process execution progress: "+progress.toString()); } }); } } ]); })();