const { readable, writable } = new TransformStream(transformer?: any, writableStrategy?: WritableStrategy);
Parameter | Type | Required | Description |
transformer | any | No | This parameter is not supported. The values do not take effect and are ignored automatically. |
writableStrategy | No | The strategy for the writable side. |
Parameter | Type | Required | Description |
highWaterMark | number | Yes | The size of the writable buffer in bytes. Default value: 32K. Maximum value: 256K. If you enter a value greater than 256K, the value is changed to 256K automatically. |
readonly readable: ReadableStream;
readonly writable: WritableStream;
async function handleEnterRoom() {// Generate readable streams and writeable streams.const { readable, writable } = new TransformStream();// Fetch a remote resource.const response = await fetch('https://www.tencentcloud.com/');// Respond to the client in streaming mode.response.body.pipeTo(writable);return new Response(readable, response);}addEventListener('fetch', (event) => {event.respondWith(handleEvent(event));});
Was this page helpful?