Skip to content

Commit db527e2

Browse files
committed
fix: 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: passed - 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 b92e4b8 commit db527e2

File tree

2 files changed

+8
-7
lines changed
  • lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-of

2 files changed

+8
-7
lines changed

lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-of/lib/main.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ function dlastIndexOf( arrays ) {
7070
searchElement = ndarraylike2scalar( arrays[ 1 ] );
7171
fromIndex = ndarraylike2scalar( arrays[ 2 ] );
7272

73-
if ( fromIndex < 0 ) {
74-
fromIndex += N;
75-
if ( fromIndex < 0 ) {
76-
fromIndex = 0;
73+
if (fromIndex < 0) {
74+
if (fromIndex >= -N) {
75+
fromIndex += N;
76+
} else {
77+
return -1;
7778
}
7879
} else if ( fromIndex >= N ) {
79-
return -1;
80+
fromIndex = N - 1;
8081
}
8182
N = fromIndex + 1;
8283
stride = getStride( x, 0 );

lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-of/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ tape( 'the function returns the last index of an element which equals a provided
137137
t.end();
138138
});
139139

140-
tape( 'the function returns `-1` if provided a starting search index which is greater than or equal to number of elements in the input ndarray', function test( t ) {
140+
tape( 'the function clamps the provided starting search index if it is greater than or equal to number of elements in the input ndarray', function test( t ) {
141141
var searchElement;
142142
var fromIndex;
143143
var actual;
@@ -152,7 +152,7 @@ tape( 'the function returns `-1` if provided a starting search index which is gr
152152
});
153153

154154
actual = dlastIndexOf( [ x, searchElement, fromIndex ] );
155-
t.strictEqual( actual, -1, 'returns expected value' );
155+
t.strictEqual( actual, 3, 'returns expected value' );
156156

157157
t.end();
158158
});

0 commit comments

Comments
 (0)