From: Feross Aboukhadijeh Date: Fri, 15 Jul 2016 06:55:51 +0000 (-0700) Subject: Fix TypeError: Could not convert argument 1 to a number (fix #123) X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=f1a9e11e4813d63a54b7097414d26cd21bce6a89;p=buffer.git Fix TypeError: Could not convert argument 1 to a number (fix #123) --- diff --git a/index.js b/index.js index 933a972..f04a7dd 100644 --- a/index.js +++ b/index.js @@ -252,7 +252,9 @@ function fromArrayBuffer (that, array, byteOffset, length) { throw new RangeError('\'length\' is out of bounds') } - if (length === undefined) { + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { array = new Uint8Array(array, byteOffset) } else { array = new Uint8Array(array, byteOffset, length)