Skip to content

Commit 5b5b750

Browse files
committed
Fixed builds
1 parent 40cc25d commit 5b5b750

File tree

4 files changed

+108
-217
lines changed

4 files changed

+108
-217
lines changed

package-lock.json

Lines changed: 20 additions & 130 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
"glob": "10.0.0",
108108
"jest": "29.5.0",
109109
"jest-cli": "29.5.0",
110-
"node-fetch": "3.3.1",
110+
"node-fetch": "2.6.9",
111111
"prettier": "2.8.7",
112112
"puppeteer": "19.8.5",
113113
"qs": "6.11.1",
@@ -117,11 +117,12 @@
117117
"rxjs": "7.8.0",
118118
"ts-node": "10.9.1",
119119
"tslib": "2.5.0",
120-
"typescript": "5.0.4",
120+
"typescript": "4.9.5",
121121
"zone.js": "0.13.0"
122122
},
123123
"overrides" : {
124+
"node-fetch": "2.6.9",
124125
"rollup": "3.20.2",
125-
"typescript": "5.0.4"
126+
"typescript": "4.9.5"
126127
}
127128
}

src/templates/core/CancelablePromise.hbs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,47 +36,47 @@ export class CancelablePromise<T> implements Promise<T> {
3636
onCancel: OnCancel
3737
) => void
3838
) {
39-
this._isResolved = false;
40-
this._isRejected = false;
41-
this._isCancelled = false;
42-
this._cancelHandlers = [];
43-
this._promise = new Promise<T>((resolve, reject) => {
44-
this._resolve = resolve;
45-
this._reject = reject;
39+
this.#isResolved = false;
40+
this.#isRejected = false;
41+
this.#isCancelled = false;
42+
this.#cancelHandlers = [];
43+
this.#promise = new Promise<T>((resolve, reject) => {
44+
this.#resolve = resolve;
45+
this.#reject = reject;
4646

4747
const onResolve = (value: T | PromiseLike<T>): void => {
48-
if (this._isResolved || this._isRejected || this._isCancelled) {
48+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
4949
return;
5050
}
51-
this._isResolved = true;
52-
this._resolve?.(value);
51+
this.#isResolved = true;
52+
this.#resolve?.(value);
5353
};
5454

5555
const onReject = (reason?: any): void => {
56-
if (this._isResolved || this._isRejected || this._isCancelled) {
56+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
5757
return;
5858
}
59-
this._isRejected = true;
60-
this._reject?.(reason);
59+
this.#isRejected = true;
60+
this.#reject?.(reason);
6161
};
6262

6363
const onCancel = (cancelHandler: () => void): void => {
64-
if (this._isResolved || this._isRejected || this._isCancelled) {
64+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
6565
return;
6666
}
67-
this._cancelHandlers.push(cancelHandler);
67+
this.#cancelHandlers.push(cancelHandler);
6868
};
6969

7070
Object.defineProperty(onCancel, 'isResolved', {
71-
get: (): boolean => this._isResolved,
71+
get: (): boolean => this.#isResolved,
7272
});
7373

7474
Object.defineProperty(onCancel, 'isRejected', {
75-
get: (): boolean => this._isRejected,
75+
get: (): boolean => this.#isRejected,
7676
});
7777

7878
Object.defineProperty(onCancel, 'isCancelled', {
79-
get: (): boolean => this._isCancelled,
79+
get: (): boolean => this.#isCancelled,
8080
});
8181

8282
return executor(onResolve, onReject, onCancel as OnCancel);
@@ -91,39 +91,39 @@ export class CancelablePromise<T> implements Promise<T> {
9191
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
9292
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
9393
): Promise<TResult1 | TResult2> {
94-
return this._promise.then(onFulfilled, onRejected);
94+
return this.#promise.then(onFulfilled, onRejected);
9595
}
9696

9797
public catch<TResult = never>(
9898
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null
9999
): Promise<T | TResult> {
100-
return this._promise.catch(onRejected);
100+
return this.#promise.catch(onRejected);
101101
}
102102

103103
public finally(onFinally?: (() => void) | null): Promise<T> {
104-
return this._promise.finally(onFinally);
104+
return this.#promise.finally(onFinally);
105105
}
106106

107107
public cancel(): void {
108-
if (this._isResolved || this._isRejected || this._isCancelled) {
108+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
109109
return;
110110
}
111-
this._isCancelled = true;
112-
if (this._cancelHandlers.length) {
111+
this.#isCancelled = true;
112+
if (this.#cancelHandlers.length) {
113113
try {
114-
for (const cancelHandler of this._cancelHandlers) {
114+
for (const cancelHandler of this.#cancelHandlers) {
115115
cancelHandler();
116116
}
117117
} catch (error) {
118118
console.warn('Cancellation threw an error', error);
119119
return;
120120
}
121121
}
122-
this._cancelHandlers.length = 0;
123-
this._reject?.(new CancelError('Request aborted'));
122+
this.#cancelHandlers.length = 0;
123+
this.#reject?.(new CancelError('Request aborted'));
124124
}
125125

126126
public get isCancelled(): boolean {
127-
return this._isCancelled;
127+
return this.#isCancelled;
128128
}
129129
}

0 commit comments

Comments
 (0)