UNPKG

@iredium/butterfly

Version:
45 lines (44 loc) 1.86 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SampleJob = void 0; var job_1 = require("./job"); var SampleJob = /** @class */ (function (_super) { __extends(SampleJob, _super); function SampleJob() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.name = 'iredium.jobs.sample-job'; _this.maxActiveJob = 3; return _this; } SampleJob.prototype.perform = function (job, done) { var currentProgress = 0; console.log('start job'); var totalTime = 100 * Math.floor(Math.random() * 60); var updateProgressInterval = setInterval(function () { currentProgress += 100; job.progress(currentProgress, totalTime); }, 1000); setTimeout(function () { console.log("Test job complete. Here is the message from the job: " + JSON.stringify(job.data)); clearInterval(updateProgressInterval); done(); }, totalTime); }; return SampleJob; }(job_1.Job)); exports.SampleJob = SampleJob;