ReadableStream.locked
ReadableStream
接口的只读属性 locked
返回可读流是否锁定到 reader。
一个可读流最多可以有一个激活的 reader,并且直到被释放之前都是锁定到该 reader。可以使用 ReadableStream.getReader()
方法获取 reader 然后使用 reader 的 releaseLock()
方法释放可读流。
值
一个布尔值,表示可读流是否已锁定。
示例
js
const stream = new ReadableStream({
...
});
const reader = stream.getReader();
stream.locked
// 应返回 true,表示流已经锁定到了一个 reader
规范
Specification |
---|
Streams # ref-for-rs-locked② |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
locked |
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.
参见
ReadableStream()
构造函数- 使用可读流