From: Feross Aboukhadijeh Date: Fri, 18 Sep 2015 22:39:31 +0000 (-0700) Subject: standard X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=bc33ea4618e6846148e35aee78dfc28d999bdd1c;p=buffer.git standard --- diff --git a/index.js b/index.js index 5a68f2c..bc1183f 100644 --- a/index.js +++ b/index.js @@ -46,20 +46,22 @@ var rootParent = {} */ Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined ? global.TYPED_ARRAY_SUPPORT - : (function () { - function Bar () {} - try { - var arr = new Uint8Array(1) - arr.foo = function () { return 42 } - arr.constructor = Bar - return arr.foo() === 42 && // typed array instances can be augmented - arr.constructor === Bar && // constructor can be set - typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` - } catch (e) { - return false - } - })() + : typedArraySupport() + +function typedArraySupport () { + function Bar () {} + try { + var arr = new Uint8Array(1) + arr.foo = function () { return 42 } + arr.constructor = Bar + return arr.foo() === 42 && // typed array instances can be augmented + arr.constructor === Bar && // constructor can be set + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} function kMaxLength () { return Buffer.TYPED_ARRAY_SUPPORT