Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed deprecation warning for new Buffer #1905

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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