Edge Developer Platform
  • Edge Functions
    • Overview
    • Getting Started
    • Operation Guide
      • Function Management
      • Function Trigger
    • Runtime APIs
      • addEventListener
      • Cache
      • Cookies
      • Encoding
      • Fetch
      • FetchEvent
      • Headers
      • Request
      • Response
      • Streams
        • ReadableStream
        • ReadableStreamBYOBReader
        • ReadableStreamDefaultReader
        • TransformStream
        • WritableStream
        • WritableStreamDefaultWriter
      • Web Crypto
      • Web standards
      • Images
        • ImageProperties
    • Sample Functions
      • Returning an HTML Page
      • Returning a JSON Object
      • Fetch Remote Resources
      • Authenticating a Request Header
      • Modifying a Response Header
      • Performing an A/B Test
      • Setting Cookies
      • Performing Redirect Based on the Request Location
      • Using the Cache API
      • Caching POST Requests
      • Responding in Streaming Mode
      • Merging Resources and Responding in Streaming Mode
      • Protecting Data from Tampering
      • Rewriting a m3u8 File and Configuring Authentication
      • Adaptive Image Resize
      • Image Adaptive WebP
      • Customize Referer restriction rules
      • Remote Authentication
      • HMAC Digital Signature
      • Naming a Downloaded File
      • Obtaining Client IP Address
    • Best Practices
      • Adaptive Image Format Conversion via Edge Functions
このページは現在英語版のみで提供されており、日本語版も近日中に提供される予定です。ご利用いただきありがとうございます。

TransformStream

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