Skip to content

Commit 41e25b8

Browse files
fix: adjust promise resolve for next issue
1 parent 728fefa commit 41e25b8

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

package-lock.json

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

src/templates/core/CancelablePromise.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ export class CancelablePromise<T> implements Promise<T> {
4949
return;
5050
}
5151
this.#isResolved = true;
52-
this.#resolve?.(value);
52+
if (this.#resolve) this.#resolve(value);
5353
};
5454

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

6363
const onCancel = (cancelHandler: () => void): void => {

test/__snapshots__/index.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ export class CancelablePromise<T> implements Promise<T> {
119119
return;
120120
}
121121
this.#isResolved = true;
122-
this.#resolve?.(value);
122+
if (this.#resolve) this.#resolve(value);
123123
};
124124

125125
const onReject = (reason?: any): void => {
126126
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
127127
return;
128128
}
129129
this.#isRejected = true;
130-
this.#reject?.(reason);
130+
if (this.#reject) this.#reject(reason);
131131
};
132132

133133
const onCancel = (cancelHandler: () => void): void => {
@@ -3345,15 +3345,15 @@ export class CancelablePromise<T> implements Promise<T> {
33453345
return;
33463346
}
33473347
this.#isResolved = true;
3348-
this.#resolve?.(value);
3348+
if (this.#resolve) this.#resolve(value);
33493349
};
33503350

33513351
const onReject = (reason?: any): void => {
33523352
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
33533353
return;
33543354
}
33553355
this.#isRejected = true;
3356-
this.#reject?.(reason);
3356+
if (this.#reject) this.#reject(reason);
33573357
};
33583358

33593359
const onCancel = (cancelHandler: () => void): void => {

0 commit comments

Comments
 (0)