From: Feross Aboukhadijeh Date: Tue, 8 Apr 2014 08:19:54 +0000 (-0700) Subject: use simpler typedarray check X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=7380adce48b60d2e0f889dfd7411ef7873488fcb;p=buffer.git use simpler typedarray check --- diff --git a/index.js b/index.js index c4ad66d..15e8ad5 100644 --- a/index.js +++ b/index.js @@ -90,10 +90,7 @@ function Buffer (subject, encoding, noZero) { } var i - if (Buffer._useTypedArrays && (subject instanceof Uint8Array - || subject instanceof Uint16Array || subject instanceof Int16Array - || subject instanceof Uint32Array || subject instanceof Int32Array - || subject instanceof Float32Array || subject instanceof Float64Array)) { + if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') { // Speed optimization -- use set if we're copying from a typed array buf._set(subject) } else if (isArrayish(subject)) {