Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 15, 2024
1 parent 9aad113 commit aa0a057
Show file tree
Hide file tree
Showing 3 changed files with 1,250 additions and 9 deletions.
22 changes: 13 additions & 9 deletions index/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ function ArrayIndex( x ) {

// When provided a "generic" array or an array of an unknown data type, attempt to infer the type of index array...
if ( dt === 'generic' || dt === null ) {
get = resolveGetter( x );
v = get( x, 0 );

// Infer the "type" of index array from the first element...
if ( isBoolean( v ) ) {
t = 'bool';
} else if ( isInteger( v ) ) {
t = 'int';
if ( x.length > 0 ) {
get = resolveGetter( x );
v = get( x, 0 );

// Infer the "type" of index array from the first element...
if ( isBoolean( v ) ) {
t = 'bool';
} else if ( isInteger( v ) ) {
t = 'int';
} else {
throw new TypeError( 'invalid argument. First argument must be a valid index array.' );
}
} else {
throw new TypeError( 'invalid argument. First argument must be a valid index array.' );
t = 'int';
}
} else if ( dt === 'int32' ) {
t = 'int';
Expand Down
Loading

0 comments on commit aa0a057

Please sign in to comment.