Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editorial: add cross-links to internal slots
As part of this, we split out the common features of readable stream readers into the ReadableStreamGenericReader mixin. Despite this changing the IDL, it has no observable behavior changes. Inspired by #1048.
- Loading branch information
1 parent
6cd5e81
commit 1975208
Showing
8 changed files
with
898 additions
and
740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
reference-implementation/lib/ReadableStreamGenericReader-impl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const { promiseRejectedWith } = require('./helpers/webidl.js'); | ||
const aos = require('./abstract-ops/readable-streams.js'); | ||
|
||
exports.implementation = class ReadableStreamGenericReaderImpl { | ||
get closed() { | ||
return this._closedPromise; | ||
} | ||
|
||
cancel(reason) { | ||
if (this._stream === undefined) { | ||
return promiseRejectedWith(readerLockException('cancel')); | ||
} | ||
|
||
return aos.ReadableStreamReaderGenericCancel(this, reason); | ||
} | ||
}; | ||
|
||
function readerLockException(name) { | ||
return new TypeError('Cannot ' + name + ' a stream using a released reader'); | ||
} |
5 changes: 5 additions & 0 deletions
5
reference-implementation/lib/ReadableStreamGenericReader.webidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
interface mixin ReadableStreamGenericReader { | ||
readonly attribute Promise<void> closed; | ||
|
||
Promise<void> cancel(optional any reason); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters