From 2e45dc60775efdd142b0df886fb48a333c856990 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 30 Jul 2015 00:41:34 -0700 Subject: [PATCH] more compact typed array feature detection --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c018fee..7b7b02c 100644 --- a/index.js +++ b/index.js @@ -46,14 +46,13 @@ var rootParent = {} Buffer.TYPED_ARRAY_SUPPORT = (function () { function Bar () {} try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) + 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` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { return false } -- 2.34.1