Skip to content

Commit aa0a057

Browse files
committed
Auto-generated commit
1 parent 9aad113 commit aa0a057

File tree

3 files changed

+1250
-9
lines changed

3 files changed

+1250
-9
lines changed

index/lib/main.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,20 @@ function ArrayIndex( x ) {
8383

8484
// When provided a "generic" array or an array of an unknown data type, attempt to infer the type of index array...
8585
if ( dt === 'generic' || dt === null ) {
86-
get = resolveGetter( x );
87-
v = get( x, 0 );
88-
89-
// Infer the "type" of index array from the first element...
90-
if ( isBoolean( v ) ) {
91-
t = 'bool';
92-
} else if ( isInteger( v ) ) {
93-
t = 'int';
86+
if ( x.length > 0 ) {
87+
get = resolveGetter( x );
88+
v = get( x, 0 );
89+
90+
// Infer the "type" of index array from the first element...
91+
if ( isBoolean( v ) ) {
92+
t = 'bool';
93+
} else if ( isInteger( v ) ) {
94+
t = 'int';
95+
} else {
96+
throw new TypeError( 'invalid argument. First argument must be a valid index array.' );
97+
}
9498
} else {
95-
throw new TypeError( 'invalid argument. First argument must be a valid index array.' );
99+
t = 'int';
96100
}
97101
} else if ( dt === 'int32' ) {
98102
t = 'int';

0 commit comments

Comments
 (0)