Skip to content

Commit

Permalink
Fix errors in IE11
Browse files Browse the repository at this point in the history
* Polyfill Number.isNaN
* Don't create Symbol.asyncIterator if Symbol is not defined

Fixes #364
  • Loading branch information
jhiesey committed Sep 25, 2018
1 parent e890201 commit 8716539
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ function computeNewHighWaterMark(n) {
function howMuchToRead(n, state) {
if (n <= 0 || state.length === 0 && state.ended) return 0;
if (state.objectMode) return 1;
if (Number.isNaN(n)) {
// Equivalent to Number.isNaN() but works in IE11
if (n !== n) {
// Only flow one buffer at a time
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
}
Expand Down Expand Up @@ -941,11 +942,14 @@ Readable.prototype.wrap = function (stream) {
return this;
};

Readable.prototype[Symbol.asyncIterator] = function () {
emitExperimentalWarning('Readable[Symbol.asyncIterator]');
if (ReadableAsyncIterator === undefined) ReadableAsyncIterator = require('./internal/streams/async_iterator');
return new ReadableAsyncIterator(this);
};
// Only add asyncIterator if Symbol is available
if (typeof Symbol === 'function') {
Readable.prototype[Symbol.asyncIterator] = function () {
emitExperimentalWarning('Readable[Symbol.asyncIterator]');
if (ReadableAsyncIterator === undefined) ReadableAsyncIterator = require('./internal/streams/async_iterator');
return new ReadableAsyncIterator(this);
};
}

Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
// making it explicit this property is not enumerable
Expand Down

0 comments on commit 8716539

Please sign in to comment.