From bd057655fef1fde15a3e64b08a1b48c27fce1309 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Wed, 14 Sep 2016 09:49:58 -0700 Subject: [PATCH] style: Move prototype setup to right after Buffer constructor --- index.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 0fcd80a..a51caae 100644 --- a/index.js +++ b/index.js @@ -113,6 +113,18 @@ function Buffer (arg, encodingOrOffset, length) { return from(this, arg, encodingOrOffset, length) } +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} Buffer.poolSize = 8192 // not used by this implementation // TODO: Legacy, not needed anymore. Remove in next major version. @@ -149,19 +161,6 @@ Buffer.from = function (value, encodingOrOffset, length) { return from(null, value, encodingOrOffset, length) } -if (Buffer.TYPED_ARRAY_SUPPORT) { - Buffer.prototype.__proto__ = Uint8Array.prototype - Buffer.__proto__ = Uint8Array - if (typeof Symbol !== 'undefined' && Symbol.species && - Buffer[Symbol.species] === Buffer) { - // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 - Object.defineProperty(Buffer, Symbol.species, { - value: null, - configurable: true - }) - } -} - function assertSize (size) { if (typeof size !== 'number') { throw new TypeError('"size" argument must be a number') -- 2.34.1