You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/ndarray/vector/ctor/lib/main.js
+17-8Lines changed: 17 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -165,7 +165,7 @@ function arraybuffer2vector( dtype, buffer, length, stride, byteOffset, order, o
165
165
N=length*stride;
166
166
167
167
// Adjust the byte offset to point to the element marking the beginning of the view:
168
-
if(stride<0){
168
+
if(stride<0){// TODO: the following is effectively unreachable code, as provided strides are never anything other than unity; however, we keep this around in the event that we want to extract this function to a separate package and would like to maintain generality
169
169
N*=-1;
170
170
o-=N*bytesPerElement(dtype);
171
171
}
@@ -483,6 +483,9 @@ function vector() {
483
483
if(nargs===2){
484
484
// Case: vector( dtype, options )
485
485
if(isDataType(arg0)){
486
+
if(arg1===null){
487
+
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',arg1));
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',arg1));
509
+
}
504
510
out=vectorWithDType(arg0,DEFAULT_DTYPE,arg1);
505
511
if(out===null){
506
512
thrownewTypeError(format('invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.',arg0));
@@ -523,6 +529,9 @@ function vector() {
523
529
}
524
530
// Case: vector( arg0, dtype, options )
525
531
if(isDataType(arg1)){
532
+
if(arg2===null){
533
+
thrownewTypeError(format('invalid argument. Options argument must be an object. Value: `%s`.',arg2));
534
+
}
526
535
out=vectorWithDType(arg0,arg1,arg2);
527
536
if(out===null){
528
537
thrownewTypeError(format('invalid argument. First argument must be a length, ArrayBuffer, typed array, array-like object, or iterable. Value: `%s`.',arg0));
@@ -536,15 +545,15 @@ function vector() {
536
545
if(!isNonNegativeInteger(arg1)){
537
546
thrownewTypeError(format('invalid argument. Byte offset must be a nonnegative integer. Value: `%s`.',arg1));
0 commit comments