summaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
Diffstat (limited to 'std')
-rw-r--r--std/io/README.md34
-rw-r--r--std/io/mod.ts1
2 files changed, 35 insertions, 0 deletions
diff --git a/std/io/README.md b/std/io/README.md
index 2432a468b..ead1d1d4c 100644
--- a/std/io/README.md
+++ b/std/io/README.md
@@ -123,3 +123,37 @@ console.log(w.toString()); // base0123456789
base0123
base0123456789
```
+
+## Streams
+
+### fromStreamReader
+
+Creates a `Reader` from a `ReadableStreamDefaultReader`
+
+```ts
+import { fromStreamReader } from "https://deno.land/std/io/mod.ts";
+const res = await fetch("https://deno.land");
+const file = await Deno.open("./deno.land.html", { create: true, write: true });
+
+const reader = fromStreamReader(res.body!.getReader());
+await Deno.copy(reader, file);
+file.close();
+```
+
+### fromStreamWriter
+
+Creates a `Writer` from a `WritableStreamDefaultWriter`
+
+```ts
+import { fromStreamWriter } from "https://deno.land/std/io/mod.ts";
+const file = await Deno.open("./deno.land.html", { read: true });
+
+const writableStream = new WritableStream({
+ write(chunk): void {
+ console.log(chunk);
+ },
+});
+const writer = fromStreamWriter(writableStream.getWriter());
+await Deno.copy(file, writer);
+file.close();
+```
diff --git a/std/io/mod.ts b/std/io/mod.ts
index ca07bac43..f92feb6ef 100644
--- a/std/io/mod.ts
+++ b/std/io/mod.ts
@@ -2,3 +2,4 @@ export * from "./bufio.ts";
export * from "./ioutil.ts";
export * from "./readers.ts";
export * from "./writers.ts";
+export * from "./streams.ts";