Skip to content

Commit a7fef39

Browse files
committed
refactor: cleanup nested conditions
Signed-off-by: Jérôme Benoit <[email protected]>
1 parent 5e18c45 commit a7fef39

File tree

2 files changed

+17
-39
lines changed

2 files changed

+17
-39
lines changed

deno.json

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"version": "0.5.13",
44
"exports": "./src/mod.ts",
55
"compilerOptions": {
6-
"lib": [
7-
"deno.worker"
8-
],
6+
"lib": ["deno.worker"],
97
"strict": true
108
},
119
"tasks": {
@@ -27,9 +25,7 @@
2725
"documentation": "deno doc ./src/mod.ts"
2826
},
2927
"test": {
30-
"include": [
31-
"./tests/**/*.test.mjs"
32-
]
28+
"include": ["./tests/**/*.test.mjs"]
3329
},
3430
"fmt": {
3531
"semiColons": false,
@@ -42,18 +38,8 @@
4238
"@std/testing": "jsr:@std/testing@^1.0.15"
4339
},
4440
"publish": {
45-
"include": [
46-
"LICENSE",
47-
"README.md",
48-
"deno.json",
49-
"src/**/*.ts"
50-
]
41+
"include": ["LICENSE", "README.md", "deno.json", "src/**/*.ts"]
5142
},
5243
"lock": false,
53-
"exclude": [
54-
"./coverage",
55-
"./dist/browser",
56-
"./dist/esm",
57-
"./npm"
58-
]
44+
"exclude": ["./coverage", "./dist/browser", "./dist/esm", "./npm"]
5945
}

src/pools/abstract-pool.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,11 +1329,9 @@ export abstract class AbstractPool<
13291329
try {
13301330
await this.destroyWorkerNode(workerNodeKey)
13311331
} catch (error) {
1332-
if (this.eventTarget != null) {
1333-
this.eventTarget.dispatchEvent(
1334-
new ErrorEvent(PoolEvents.error, { error }),
1335-
)
1336-
}
1332+
this.eventTarget?.dispatchEvent(
1333+
new ErrorEvent(PoolEvents.error, { error }),
1334+
)
13371335
}
13381336
}),
13391337
)
@@ -1637,23 +1635,17 @@ export abstract class AbstractPool<
16371635
this.eventTarget?.dispatchEvent(
16381636
new ErrorEvent(PoolEvents.error, errorEvent),
16391637
)
1640-
if (
1641-
this.started &&
1642-
!this.destroying &&
1643-
this.opts.restartWorkerOnError === true
1644-
) {
1645-
if (workerNode.info.dynamic) {
1646-
this.createAndSetupDynamicWorkerNode()
1647-
} else if (!this.startingMinimumNumberOfWorkers) {
1648-
this.startMinimumNumberOfWorkers(true)
1638+
if (this.started && !this.destroying) {
1639+
if (this.opts.restartWorkerOnError === true) {
1640+
if (workerNode.info.dynamic) {
1641+
this.createAndSetupDynamicWorkerNode()
1642+
} else if (!this.startingMinimumNumberOfWorkers) {
1643+
this.startMinimumNumberOfWorkers(true)
1644+
}
1645+
}
1646+
if (this.opts.enableTasksQueue === true) {
1647+
this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode))
16491648
}
1650-
}
1651-
if (
1652-
this.started &&
1653-
!this.destroying &&
1654-
this.opts.enableTasksQueue === true
1655-
) {
1656-
this.redistributeQueuedTasks(this.workerNodes.indexOf(workerNode))
16571649
}
16581650
workerNode?.terminate()
16591651
}

0 commit comments

Comments
 (0)