1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

refactor: make 'rid' properties non-enumerable (#22137)

Now these props will not show up when inspecting objects in console.
This commit is contained in:
Bartek Iwańczuk 2024-01-26 23:19:00 +01:00 committed by GitHub
parent 942fb5e038
commit 6109717c4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 14 deletions

View file

@ -83,6 +83,7 @@ const {
Function, Function,
MathTrunc, MathTrunc,
ObjectEntries, ObjectEntries,
ObjectDefineProperty,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
ObjectValues, ObjectValues,
StringPrototypeSlice, StringPrototypeSlice,
@ -656,14 +657,16 @@ function create(path) {
} }
class FsFile { class FsFile {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
#readable; #readable;
#writable; #writable;
constructor(rid, symbol) { constructor(rid, symbol) {
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) { if (!symbol || symbol !== SymbolFor("Deno.internal.FsFile")) {
internals.warnOnDeprecatedApi( internals.warnOnDeprecatedApi(

View file

@ -34,6 +34,7 @@ const {
Error, Error,
Number, Number,
ObjectPrototypeIsPrototypeOf, ObjectPrototypeIsPrototypeOf,
ObjectDefineProperty,
PromiseResolve, PromiseResolve,
SafeSet, SafeSet,
SetPrototypeAdd, SetPrototypeAdd,
@ -91,7 +92,6 @@ async function resolveDns(query, recordType, options) {
} }
class Conn { class Conn {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
#remoteAddr = null; #remoteAddr = null;
#localAddr = null; #localAddr = null;
@ -102,7 +102,10 @@ class Conn {
#writable; #writable;
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
this.#remoteAddr = remoteAddr; this.#remoteAddr = remoteAddr;
this.#localAddr = localAddr; this.#localAddr = localAddr;
@ -201,12 +204,14 @@ class Conn {
} }
class TcpConn extends Conn { class TcpConn extends Conn {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
} }
@ -229,12 +234,14 @@ class TcpConn extends Conn {
} }
class UnixConn extends Conn { class UnixConn extends Conn {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
} }
@ -249,14 +256,16 @@ class UnixConn extends Conn {
} }
class Listener { class Listener {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
#addr = null; #addr = null;
#unref = false; #unref = false;
#promise = null; #promise = null;
constructor(rid, addr) { constructor(rid, addr) {
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
this.#addr = addr; this.#addr = addr;
} }

View file

@ -11,6 +11,7 @@ const {
} = core.ensureFastOps(); } = core.ensureFastOps();
const { const {
Number, Number,
ObjectDefineProperty,
TypeError, TypeError,
} = primordials; } = primordials;
@ -25,12 +26,14 @@ function opTlsHandshake(rid) {
} }
class TlsConn extends Conn { class TlsConn extends Conn {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
constructor(rid, remoteAddr, localAddr) { constructor(rid, remoteAddr, localAddr) {
super(rid, remoteAddr, localAddr); super(rid, remoteAddr, localAddr);
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
} }
@ -78,12 +81,14 @@ async function connectTls({
} }
class TlsListener extends Listener { class TlsListener extends Listener {
[internalRidSymbol] = 0;
#rid = 0; #rid = 0;
constructor(rid, addr) { constructor(rid, addr) {
super(rid, addr); super(rid, addr);
this[internalRidSymbol] = rid; ObjectDefineProperty(this, internalRidSymbol, {
enumerable: false,
value: rid,
});
this.#rid = rid; this.#rid = rid;
} }