Skip to content

Commit 1a77773

Browse files
committed
- Updated formatting of cancelable promise
1 parent 6b7efd1 commit 1a77773

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

src/templates/core/CancelablePromise.hbs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ export class CancelablePromise<T> implements Promise<T> {
1010
#resolve?: (value: T | PromiseLike<T>) => void;
1111
#reject?: (reason?: any) => void;
1212

13-
constructor(executor: (
14-
resolve: (value: T | PromiseLike<T>) => void,
15-
reject: (reason?: any) => void,
16-
onCancel: (cancelHandler: () => void) => void) => void,
13+
constructor(
14+
executor: (
15+
resolve: (value: T | PromiseLike<T>) => void,
16+
reject: (reason?: any) => void,
17+
onCancel: (cancelHandler: () => void) => void
18+
) => void
1719
) {
1820
this.#isPending = true;
1921
this.#isCanceled = false;
@@ -69,7 +71,7 @@ export class CancelablePromise<T> implements Promise<T> {
6971
for (const cancelHandler of this.#cancelHandlers) {
7072
cancelHandler();
7173
}
72-
} catch (error) {
74+
} catch(error) {
7375
this.#reject?.(error);
7476
return;
7577
}

test/__snapshots__/index.spec.js.snap

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,12 @@ export class CancelablePromise<T> implements Promise<T> {
6868
#resolve?: (value: T | PromiseLike<T>) => void;
6969
#reject?: (reason?: any) => void;
7070

71-
constructor(executor: (
72-
resolve: (value: T | PromiseLike<T>) => void,
73-
reject: (reason?: any) => void,
74-
onCancel: (cancelHandler: () => void) => void) => void,
71+
constructor(
72+
executor: (
73+
resolve: (value: T | PromiseLike<T>) => void,
74+
reject: (reason?: any) => void,
75+
onCancel: (cancelHandler: () => void) => void
76+
) => void
7577
) {
7678
this.#isPending = true;
7779
this.#isCanceled = false;
@@ -127,7 +129,7 @@ export class CancelablePromise<T> implements Promise<T> {
127129
for (const cancelHandler of this.#cancelHandlers) {
128130
cancelHandler();
129131
}
130-
} catch (error) {
132+
} catch(error) {
131133
this.#reject?.(error);
132134
return;
133135
}
@@ -2537,10 +2539,12 @@ export class CancelablePromise<T> implements Promise<T> {
25372539
#resolve?: (value: T | PromiseLike<T>) => void;
25382540
#reject?: (reason?: any) => void;
25392541

2540-
constructor(executor: (
2541-
resolve: (value: T | PromiseLike<T>) => void,
2542-
reject: (reason?: any) => void,
2543-
onCancel: (cancelHandler: () => void) => void) => void,
2542+
constructor(
2543+
executor: (
2544+
resolve: (value: T | PromiseLike<T>) => void,
2545+
reject: (reason?: any) => void,
2546+
onCancel: (cancelHandler: () => void) => void
2547+
) => void
25442548
) {
25452549
this.#isPending = true;
25462550
this.#isCanceled = false;
@@ -2596,7 +2600,7 @@ export class CancelablePromise<T> implements Promise<T> {
25962600
for (const cancelHandler of this.#cancelHandlers) {
25972601
cancelHandler();
25982602
}
2599-
} catch (error) {
2603+
} catch(error) {
26002604
this.#reject?.(error);
26012605
return;
26022606
}

0 commit comments

Comments
 (0)