Skip to content

Commit ec79858

Browse files
committed
refactor: apply suggestions from code review
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent bac6b34 commit ec79858

File tree

1 file changed

+3
-9
lines changed
  • lib/node_modules/@stdlib/ndarray/find/lib

1 file changed

+3
-9
lines changed

lib/node_modules/@stdlib/ndarray/find/lib/main.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)