Skip to content

Commit 2488d6b

Browse files
committed
chore: clean-up
--- 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: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - 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: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed ---
1 parent c5f1102 commit 2488d6b

File tree

11 files changed

+197
-138
lines changed

11 files changed

+197
-138
lines changed

lib/node_modules/@stdlib/blas/ext/find-index/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# findIndex
2222

23-
> Return the first index of an element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function.
23+
> Return the index of the first element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function.
2424
2525
<section class="usage">
2626

@@ -32,7 +32,7 @@ var findIndex = require( '@stdlib/blas/ext/find-index' );
3232

3333
#### findIndex( x\[, options], clbk\[, thisArg] )
3434

35-
Returns the first index of an element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function.
35+
Returns the index of the first element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function.
3636

3737
```javascript
3838
var array = require( '@stdlib/ndarray/array' );
@@ -193,7 +193,7 @@ var dt = dtype( idx );
193193

194194
#### findIndex.assign( x, out\[, options], clbk\[, thisArg] )
195195

196-
Returns the first index of an element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
196+
Returns the index of the first element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].
197197

198198
```javascript
199199
var array = require( '@stdlib/ndarray/array' );

lib/node_modules/@stdlib/blas/ext/find-index/docs/repl.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
{{alias}}( x[, options], clbk[, thisArg] )
3-
Returns the first index of an element along an ndarray dimension which
3+
Returns the index of the first element along an ndarray dimension which
44
passes a test implemented by a predicate function.
55

66
The callback function is provided the following arguments:
@@ -57,7 +57,7 @@
5757

5858

5959
{{alias}}.assign( x, out[, options], clbk[, thisArg] )
60-
Returns the first index of an element along an ndarray dimension which
60+
Returns the index of the first element along an ndarray dimension which
6161
passes a test implemented by a predicate function and assigns results to a
6262
provided output ndarray.
6363

lib/node_modules/@stdlib/blas/ext/find-index/docs/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ interface Options extends BaseOptions {
106106
}
107107

