Skip to content

Commit

Permalink
fix: deprecation warning for new Buffer (#1905)
Browse files Browse the repository at this point in the history
Co-authored-by: Filip Mösner <filip.mosner@firma.seznam.cz>
  • Loading branch information
panther7 and Filip Mösner committed Aug 21, 2023
1 parent eaf9f0a commit e93286e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/reader.js
Expand Up @@ -312,9 +312,14 @@ Reader.prototype.bytes = function read_bytes() {
this.pos += length;
if (Array.isArray(this.buf)) // plain array
return this.buf.slice(start, end);
return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
? new this.buf.constructor(0)
: this._slice.call(this.buf, start, end);

if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
var nativeBuffer = util.Buffer;
return nativeBuffer
? nativeBuffer.alloc(0)
: new this.buf.constructor(0);
}
return this._slice.call(this.buf, start, end);
};

/**
Expand Down

0 comments on commit e93286e

Please sign in to comment.