diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-08-14 15:34:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-14 13:34:24 +0000 |
commit | c765d9ad2fbd82be1b025cae3930fdfe8e30f9e2 (patch) | |
tree | 77f80cd073fc66ab6e00c27637f36dde7b7e7b32 /ext/node | |
parent | 130a2592f1e946be563c7f167d7127f49a1014d1 (diff) |
fix(node/inspector): Session constructor should not throw (#25041)
There is no constructor code when creating an inspector `Session`
instance in Node. Also get rid of some symbols which should've been
private properties. This PR doesn't yet add any new implementations
though as these are mostly cosmetic changes.
Diffstat (limited to 'ext/node')
-rw-r--r-- | ext/node/polyfills/inspector.ts | 26 |
1 files changed, 7 insertions, 19 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, |