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

adventure-yunfei fix: wrong overwritting of not writable Unit8Array.from #148

Merged
merged 1 commit into from
Dec 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ function Buffer (arg, encodingOrOffset, length) {
return from(arg, encodingOrOffset, length)
}

Buffer.prototype.__proto__ = Uint8Array.prototype
Buffer.__proto__ = Uint8Array

// Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
if (typeof Symbol !== 'undefined' && Symbol.species &&
Buffer[Symbol.species] === Buffer) {
Expand Down Expand Up @@ -128,6 +125,10 @@ Buffer.from = function (value, encodingOrOffset, length) {
return from(value, encodingOrOffset, length)
}

Buffer.prototype.__proto__ = Uint8Array.prototype
// Assign Uint8Array as proto AFTER setting Buffer.from
Buffer.__proto__ = Uint8Array

function assertSize (size) {
if (typeof size !== 'number') {
throw new TypeError('"size" argument must be a number')
Expand Down