@@ -98,7 +98,7 @@ function find( x ) { // eslint-disable-line stdlib/no-redeclare
9898 throw new TypeError ( format ( 'invalid argument. First argument must be an ndarray-like object. Value: `%s`.' , x ) ) ;
9999 }
100100
101- if ( nargs == = 2 ) {
101+ if ( nargs < = 2 ) {
102102 // find( x, predicate )
103103 predicate = arguments [ 1 ] ;
104104 if ( ! isFunction ( predicate ) ) {
@@ -148,7 +148,7 @@ function find( x ) { // eslint-disable-line stdlib/no-redeclare
148148 throw new TypeError ( format ( 'invalid argument. Third argument must be a function. Value: `%s`.' , predicate ) ) ;
149149 }
150150 }
151- } else if ( nargs === 5 ) {
151+ } else { // nargs >= 5
152152 // find( x, sentinel, options, predicate, thisArg )
153153 sentinelValue = arguments [ 1 ] ;
154154 options = arguments [ 2 ] ;
@@ -157,8 +157,6 @@ function find( x ) { // eslint-disable-line stdlib/no-redeclare
157157 if ( ! isFunction ( predicate ) ) {
158158 throw new TypeError ( format ( 'invalid argument. Fourth argument must be a function. Value: `%s`.' , predicate ) ) ;
159159 }
160- } else {
161- throw new Error ( 'invalid number of arguments.' ) ;
162160 }
163161
164162 shx = getShape ( x ) ;
@@ -193,11 +191,7 @@ function find( x ) { // eslint-disable-line stdlib/no-redeclare
193191 }
194192
195193 if ( isndarrayLike ( sentinelValue ) ) {
196- try {
197- sv = maybeBroadcastArray ( sentinelValue , shy ) ;
198- } catch ( err ) { // eslint-disable-line no-unused-vars
199- throw new Error ( 'invalid argument. Sentinel value must be broadcast-compatible with the non-reduced dimensions of the input array.' ) ;
200- }
194+ sv = maybeBroadcastArray ( sentinelValue , shy ) ;
201195 } else {
202196 sv = broadcastScalar ( sentinelValue , getDtype ( x ) , shy , ord ) ;
203197 }
0 commit comments