Skip to content

Commit cdd8e99

Browse files
committed
refactor: miscellaneous
--- 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: passed - task: lint_javascript_src status: na - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent 0cb0647 commit cdd8e99

File tree

3 files changed

+22
-28
lines changed

3 files changed

+22
-28
lines changed

lib/node_modules/@stdlib/blas/ext/base/ndarray/gfind-last-index/docs/repl.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
Returns the index of the last element in a one-dimensional ndarray which
44
passes a test implemented by a predicate function.
55

6-
If provided an empty ndarray, the function returns `-1`.
6+
If provided an empty ndarray or no element passes a test implemented by a
7+
predicate function, the function returns `-1`.
78

89
The callback function is provided three arguments:
910

1011
- value: current array element.
1112
- index: current array index.
1213
- array: the input ndarray.
1314

14-
The callback function should return a boolean value.
15-
1615
Parameters
1716
----------
1817
arrays: ArrayLikeObject<ndarray>

lib/node_modules/@stdlib/blas/ext/base/ndarray/gfind-last-index/docs/types/index.d.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,55 +23,59 @@
2323
import { typedndarray } from '@stdlib/types/ndarray';
2424

2525
/**
26-
* Returns the result of callback function.
26+
* Returns a boolean indicating whether an element passes a test.
2727
*
28-
* @returns result
28+
* @returns boolean indicating whether an element passes a test
2929
*/
3030
type Nullary<ThisArg> = ( this: ThisArg ) => boolean;
3131

3232
/**
33-
* Returns the result of callback function.
33+
* Returns a boolean indicating whether an element passes a test.
3434
*
3535
* @param value - current array element
36-
* @returns result
36+
* @returns boolean indicating whether an element passes a test
3737
*/
3838
type Unary<T, ThisArg> = ( this: ThisArg, value: T ) => boolean;
3939

4040
/**
41-
* Returns the result of callback function.
41+
* Returns a boolean indicating whether an element passes a test.
4242
*
4343
* @param value - current array element
4444
* @param index - current array element index
45-
* @returns result
45+
* @returns boolean indicating whether an element passes a test
4646
*/
4747
type Binary<T, ThisArg> = ( this: ThisArg, value: T, index: number ) => boolean;
4848

4949
/**
50-
* Returns the result of callback function.
50+
* Returns a boolean indicating whether an element passes a test.
5151
*
5252
* @param value - current array element
5353
* @param index - current array element index
5454
* @param array - input ndarray
55-
* @returns result
55+
* @returns boolean indicating whether an element passes a test
5656
*/
5757
type Ternary<T, U, ThisArg> = ( this: ThisArg, value: T, index: number, array: U ) => boolean;
5858

5959
/**
60-
* Returns the result of callback function.
60+
* Returns a boolean indicating whether an element passes a test.
6161
*
6262
* @param value - current array element
6363
* @param index - current array element index
6464
* @param array - input ndarray
65-
* @returns result
65+
* @returns boolean indicating whether an element passes a test
6666
*/
67-
type Callback<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, U, ThisArg>;
67+
type Predicate<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T, ThisArg> | Ternary<T, U, ThisArg>;
6868

6969
/**
7070
* Returns the index of the last element in a one-dimensional ndarray which passes a test implemented by a predicate function.
7171
*
72+
* ## Notes
73+
*
74+
* - If no element passes a test implemented by a predicate function, the function returns `-1`.
75+
*
7276
* @param arrays - array-like object containing an input ndarray
73-
* @param clbk - callback function
74-
* @param thisArg - callback execution context
77+
* @param clbk - predicate function
78+
* @param thisArg - predicate execution context
7579
* @returns index
7680
*
7781
* @example
@@ -87,7 +91,7 @@ type Callback<T, U, ThisArg> = Nullary<ThisArg> | Unary<T, ThisArg> | Binary<T,
8791
* var v = gfindLastIndex( [ x ], clbk );
8892
* // returns 3
8993
*/
90-
declare function gfindLastIndex<T = unknown, U extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( arrays: [ U ], clbk: Callback<T, U, ThisArg>, thisArg?: ThisParameterType<Callback<T, U, ThisArg>> ): number;
94+
declare function gfindLastIndex<T = unknown, U extends typedndarray<T> = typedndarray<T>, ThisArg = unknown>( arrays: [ U ], clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): number;
9195

9296

9397
// EXPORTS //

lib/node_modules/@stdlib/blas/ext/base/ndarray/gfind-last-index/test/test.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,28 +196,19 @@ tape( 'the function supports providing an execution context', function test( t )
196196
actual = gfindLastIndex( [ arr ], isEven, ctx );
197197

198198
t.strictEqual( actual, 3, 'returns expected value' );
199-
t.strictEqual( ctx.count, 4, 'returns expected value' );
199+
t.strictEqual( ctx.count, 1, 'returns expected value' );
200200

201201
expected = [
202-
1.0,
203-
3.0,
204-
-7.0,
205202
4.0
206203
];
207204
t.deepEqual( values, expected, 'returns expected value' );
208205

209206
expected = [
210-
0,
211-
1,
212-
2,
213-
3
207+
0
214208
];
215209
t.deepEqual( indices, expected, 'returns expected value' );
216210

217211
expected = [
218-
arr,
219-
arr,
220-
arr,
221212
arr
222213
];
223214
t.deepEqual( arrays, expected, 'returns expected value' );

0 commit comments

Comments
 (0)