Skip to content

Commit 1df6eba

Browse files
committed
fix: update argument juggling
--- 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 15144b7 commit 1df6eba

File tree

1 file changed

+10
-7
lines changed
  • lib/node_modules/@stdlib/blas/ext/last-index-of/lib

1 file changed

+10
-7
lines changed

lib/node_modules/@stdlib/blas/ext/last-index-of/lib/assign.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,6 @@ function assign( x, searchElement, fromIndex, out ) {
114114
if ( !isndarrayLike( x ) ) {
115115
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
116116
}
117-
if ( nargs < 2 ) {
118-
throw new TypeError( format( 'invalid argument. Second argument must be either an ndarray or a scalar value. Value: `%s`.', searchElement ) );
119-
}
120-
if ( nargs < 3 ) {
121-
throw new TypeError( format( 'invalid argument. Third argument must be an ndarray. Value: `%s`.', fromIndex ) );
122-
}
123117
// Resolve input ndarray meta data:
124118
dt = getDType( x );
125119
ord = getOrder( x );
@@ -139,8 +133,11 @@ function assign( x, searchElement, fromIndex, out ) {
139133
hasOptions = false;
140134

141135
// Case: assign( x, search_element, out )
142-
if ( nargs === 3 ) {
136+
if ( nargs <= 3 ) {
143137
o = fromIndex;
138+
if ( !isndarrayLike( o ) ) {
139+
throw new TypeError( format( 'invalid argument. Third argument must be an ndarray. Value: `%s`.', o ) );
140+
}
144141
}
145142
// Case: assign( x, search_element, ???, ??? )
146143
else if ( nargs === 4 ) {
@@ -165,6 +162,9 @@ function assign( x, searchElement, fromIndex, out ) {
165162
// Case: assign( x, search_element, out, options )
166163
else {
167164
o = fromIndex;
165+
if ( !isndarrayLike( o ) ) {
166+
throw new TypeError( format( 'invalid argument. Third argument must be an ndarray. Value: `%s`.', o ) );
167+
}
168168
options = out;
169169
hasOptions = true;
170170
}
@@ -185,6 +185,9 @@ function assign( x, searchElement, fromIndex, out ) {
185185
throw new TypeError( format( 'invalid argument. Third argument must be either an ndarray or an integer. Value: `%s`.', fromIndex ) );
186186
}
187187
o = out;
188+
if ( !isndarrayLike( o ) ) {
189+
throw new TypeError( format( 'invalid argument. Fourth argument must be an ndarray. Value: `%s`.', o ) );
190+
}
188191
options = arguments[ 4 ];
189192
hasOptions = true;
190193
}

0 commit comments

Comments
 (0)