Skip to content

Commit 1ab4d49

Browse files
committed
Update Stream documentation
- Use the module syntax over - TransformStream -> ReadableStream - let -> const where applicable
1 parent eb9d463 commit 1ab4d49

File tree

1 file changed

+7
-7
lines changed
  • src/content/docs/workers/runtime-apis/streams

1 file changed

+7
-7
lines changed

src/content/docs/workers/runtime-apis/streams/index.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The [Streams API](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
1515

1616
<DirectoryListing />
1717

18-
Workers do not need to prepare an entire response body before delivering it to `event.respondWith()`. You can use [`TransformStream`](/workers/runtime-apis/streams/transformstream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize:
18+
Workers do not need to prepare an entire response body before returning a `Response`. You can use a [`ReadableStream`](/workers/runtime-apis/streams/readablestream/) to stream a response body after sending the front matter (that is, HTTP status line and headers). This allows you to minimize:
1919

2020
* The visitor’s time-to-first-byte.
2121
* The buffering done in the Worker.
@@ -39,7 +39,7 @@ The worker can create a `Response` object using a `ReadableStream` as the body.
3939
export default {
4040
async fetch(request, env, ctx) {
4141
// Fetch from origin server.
42-
let response = await fetch(request);
42+
const response = await fetch(request);
4343

4444
// ... and deliver our Response while that’s running.
4545
return new Response(response.body, response);
@@ -56,7 +56,7 @@ addEventListener('fetch', event => {
5656

5757
async function fetchAndStream(request) {
5858
// Fetch from origin server.
59-
let response = await fetch(request);
59+
const response = await fetch(request);
6060

6161
// ... and deliver our Response while that’s running.
6262
return new Response(readable.body, response);
@@ -73,9 +73,9 @@ A [`TransformStream`](/workers/runtime-apis/streams/transformstream/) and the [`
7373
export default {
7474
async fetch(request, env, ctx) {
7575
// Fetch from origin server.
76-
let response = await fetch(request);
76+
const response = await fetch(request);
7777

78-
let { readable, writable } = new TransformStream({
78+
const { readable, writable } = new TransformStream({
7979
transform(chunk, controller) {
8080
controller.enqueue(modifyChunkSomehow(chunk));
8181
}
@@ -99,9 +99,9 @@ addEventListener('fetch', event => {
9999

100100
async function fetchAndStream(request) {
101101
// Fetch from origin server.
102-
let response = await fetch(request);
102+
const response = await fetch(request);
103103

104-
let { readable, writable } = new TransformStream({
104+
const { readable, writable } = new TransformStream({
105105
transform(chunk, controller) {
106106
controller.enqueue(modifyChunkSomehow(chunk));
107107
}

0 commit comments

Comments
 (0)