Streams
WritableStreamDefaultWriter 接口的只读属性 closed 返回一个 Promise,这个 promise 在流关闭时兑现,而在流抛出错误或者 writer 的锁被释放时拒绝。
值
一个 Promise。
示例
const writableStream = new WritableStream({
start(controller) {
},
write(chunk, controller) {
...
},
close(controller) {
...
},
abort(err) {
...
}
}, queuingStrategy);
...
const writer = writableStream.getWriter();
..
// check if the stream is closed
writer.closed.then(() => {
console.log('writer closed');
})
规范
浏览器兼容性
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
