UNPKG

1.15 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const cancelation_1 = __importDefault(require("./errors/cancelation"));
7class CancelationRequest {
8 constructor(pendingWork) {
9 this._pendingWork = pendingWork; // all
10 this._canceling = null;
11 }
12 get isCanceled() {
13 return !!this._canceling;
14 }
15 throwIfRequested() {
16 if (this.isCanceled) {
17 throw new cancelation_1.default('Build Canceled');
18 }
19 }
20 then() {
21 return this._pendingWork.then(...arguments);
22 }
23 cancel() {
24 if (this._canceling) {
25 return this._canceling;
26 }
27 this._canceling = this._pendingWork.catch(e => {
28 if (cancelation_1.default.isCancelationError(e)) {
29 return;
30 }
31 else {
32 throw e;
33 }
34 });
35 return this._canceling;
36 }
37}
38exports.default = CancelationRequest;
39//# sourceMappingURL=cancelation-request.js.map
\No newline at end of file