From c765d9ad2fbd82be1b025cae3930fdfe8e30f9e2 Mon Sep 17 00:00:00 2001 From: Marvin Hagemeister Date: Wed, 14 Aug 2024 15:34:24 +0200 Subject: 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. --- ext/node/polyfills/inspector.ts | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'ext/node/polyfills') 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 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, -- cgit v1.2.3