From 6b92cf350bb7d417dbbc394e800981ad7745221c Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 19 Apr 2016 22:48:28 -0700 Subject: [PATCH] IE10 fix: don't pass undefined length to typed array constructor --- index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 12a7190..83842a2 100644 --- a/index.js +++ b/index.js @@ -252,17 +252,19 @@ function fromArrayBuffer (that, array, byteOffset, length) { throw new RangeError('\'length\' is out of bounds') } + if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + if (Buffer.TYPED_ARRAY_SUPPORT) { // Return an augmented `Uint8Array` instance, for best performance - if (length === undefined) { - that = new Uint8Array(array, byteOffset) - } else { - that = new Uint8Array(array, byteOffset, length) - } + that = array that.__proto__ = Buffer.prototype } else { // Fallback: Return an object instance of the Buffer class - that = fromArrayLike(that, new Uint8Array(array, byteOffset, length)) + that = fromArrayLike(that, array) } return that } -- 2.34.1