Skip to content

Commit

Permalink
Fixed deprecation warning for new Buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Filip Mösner authored and panther7 committed Aug 21, 2023
1 parent eaf9f0a commit a1bd21f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,11 @@ Reader.prototype.bytes = function read_bytes() {
this.pos += length;
if (Array.isArray(this.buf)) // plain array
return this.buf.slice(start, end);
var nativeBuffer = util.Buffer;
return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
? new this.buf.constructor(0)
? (nativeBuffer)
? nativeBuffer.alloc(0)
: new this.buf.constructor(0)
: this._slice.call(this.buf, start, end);
};

Expand Down

0 comments on commit a1bd21f

Please sign in to comment.