108108
/**
109-
* Interface describing `findIndex`
109+
* Interface describing `findIndex`.
110110
*/
111111
interface FindIndex {
112112
/**
113-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.
113+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
114114
*
115115
* ## Notes
116116
*
@@ -139,7 +139,7 @@ interface FindIndex {
139139
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;
140140

141141
/**
142-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.
142+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
143143
*
144144
* ## Notes
145145
*
@@ -169,7 +169,7 @@ interface FindIndex {
169169
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;
170170

171171
/**
172-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
172+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
173173
*
174174
* ## Notes
175175
*
@@ -204,7 +204,7 @@ interface FindIndex {
204204
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends OutputArray = OutputArray, ThisArg = unknown>( x: U, out: V, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
205205

206206
/**
207-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
207+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
208208
*
209209
* ## Notes
210210
*
@@ -241,7 +241,7 @@ interface FindIndex {
241241
}
242242

243243
/**
244-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
244+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
245245
*
246246
* ## Notes
247247
*

lib/node_modules/@stdlib/blas/ext/find-index/docs/types/test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
/* eslint-disable @typescript-eslint/no-unused-expressions, space-in-parens */
19+
/* eslint-disable space-in-parens */
2020

2121
/// <reference types="@stdlib/types"/>
2222

@@ -192,7 +192,6 @@ function clbk( value: any ): boolean {
192192
findIndex( x, { 'dim': ( x: number ): number => x }, clbk ); // $ExpectError
193193

194194
findIndex( x, { 'dim': '5' }, clbk, {} ); // $ExpectError
195-
findIndex( x, { 'dim': 5 }, clbk, {} ); // $ExpectError
196195
findIndex( x, { 'dim': true }, clbk, {} ); // $ExpectError
197196
findIndex( x, { 'dim': false }, clbk, {} ); // $ExpectError
198197
findIndex( x, { 'dim': null }, clbk, {} ); // $ExpectError

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

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2424
var isFunction = require( '@stdlib/assert/is-function' );
2525
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2626
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
27-
var getShape = require( '@stdlib/ndarray/shape' );
27+
var ndims = require( '@stdlib/ndarray/ndims' );
2828
var format = require( '@stdlib/string/format' );
2929
var base = require( './base.js' ).assign;
3030

3131

3232
// MAIN //
3333

3434
/**
35-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function and assigns the results to a provided output ndarray.
35+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function and assigns the results to a provided output ndarray.
3636
*
3737
* @param {ndarrayLike} x - input ndarray
3838
* @param {ndarrayLike} out - output ndarray
@@ -43,7 +43,7 @@ var base = require( './base.js' ).assign;
4343
* @throws {TypeError} function must be provided at least three arguments
4444
* @throws {TypeError} first argument must be an ndarray-like object
4545
* @throws {TypeError} second argument must be an ndarray-like object
46-
* @throws {TypeError} third argument must be a function
46+
* @throws {TypeError} callback argument must be a function
4747
* @throws {TypeError} options argument must be an object
4848
* @throws {RangeError} dimension index must not exceed input ndarray bounds
4949
* @throws {RangeError} first argument must have at least one dimension
@@ -96,7 +96,6 @@ function assign( x, out ) {
9696
var opts;
9797
var ctx;
9898
var cb;
99-
var sh;
10099

101100
nargs = arguments.length;
102101
if ( !isndarrayLike( x ) ) {
@@ -105,10 +104,6 @@ function assign( x, out ) {
105104
if ( !isndarrayLike( out ) ) {
106105
throw new TypeError( format( 'invalid argument. The second argument must be an ndarray. Value: `%s`.', out ) );
107106
}
108-
if ( nargs < 3 ) {
109-
throw new TypeError( format( 'invalid argument. Function must be provided a callback function. Value: `%s`.', arguments[ 2 ] ) );
110-
}
111-
112107
// Initialize an options object:
113108
opts = {
114109
'dims': [ -1 ] // default behavior is to perform a reduction over the last dimension
@@ -118,35 +113,38 @@ function assign( x, out ) {
118113
hasOptions = false;
119114

120115
// Case: assign( x, out, clbk )
121-
if ( nargs === 3 ) {
116+
if ( nargs <= 3 ) {
122117
cb = arguments[ 2 ];
123118
if ( !isFunction( cb ) ) {
124-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
119+
throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', cb ) );
125120
}
126121
}
127-
// Case: assign( x, out, options, clbk ) or Case: assign( x, out, clbk, thisArg )
128-
else if ( nargs < 5 ) {
129-
options = arguments[ 2 ];
130-
cb = arguments[ 3 ];
131-
if ( isFunction( options ) ) {
132-
ctx = cb;
133-
cb = options;
134-
} else {
122+
// Case: assign( x, out, ???, ??? )
123+
else if ( nargs === 4 ) {
124+
// Case: assign( x, out, clbk, thisArg )
125+
if ( isFunction( arguments[ 2 ] ) ) {
126+
cb = arguments[ 2 ];
127+
ctx = arguments[ 3 ];
128+
}
129+
// Case: assign( x, out, options, clbk )
130+
else {
131+
options = arguments[ 2 ];
132+
cb = arguments[ 3 ];
135133
if ( !isFunction( cb ) ) {
136-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
134+
throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', cb ) );
137135
}
138136
hasOptions = true;
139137
}
140138
}
141139
// Case: assign( x, out, options, clbk, thisArg )
142140
else {
143141
options = arguments[ 2 ];
144-
hasOptions = true;
145142
cb = arguments[ 3 ];
143+
ctx = arguments[ 4 ];
146144
if ( !isFunction( cb ) ) {
147-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
145+
throw new TypeError( format( 'invalid argument. Fourth argument must be a function. Value: `%s`.', cb ) );
148146
}
149-
ctx = arguments[ 4 ];
147+
hasOptions = true;
150148
}
151149
if ( hasOptions ) {
152150
if ( !isPlainObject( options ) ) {
@@ -157,9 +155,7 @@ function assign( x, out ) {
157155
opts.dims[ 0 ] = options.dim;
158156
}
159157
}
160-
// Resolve the list of non-reduced dimensions:
161-
sh = getShape( x );
162-
if ( sh.length < 1 ) {
158+
if ( ndims( x ) < 1 ) {
163159
throw new RangeError( 'invalid argument. First argument must have at least one dimension.' );
164160
}
165161
return base( x, out, opts, cb, ctx );

lib/node_modules/@stdlib/blas/ext/find-index/lib/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var table = {
4141
// MAIN //
4242

4343
/**
44-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.
44+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
4545
*
4646
* @private
4747
* @name findIndex

lib/node_modules/@stdlib/blas/ext/find-index/lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
'use strict';
2020

2121
/**
22-
* Return the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.
22+
* Return the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
2323
*
2424
* @module @stdlib/blas/ext/find-index
2525
*

lib/node_modules/@stdlib/blas/ext/find-index/lib/main.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ var hasOwnProp = require( '@stdlib/assert/has-own-property' );
2424
var isFunction = require( '@stdlib/assert/is-function' );
2525
var isPlainObject = require( '@stdlib/assert/is-plain-object' );
2626
var isndarrayLike = require( '@stdlib/assert/is-ndarray-like' );
27-
var getShape = require( '@stdlib/ndarray/shape' );
27+
var ndims = require( '@stdlib/ndarray/ndims' );
2828
var format = require( '@stdlib/string/format' );
2929
var base = require( './base.js' );
3030

3131

3232
// MAIN //
3333

3434
/**
35-
* Returns the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.
35+
* Returns the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.
3636
*
3737
* @param {ndarrayLike} x - input ndarray
3838
* @param {Options} [options] - function options
@@ -42,6 +42,7 @@ var base = require( './base.js' );
4242
* @param {Function} clbk - callback function
4343
* @param {*} [thisArg] - callback execution context
4444
* @throws {TypeError} first argument must be an ndarray-like object
45+
* @throws {TypeError} second argument must be a function
4546
* @throws {TypeError} options argument must be an object
4647
* @throws {RangeError} dimension index must not exceed input ndarray bounds
4748
* @throws {RangeError} first argument must have at least one dimension
@@ -85,16 +86,11 @@ function findIndex( x ) {
8586
var opts;
8687
var ctx;
8788
var cb;
88-
var sh;
8989

9090
nargs = arguments.length;
9191
if ( !isndarrayLike( x ) ) {
9292
throw new TypeError( format( 'invalid argument. First argument must be an ndarray. Value: `%s`.', x ) );
9393
}
94-
if ( nargs < 2 ) {
95-
throw new TypeError( format( 'invalid argument. Function must be provided a callback function. Value: `%s`.', arguments[ 1 ] ) );
96-
}
97-
9894
// Initialize an options object:
9995
opts = {
10096
'dims': [ -1 ], // default behavior is to perform a reduction over the last dimension
@@ -105,35 +101,38 @@ function findIndex( x ) {
105101
hasOptions = false;
106102

107103
// Case: findIndex( x, clbk )
108-
if ( nargs === 2 ) {
104+
if ( nargs <= 2 ) {
109105
cb = arguments[ 1 ];
110106
if ( !isFunction( cb ) ) {
111107
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
112108
}
113109
}
114-
// Case: findIndex( x, options, clbk ) or Case: findIndex( x, clbk, thisArg )
115-
else if ( nargs < 4 ) {
116-
options = arguments[ 1 ];
117-
cb = arguments[ 2 ];
118-
if ( isFunction( options ) ) {
119-
ctx = cb;
120-
cb = options;
121-
} else {
110+
// Case: findIndex( x, ???, ??? )
111+
else if ( nargs === 3 ) {
112+
// Case: findIndex( x, clbk, thisArg )
113+
if ( isFunction( arguments[ 1 ] ) ) {
114+
cb = arguments[ 1 ];
115+
ctx = arguments[ 2 ];
116+
}
117+
// Case: findIndex( x, options, clbk )
118+
else {
119+
options = arguments[ 1 ];
120+
cb = arguments[ 2 ];
122121
if ( !isFunction( cb ) ) {
123-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
122+
throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', cb ) );
124123
}
125124
hasOptions = true;
126125
}
127126
}
128127
// Case: findIndex( x, options, clbk, thisArg )
129128
else {
130129
options = arguments[ 1 ];
131-
hasOptions = true;
132130
cb = arguments[ 2 ];
131+
ctx = arguments[ 3 ];
133132
if ( !isFunction( cb ) ) {
134-
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', cb ) );
133+
throw new TypeError( format( 'invalid argument. Third argument must be a function. Value: `%s`.', cb ) );
135134
}
136-
ctx = arguments[ 3 ];
135+
hasOptions = true;
137136
}
138137
if ( hasOptions ) {
139138
if ( !isPlainObject( options ) ) {
@@ -151,8 +150,7 @@ function findIndex( x ) {
151150
}
152151
}
153152
// Resolve the list of non-reduced dimensions:
154-
sh = getShape( x );
155-
if ( sh.length < 1 ) {
153+
if ( ndims( x ) < 1 ) {
156154
throw new RangeError( 'invalid argument. First argument must have at least one dimension.' );
157155
}
158156
return base( x, opts, cb, ctx );

lib/node_modules/@stdlib/blas/ext/find-index/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/blas/ext/find-index",
33
"version": "0.0.0",
4-
"description": "Return the first index of an element along an ndarray dimension which passes a test implemented by a predicate function.",
4+
"description": "Return the index of the first element along an ndarray dimension which passes a test implemented by a predicate function.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",
@@ -53,7 +53,6 @@
5353
"blas",
5454
"find",
5555
"index",
56-
"callback",
5756
"search",
5857
"array",
5958
"ndarray"

0 commit comments

Comments
 (0)