Skip to content

Commit a1bd21f

Browse files
Filip Mösnerpanther7
authored andcommitted
Fixed deprecation warning for new Buffer
1 parent eaf9f0a commit a1bd21f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/reader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,11 @@ 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+
var nativeBuffer = util.Buffer;
315316
return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
316-
? new this.buf.constructor(0)
317+
? (nativeBuffer)
318+
? nativeBuffer.alloc(0)
319+
: new this.buf.constructor(0)
317320
: this._slice.call(this.buf, start, end);
318321
};
319322

0 commit comments

Comments
 (0)