From 57f423901b998b61a77ec5d65c1ce2cfcd554695 Mon Sep 17 00:00:00 2001 From: Parsha Pourkhomami Date: Tue, 7 Jul 2015 12:08:01 -0700 Subject: [PATCH] Ensure typed array constructor property can be set Otherwise set TYPED_ARRAY_SUPPORT to false and fallback to the object implementation. --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index da0a496..91ea5e9 100644 --- a/index.js +++ b/index.js @@ -39,11 +39,14 @@ var rootParent = {} * get the Object implementation, which is slower but will work correctly. */ Buffer.TYPED_ARRAY_SUPPORT = (function () { + function Foo () {} try { var buf = new ArrayBuffer(0) var arr = new Uint8Array(buf) arr.foo = function () { return 42 } - return arr.foo() === 42 && // typed array instances can be augmented + arr.constructor = Foo + return arr.constructor === Foo && // constructor can be set + arr.foo() === 42 && // typed array instances can be augmented typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { -- 2.34.1