diff options
-rw-r--r-- | ext/node/polyfills/inspector.ts | 26 | ||||
-rw-r--r-- | tests/unit_node/inspector_test.ts | 6 |
2 files changed, 12 insertions, 20 deletions
diff --git a/ext/node/polyfills/inspector.ts b/ext/node/polyfills/inspector.ts index 12ec05021..9de86ab14 100644 --- a/ext/node/polyfills/inspector.ts +++ b/ext/node/polyfills/inspector.ts @@ -1,26 +1,18 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. -// TODO(petamoriken): enable prefer-primordials for node polyfills -// deno-lint-ignore-file prefer-primordials - import { EventEmitter } from "node:events"; import { notImplemented } from "ext:deno_node/_utils.ts"; +import { primordials } from "ext:core/mod.js"; -const connectionSymbol = Symbol("connectionProperty"); -const messageCallbacksSymbol = Symbol("messageCallbacks"); -const nextIdSymbol = Symbol("nextId"); -const onMessageSymbol = Symbol("onMessage"); +const { + SafeMap, +} = primordials; class Session extends EventEmitter { - [connectionSymbol]: null; - [nextIdSymbol]: number; - [messageCallbacksSymbol]: Map<string, (e: Error) => void>; - - constructor() { - super(); - notImplemented("inspector.Session.prototype.constructor"); - } + #connection = null; + #nextId = 1; + #messageCallbacks = new SafeMap(); /** Connects the session to the inspector back-end. */ connect() { @@ -33,10 +25,6 @@ class Session extends EventEmitter { notImplemented("inspector.Session.prototype.connectToMainThread"); } - [onMessageSymbol](_message: string) { - notImplemented("inspector.Session.prototype[Symbol('onMessage')]"); - } - /** Posts a message to the inspector back-end. */ post( _method: string, diff --git a/tests/unit_node/inspector_test.ts b/tests/unit_node/inspector_test.ts index ec4d0ae3a..a53e977bb 100644 --- a/tests/unit_node/inspector_test.ts +++ b/tests/unit_node/inspector_test.ts @@ -1,7 +1,11 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import inspector from "node:inspector"; +import inspector, { Session } from "node:inspector"; import { assertEquals } from "@std/assert/equals"; Deno.test("[node/inspector] - importing inspector works", () => { assertEquals(typeof inspector.open, "function"); }); + +Deno.test("[node/inspector] - Session constructor should not throw", () => { + new Session(); +}); |