Skip to content

Commit 5cabd09

Browse files
committed
Clean up code
1 parent de51459 commit 5cabd09

File tree

4 files changed

+48
-44
lines changed

4 files changed

+48
-44
lines changed

Cargo.lock

+11-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fend-core.workspace = true
1616
home = "0.5.9"
1717
rand = { version = "0.8.5", default-features = false, features = ["std", "std_rng"] }
1818
rustyline = { version = "15.0.0", default-features = false, features = ["with-file-history", "custom-bindings"] }
19-
serde = { version = "1.0.215", default-features = false }
19+
serde = { version = "1.0.216", default-features = false }
2020
toml = { version = "0.8.19", default-features = false, features = ["parse"] }
2121
minreq = { version = "2.13.0", default-features = false, optional = true }
2222

web/package-lock.json

+27-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/lib/WaitGroup.ts

+9-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export class WaitGroup {
1111
}
1212
++this.#counter;
1313
}
14+
1415
leave() {
1516
if (this.#counter <= 0 || !this.#resolve) {
1617
throw new Error('leave() called without a matching enter()');
@@ -21,11 +22,10 @@ export class WaitGroup {
2122
this.#resolve = undefined;
2223
}
2324
}
25+
2426
async wait(abortSignal?: AbortSignal) {
2527
if (abortSignal) {
26-
await abortPromise(abortSignal, async () => {
27-
await this.#promise;
28-
});
28+
await abortPromise(abortSignal, this.#promise);
2929
} else {
3030
await this.#promise;
3131
}
@@ -36,18 +36,16 @@ export class WaitGroup {
3636
}
3737
}
3838

39-
async function abortPromise(abortSignal: AbortSignal, f: () => Promise<void>) {
40-
return new Promise((resolve, reject) => {
39+
async function abortPromise<T>(abortSignal: AbortSignal, promise: Promise<T>) {
40+
return new Promise<T>((resolve, reject) => {
4141
if (abortSignal.aborted) {
42-
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
43-
reject(abortSignal.reason);
42+
reject(abortSignal.reason as Error);
4443
return;
4544
}
4645

4746
const onAbort = () => {
4847
cleanup();
49-
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
50-
reject(abortSignal.reason);
48+
reject(abortSignal.reason as Error);
5149
};
5250

5351
const cleanup = () => {
@@ -56,15 +54,14 @@ async function abortPromise(abortSignal: AbortSignal, f: () => Promise<void>) {
5654

5755
abortSignal.addEventListener('abort', onAbort);
5856

59-
f().then(
57+
promise.then(
6058
value => {
6159
cleanup();
6260
resolve(value);
6361
},
6462
(error: unknown) => {
6563
cleanup();
66-
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
67-
reject(error);
64+
reject(error as Error);
6865
},
6966
);
7067
});

0 commit comments

Comments
 (0)