Skip to content

Commit

Permalink
sync spec and implementation of autoAllocateChunkSize
Browse files Browse the repository at this point in the history
autoAllocateChunkSize was added in whatwg#430 as commit e601d69.

The spec was out of sync with the reference implementation: it tried to round
non-integers into integers instead of rejecting them.

The reference implementation was out of sync with the spec: it was allowing
an autoAllocateChunkSize of 0 through instead of throwing a RangeError.
  • Loading branch information
isonmad committed Nov 3, 2016
1 parent 9312f2c commit 0d0b7de
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1860,8 +1860,7 @@ ReadableByteStreamController(<var>stream</var>, <var>underlyingByteSource</var>,
1. Set *this*.[[strategyHWM]] to ? ValidateAndNormalizeHighWaterMark(_highWaterMark_).
1. Let _autoAllocateChunkSize_ be ? GetV(_underlyingByteSource_, `"autoAllocateChunkSize"`).
1. If _autoAllocateChunkSize_ is not *undefined*,
1. Set _autoAllocateChunkSize_ to ? ToInteger(_autoAllocateChunkSize_).
1. If _autoAllocateChunkSize_ ≤ *0*, or if _autoAllocateChunkSize_ is *+∞* or *−∞*, throw a *RangeError* exception.
1. If ! IsInteger(_autoAllocateChunkSize_) is *false*, or if _autoAllocateChunkSize_ ≤ *0*, throw a *RangeError* exception.
1. Set *this*.[[autoAllocateChunkSize]] to _autoAllocateChunkSize_.
1. Set *this*.[[pendingPullIntos]] to a new empty List.
1. Let _controller_ be *this*.
Expand Down
2 changes: 1 addition & 1 deletion reference-implementation/lib/readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ class ReadableByteStreamController {

const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
if (autoAllocateChunkSize !== undefined) {
if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize < 0) {
if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) {
throw new RangeError('autoAllocateChunkSize must be a non negative integer');
}
}
Expand Down

0 comments on commit 0d0b7de

Please sign in to comment.