Skip to content

Commit e93286e

Browse files
panther7Filip Mösner
and
Filip Mösner
authored
fix: deprecation warning for new Buffer (#1905)
Co-authored-by: Filip Mösner <[email protected]>
1 parent eaf9f0a commit e93286e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Diff for: src/reader.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,14 @@ Reader.prototype.bytes = function read_bytes() {
312312
this.pos += length;
313313
if (Array.isArray(this.buf)) // plain array
314314
return this.buf.slice(start, end);
315-
return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
316-
? new this.buf.constructor(0)
317-
: this._slice.call(this.buf, start, end);
315+
316+
if (start === end) { // fix for IE 10/Win8 and others' subarray returning array of size 1
317+
var nativeBuffer = util.Buffer;
318+
return nativeBuffer
319+
? nativeBuffer.alloc(0)
320+
: new this.buf.constructor(0);
321+
}
322+
return this._slice.call(this.buf, start, end);
318323
};
319324

320325
/**

0 commit comments

Comments
 (0)