此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

TransformStreamDefaultController.desiredSize

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2022年6月⁩.

Invalid slug for templ/sidebar: Streams API

TransformStreamDefaultController 接口的只读属性 desiredSize 返回填充满关联的 ReadableStream 的内部队列所需要的大小。

ReadableStream 的内部队列包含已入队但尚未读取的分块。浏览器确定填满流所需要的大小,并且这个值由 desiredSize 属性返回。

如果这个 desiredSize0,则队列已满。因此你可以使用这个信息去手动管理背压去管理队列。

所需的大小。

示例

在下面的示例中,desiredSize 被打印到控制台。

js
console.log(controller.desiredSize);

规范

Specification
Streams
# ts-default-controller-desired-size

浏览器兼容性