Skip to content

Commit 52abfd2

Browse files
committed
currentOutputCallbackのオプショナルチェーンを統一
1 parent 9a08803 commit 52abfd2

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

app/terminal/worker/jsEval.worker.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@ let currentOutputCallback: ((output: ReplOutput) => void) | null = null;
1616
const originalConsole = self.console;
1717
self.console = {
1818
...originalConsole,
19-
log: (...args: unknown[]) => {
20-
currentOutputCallback?.({ type: "stdout", message: format(...args) });
21-
},
22-
error: (...args: unknown[]) => {
23-
currentOutputCallback?.({ type: "stderr", message: format(...args) });
24-
},
25-
warn: (...args: unknown[]) => {
26-
currentOutputCallback?.({ type: "stderr", message: format(...args) });
27-
},
28-
info: (...args: unknown[]) => {
29-
currentOutputCallback?.({ type: "stdout", message: format(...args) });
30-
},
19+
log: (...args: unknown[]) =>
20+
currentOutputCallback?.({ type: "stdout", message: format(...args) }),
21+
error: (...args: unknown[]) =>
22+
currentOutputCallback?.({ type: "stderr", message: format(...args) }),
23+
warn: (...args: unknown[]) =>
24+
currentOutputCallback?.({ type: "stderr", message: format(...args) }),
25+
info: (...args: unknown[]) =>
26+
currentOutputCallback?.({ type: "stdout", message: format(...args) }),
3127
};
3228

3329
async function init(/*_interruptBuffer?: Uint8Array*/): Promise<{

app/terminal/worker/pyodide.worker.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,12 @@ async function init(
4747
pyodide = await (self as any).loadPyodide({ indexURL: PYODIDE_CDN });
4848

4949
pyodide.setStdout({
50-
batched: (str: string) => {
51-
if (currentOutputCallback) {
52-
currentOutputCallback({ type: "stdout", message: str });
53-
}
54-
},
50+
batched: (str: string) =>
51+
currentOutputCallback?.({ type: "stdout", message: str }),
5552
});
5653
pyodide.setStderr({
57-
batched: (str: string) => {
58-
if (currentOutputCallback) {
59-
currentOutputCallback({ type: "stderr", message: str });
60-
}
61-
},
54+
batched: (str: string) =>
55+
currentOutputCallback?.({ type: "stderr", message: str }),
6256
});
6357

6458
pyodide.setInterruptBuffer(interruptBuffer);

0 commit comments

Comments
 (0)