From 3639a98a97888477d1bc6b335fb27b48b550a751 Mon Sep 17 00:00:00 2001 From: adventure-yunfei Date: Thu, 3 Nov 2016 16:27:13 +0800 Subject: [PATCH] adventure-yunfei fix: wrong overwritting of not writable Unit8Array.from --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 7baf22a..70bb27a 100644 --- a/index.js +++ b/index.js @@ -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) { @@ -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') -- 2.34.1