UNPKG

stryker

Version:
55 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var objectUtils_1 = require("./objectUtils"); /** * Wraps a promise in a Task api for convenience. */ var Task = /** @class */ (function () { function Task() { var _this = this; this._isCompleted = false; this.resolve = function (result) { _this._isCompleted = true; _this.resolveFn(result); }; this.reject = function (reason) { _this._isCompleted = true; _this.rejectFn(reason); }; this._promise = new Promise(function (resolve, reject) { _this.resolveFn = resolve; _this.rejectFn = reject; }); } Object.defineProperty(Task.prototype, "promise", { get: function () { return this._promise; }, enumerable: true, configurable: true }); Object.defineProperty(Task.prototype, "isCompleted", { get: function () { return this._isCompleted; }, enumerable: true, configurable: true }); return Task; }()); exports.Task = Task; /** * A task that can expire after the given time. */ var ExpirableTask = /** @class */ (function (_super) { tslib_1.__extends(ExpirableTask, _super); function ExpirableTask(timeoutMS) { var _this = _super.call(this) || this; _this._promise = objectUtils_1.timeout(_this._promise, timeoutMS); return _this; } return ExpirableTask; }(Task)); exports.ExpirableTask = ExpirableTask; //# sourceMappingURL=Task.js.map