Files
bun.sh/src/bun.js/inspector.exports.js
Jarred Sumner fcd8b82864 Add stubs for missing node builtins (#2534)
* Stub `node:v8`

* Stub `node:trace_events`

* Stub `node:repl`

* Stub `node:inspector`

* Stub `node:http2`

* Stub `node:diagnostics_channel`

* Stub `node:dgram`

* Stub `node:cluster`

* Link stubs

* cleanup

* Clean up the test

* Implement `node:vm` stub

* Cleanup `v8` module stub

* Add missing `promises` export to node:stream

* Implement `node:stream/promise`

* Implement `node:assert/strict`

* cleanup

* better errors

* Increaase timeout

* Update inspector.exports.js

* Make the version consistent

* Implement `process.binding("constants")`

* Update runner.node.mjs

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-04-01 21:13:27 -07:00

69 lines
1.4 KiB
JavaScript

// This is a stub! None of this is actually implemented yet.
function hideFromStack(fns) {
for (const fn of fns) {
Object.defineProperty(fn, "name", {
value: "::bunternal::",
});
}
}
class TODO extends Error {
constructor(messageName) {
const message = messageName
? `node:inspector ${messageName} is not implemented yet in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/2445`
: `node:inspector is not implemented yet in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/2445`;
super(message);
this.name = "TODO";
}
}
function notimpl(message) {
throw new TODO(message);
}
const { EventEmitter } = import.meta.require("node:events");
function open() {
notimpl("open");
}
function close() {
notimpl("close");
}
function url() {
notimpl("url");
}
function waitForDebugger() {
notimpl("waitForDebugger");
}
class Session extends EventEmitter {
constructor() {
super();
notimpl("Session");
}
}
const console = {
...globalThis.console,
context: {
console: globalThis.console,
},
};
var defaultObject = {
console,
open,
close,
url,
waitForDebugger,
Session,
[Symbol.for("CommonJS")]: 0,
};
export { console, open, close, url, waitForDebugger, Session, defaultObject as default };
hideFromStack([notimpl, TODO.prototype.constructor, open, close, url, waitForDebugger, Session.prototype.constructor]);