WritableStream.locked

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since June 2022.

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
# ref-for-ws-locked②

浏览器兼容性

BCD tables only load in the browser