]> zoso.dev Git - buffer.git/commitdiff
Fix TypeError: Could not convert argument 1 to a number (fix #123)
authorFeross Aboukhadijeh <feross@feross.org>
Fri, 15 Jul 2016 06:55:51 +0000 (23:55 -0700)
committerFeross Aboukhadijeh <feross@feross.org>
Fri, 15 Jul 2016 06:55:51 +0000 (23:55 -0700)
index.js

index 933a972789f6469aae5263a109c59cf21d72d5cf..f04a7ddf8e5ace1b722b235758aca112c796e092 100644 (file)
--- 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)