Skip to content

Commit 8054bdb

Browse files
committed
utilのpolyfillではなくobject-inspectライブラリを使う
1 parent 5cdd0dd commit 8054bdb

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

app/terminal/worker/jsEval.worker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
import type { ReplOutput } from "../repl";
44
import type { MessageType, WorkerRequest, WorkerResponse } from "./runtime";
5-
import { format, inspect } from "util"; // <- これなぜブラウザ側でimportできるの? :thinking:
5+
import inspect from "object-inspect";
66

7+
function format(...args: unknown[]): string {
8+
// TODO: console.logの第1引数はフォーマット指定文字列を取ることができる
9+
// https://nodejs.org/api/util.html#utilformatformat-args
10+
return args.map((a) => (typeof a === "string" ? a : inspect(a))).join(" ");
11+
}
712
let jsOutput: ReplOutput[] = [];
813

914
// Helper function to capture console output

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"drizzle-orm": "^0.44.7",
3535
"mocha": "^11.7.4",
3636
"next": "<15.5",
37+
"object-inspect": "^1.13.4",
3738
"pg": "^8.16.3",
3839
"prismjs": "^1.30.0",
3940
"pyodide": "^0.29.0",
@@ -53,6 +54,7 @@
5354
"@types/chai": "^5.2.3",
5455
"@types/mocha": "^10.0.10",
5556
"@types/node": "^20",
57+
"@types/object-inspect": "^1.13.0",
5658
"@types/pg": "^8.15.5",
5759
"@types/prismjs": "^1.26.5",
5860
"@types/react": "^19",

0 commit comments

Comments
 (0)