tencent cloud

All product documents
Tencent Cloud EdgeOne
TransformStream
Last updated: 2024-01-30 15:32:47
TransformStream
Last updated: 2024-01-30 15:32:47
A TransformStream consists of a readable stream and a writable stream. It is designed based on the standard Web API TransformStream.

Constructor API

const { readable, writable } = new TransformStream(transformer?: any, writableStrategy?: WritableStrategy);

Parameters

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.

WritableStrategy

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.

Attributes

readable

readonly readable: ReadableStream;
The readable stream. For more information, see ReadableStream.

writable

readonly writable: WritableStream;
The writable stream. For more information, see WritableStream.

Sample Code

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));
});

References

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon