From aadcf3346c25ed9d880c2bfc43b62aa075ea6126 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Tue, 10 Sep 2024 07:07:12 +1000 Subject: BREAKING(io): remove `Deno.{Reader,Writer}[Sync]` and `Deno.Closer` (#25524) --- ext/net/lib.deno_net.d.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'ext/net/lib.deno_net.d.ts') diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index f87f132ac..b2ffffa27 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -77,8 +77,57 @@ declare namespace Deno { export type UnixListener = Listener; /** @category Network */ - export interface Conn - extends Reader, Writer, Closer, Disposable { + export interface Conn extends Disposable { + /** Read the incoming data from the connection into an array buffer (`p`). + * + * Resolves to either the number of bytes read during the operation or EOF + * (`null`) if there was nothing more to read. + * + * It is possible for a read to successfully return with `0` bytes. This + * does not indicate EOF. + * + * **It is not guaranteed that the full buffer will be read in a single + * call.** + * + * ```ts + * // If the text "hello world" is received by the client: + * const conn = await Deno.connect({ hostname: "example.com", port: 80 }); + * const buf = new Uint8Array(100); + * const numberOfBytesRead = await conn.read(buf); // 11 bytes + * const text = new TextDecoder().decode(buf); // "hello world" + * ``` + * + * @category I/O + */ + read(p: Uint8Array): Promise; + /** Write the contents of the array buffer (`p`) to the connection. + * + * Resolves to the number of bytes written. + * + * **It is not guaranteed that the full buffer will be written in a single + * call.** + * + * ```ts + * const conn = await Deno.connect({ hostname: "example.com", port: 80 }); + * const encoder = new TextEncoder(); + * const data = encoder.encode("Hello world"); + * const bytesWritten = await conn.write(data); // 11 + * ``` + * + * @category I/O + */ + write(p: Uint8Array): Promise; + /** Closes the connection, freeing the resource. + * + * ```ts + * const conn = await Deno.connect({ hostname: "example.com", port: 80 }); + * + * // ... + * + * conn.close(); + * ``` + */ + close(): void; /** The local address of the connection. */ readonly localAddr: A; /** The remote address of the connection. */ -- cgit v1.2.3