From bdc8006a362b4f95107a25ca816dcdedb7f44e4a Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 15 Feb 2022 13:35:22 +0100 Subject: feat(runtime): web streams in fs & net APIs (#13615) This commit adds `readable` and `writable` properties to `Deno.File` and `Deno.Conn`. This makes it very simple to use files and network sockets with fetch or the native HTTP server. --- cli/dts/lib.deno.ns.d.ts | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'cli/dts') diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts index f24e2feca..ff8fbb741 100644 --- a/cli/dts/lib.deno.ns.d.ts +++ b/cli/dts/lib.deno.ns.d.ts @@ -1092,14 +1092,26 @@ declare namespace Deno { stat(): Promise; statSync(): FileInfo; close(): void; + + readonly readable: ReadableStream; + readonly writable: WritableStream; } /** A handle for `stdin`. */ - export const stdin: Reader & ReaderSync & Closer & { readonly rid: number }; + export const stdin: Reader & ReaderSync & Closer & { + readonly rid: number; + readonly readable: ReadableStream; + }; /** A handle for `stdout`. */ - export const stdout: Writer & WriterSync & Closer & { readonly rid: number }; + export const stdout: Writer & WriterSync & Closer & { + readonly rid: number; + readonly writable: WritableStream; + }; /** A handle for `stderr`. */ - export const stderr: Writer & WriterSync & Closer & { readonly rid: number }; + export const stderr: Writer & WriterSync & Closer & { + readonly rid: number; + readonly writable: WritableStream; + }; export interface OpenOptions { /** Sets the option for read access. This option, when `true`, means that the @@ -2208,12 +2220,18 @@ declare namespace Deno { export class Process { readonly rid: number; readonly pid: number; - readonly stdin: T["stdin"] extends "piped" ? Writer & Closer - : (Writer & Closer) | null; - readonly stdout: T["stdout"] extends "piped" ? Reader & Closer - : (Reader & Closer) | null; - readonly stderr: T["stderr"] extends "piped" ? Reader & Closer - : (Reader & Closer) | null; + readonly stdin: T["stdin"] extends "piped" ? Writer & Closer & { + writable: WritableStream; + } + : (Writer & Closer & { writable: WritableStream }) | null; + readonly stdout: T["stdout"] extends "piped" ? Reader & Closer & { + readable: ReadableStream; + } + : (Reader & Closer & { readable: ReadableStream }) | null; + readonly stderr: T["stderr"] extends "piped" ? Reader & Closer & { + readable: ReadableStream; + } + : (Reader & Closer & { readable: ReadableStream }) | null; /** Wait for the process to exit and return its exit status. * * Calling this function multiple times will return the same status. -- cgit v1.2.3