Skip to content

Commit d4e46df

Browse files
Filip Mösnerpanther7
authored andcommitted
Fixed deprecation warning for new Buffer
1 parent 42e5a9c commit d4e46df

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

‎src/reader.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,9 @@ Reader.prototype.bytes = function read_bytes() {
313313
if (Array.isArray(this.buf)) // plain array
314314
return this.buf.slice(start, end);
315315
return start === end // fix for IE 10/Win8 and others' subarray returning array of size 1
316-
? new this.buf.constructor(0)
316+
? (typeof Buffer.alloc === "function")
317+
? Buffer.alloc(0)
318+
: new this.buf.constructor(0)
317319
: this._slice.call(this.buf, start, end);
318320
};
319321

0 commit comments

Comments
 (0)