WritableStream.locked

Baseline 2022

Newly available

Since June 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

WritableStream 接口的只读属性 locked 返回一个布尔值,表示 WritableStream 是否锁定到一个 writer。

一个布尔值,表示可写流是否已锁定。

示例

js
const writableStream = new WritableStream({
  write(chunk) {
    ...
  },
  close() {
    ...
  },
  abort(err) {
    ...
  }
}, queuingStrategy);
...
const writer = writableStream.getWriter();
writableStream.locked
// should return true, as the stream has been locked to a writer

规范

Specification
Streams Standard
# ref-for-ws-locked②

浏览器兼容性

BCD tables only load in the browser