abstract operation: ReadFromReadableStream(stream) contains most of what we have now.
Has a [[stream]] internal slot.
Present as an intrinsic named %ReadableStreamLock%.
new ReadableStreamLock(stream)
- Brand-check that stream is a real ReadableStream.
- If stream@[[locked]] is true, throw TypeError
- Set this@[[stream]] to stream
- Set stream@[[locked]] to true
ReadableStreamLock.prototype.read()
- If this@[[stream]] is undefined, throw TypeError
- Return ReadFromReadableStream(this.[[stream]])
ReadableStreamLock.prototype.release()
- If this@[[stream]] is undefined, return.
- Set this@[[stream]]@[[locked]] to false.
- Set this@[[stream]] to undefined.
new ReadableStream(...)
- Set this@[[locked]] to false.
ReadableStream.prototype.read()
- If this@[[locked]] is true, throw a TypeError.
- Return ReadFromReadableStream(this).
ReadableStream.prototype.pipeTo(...)
- Add
var lock = new %ReadableStreamLock%(this)
- Use
lock.read()
throughout instead ofthis.read()
- One each branch that denotes a "finish" of the piping, i.e. each place that we fulfill or reject the return-value promise, call
lock.release()
. - May need some
try { ... } finally { ... }
s.
[optionally add] get ReadableStream.prototype.isLocked
- Return this@[[locked]].