Skip to content

Commit

Permalink
Properly coerce mode to a string in getReader()
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Mar 30, 2017
1 parent 69457fe commit de3179e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.bs
Expand Up @@ -514,8 +514,9 @@ ReadableStream(<var>underlyingSource</var> = {}, { <var>size</var>, <var>highWat

<emu-alg>
1. If ! IsReadableStream(*this*) is *false*, throw a *TypeError* exception.
1. If _mode_ is `"byob"`, return ? AcquireReadableStreamBYOBReader(*this*).
1. If _mode_ is *undefined*, return ? AcquireReadableStreamDefaultReader(*this*).
1. Set _mode_ to ? ToString(_mode_).
1. If _mode_ is `"byob"`, return ? AcquireReadableStreamBYOBReader(*this*).
1. Throw a *RangeError* exception.
</emu-alg>

Expand Down
10 changes: 6 additions & 4 deletions reference-implementation/lib/readable-stream.js
Expand Up @@ -69,14 +69,16 @@ class ReadableStream {
throw streamBrandCheckException('getReader');
}

if (mode === 'byob') {
return AcquireReadableStreamBYOBReader(this);
}

if (mode === undefined) {
return AcquireReadableStreamDefaultReader(this);
}

mode = String(mode);

if (mode === 'byob') {
return AcquireReadableStreamBYOBReader(this);
}

throw new RangeError('Invalid mode is specified');
}

Expand Down

1 comment on commit de3179e

@ricea
Copy link
Collaborator

@ricea ricea commented on de3179e Mar 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Please sign in to comment.