WritableStreamDefaultWriter.desiredSize
WritableStreamDefaultWriter
接口的只读属性 desiredSize
返回填充满流的内部队列需要的大小。
值
一个整数。请注意,在队列已满的情况下,则可能是负数。
如果无法成功写入流(由于流发生错误或者中止入队),则该值为 null
,如果流关闭,则该值为 0。
异常
TypeError
-
writer 的锁已被释放。
示例
js
const writableStream = new WritableStream({
write(chunk) {
...
},
close() {
...
},
abort(err) {
...
}
}, queuingStrategy);
...
const writer = writableStream.getWriter();
...
// return stream's desired size
let size = writer.desiredSize;
规范
Specification |
---|
Streams # ref-for-default-writer-desired-size⑥ |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
desiredSize |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.