summaryrefslogtreecommitdiff
path: root/ext/net/01_net.js
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-25 08:12:10 +1100
committerGitHub <noreply@github.com>2024-01-24 22:12:10 +0100
commitfc176c4dea7463d587a1e921780cce55552e0c86 (patch)
tree88e996655b20e796571db38896d4db27fcfe54b7 /ext/net/01_net.js
parent176118a0468c5b4f2117d18271d814000d4752b2 (diff)
feat: deprecate `Deno.{Conn,TcpConn,TlsConn,UnixConn}.rid` (#22077)
For removal in Deno v2. Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/net/01_net.js')
-rw-r--r--ext/net/01_net.js55
1 files changed, 46 insertions, 9 deletions
diff --git a/ext/net/01_net.js b/ext/net/01_net.js
index 73d8bad49..a2b04de76 100644
--- a/ext/net/01_net.js
+++ b/ext/net/01_net.js
@@ -106,6 +106,11 @@ class Conn {
}
get rid() {
+ internals.warnOnDeprecatedApi(
+ "Deno.Conn.rid",
+ new Error().stack,
+ "Use `Deno.Conn` instance methods instead.",
+ );
return this.#rid;
}
@@ -118,14 +123,14 @@ class Conn {
}
write(p) {
- return write(this.rid, p);
+ return write(this.#rid, p);
}
async read(buffer) {
if (buffer.length === 0) {
return 0;
}
- const promise = core.read(this.rid, buffer);
+ const promise = core.read(this.#rid, buffer);
if (this.#unref) core.unrefOpPromise(promise);
SetPrototypeAdd(this.#pendingReadPromises, promise);
let nread;
@@ -140,16 +145,16 @@ class Conn {
}
close() {
- core.close(this.rid);
+ core.close(this.#rid);
}
closeWrite() {
- return shutdown(this.rid);
+ return shutdown(this.#rid);
}
get readable() {
if (this.#readable === undefined) {
- this.#readable = readableStreamForRidUnrefable(this.rid);
+ this.#readable = readableStreamForRidUnrefable(this.#rid);
if (this.#unref) {
readableStreamForRidUnrefableUnref(this.#readable);
}
@@ -159,7 +164,7 @@ class Conn {
get writable() {
if (this.#writable === undefined) {
- this.#writable = writableStreamForRid(this.rid);
+ this.#writable = writableStreamForRid(this.#rid);
}
return this.#writable;
}
@@ -193,16 +198,48 @@ class Conn {
}
class TcpConn extends Conn {
+ #rid = 0;
+
+ constructor(rid, remoteAddr, localAddr) {
+ super(rid, remoteAddr, localAddr);
+ this.#rid = rid;
+ }
+
+ get rid() {
+ internals.warnOnDeprecatedApi(
+ "Deno.TcpConn.rid",
+ new Error().stack,
+ "Use `Deno.TcpConn` instance methods instead.",
+ );
+ return this.#rid;
+ }
+
setNoDelay(noDelay = true) {
- return op_set_nodelay(this.rid, noDelay);
+ return op_set_nodelay(this.#rid, noDelay);
}
setKeepAlive(keepAlive = true) {
- return op_set_keepalive(this.rid, keepAlive);
+ return op_set_keepalive(this.#rid, keepAlive);
}
}
-class UnixConn extends Conn {}
+class UnixConn extends Conn {
+ #rid = 0;
+
+ constructor(rid, remoteAddr, localAddr) {
+ super(rid, remoteAddr, localAddr);
+ this.#rid = rid;
+ }
+
+ get rid() {
+ internals.warnOnDeprecatedApi(
+ "Deno.UnixConn.rid",
+ new Error().stack,
+ "Use `Deno.UnixConn` instance methods instead.",
+ );
+ return this.#rid;
+ }
+}
class Listener {
#rid = 0;