Skip to content

Commit 8a8ffcd

Browse files
committed
fix linting error
1 parent 140bea7 commit 8a8ffcd

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

lib/node_modules/@stdlib/stats/base/nanmax-by/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ var v = nanmaxBy.ndarray( 3, x, 1, x.length-3, accessor );
160160
## Notes
161161

162162
- If `N <= 0`, both functions return `NaN`.
163-
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]).
164163
- A provided callback function should return a numeric value.
165164
- If a provided callback function returns `NaN`, the value is ignored.
166165
- If a provided callback function does not return any value (or equivalently, explicitly returns `undefined`), the value is ignored.
@@ -183,7 +182,7 @@ var bernoulli = require( '@stdlib/random/base/bernoulli' );
183182
var nanmaxBy = require( '@stdlib/stats/base/nanmax-by' );
184183

185184
function rand() {
186-
if ( bernoulli( 0.8 )< 0.2 ) {
185+
if ( bernoulli( 0.8 )< 0.2 ) {
187186
return NaN;
188187
}
189188
return uniform( -50, 50 );

lib/node_modules/@stdlib/stats/base/nanmax-by/lib/accessors.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,20 @@ var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' );
3838
* @returns {number} maximum value
3939
*
4040
* @example
41-
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
41+
* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
42+
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
43+
*
44+
* var x = toAccessorArray( [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ] );
4245
*
4346
* function accessor( v ) {
4447
* return v * 2.0;
4548
* }
4649
*
47-
* var v = nanmaxBy( x.length, x, 1, 0, accessor );
50+
* var v = nanmaxBy( x.length, arraylike2object( x ), 1, 0, accessor );
4851
* // returns 8.0
4952
*/
5053
function nanmaxBy( N, x, strideX, offsetX, clbk, thisArg ) {
51-
var xbuf;
54+
var xbuf;
5255
var get;
5356
var max;
5457
var ix;
@@ -61,38 +64,38 @@ function nanmaxBy( N, x, strideX, offsetX, clbk, thisArg ) {
6164
// Cache a reference to the element accessor:
6265
get = x.accessors[0];
6366
if ( N <= 0 ) {
64-
return NaN;
67+
return NaN;
6568
}
6669
if ( N === 1 || strideX === 0 ) {
67-
v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
68-
if ( v === void 0 || isnan( v ) ) {
69-
return NaN;
70-
}
71-
return v;
70+
v = clbk.call( thisArg, get( xbuf, 0 ), 0, 0, x );
71+
if ( v === void 0 || isnan( v ) ) {
72+
return NaN;
73+
}
74+
return v;
7275
}
7376
ix = offsetX;
7477
for ( i = 0; i < N; i++ ) {
7578
max = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
76-
if ( max === max && max !== void 0 ) {
77-
break;
78-
}
79-
ix += strideX;
79+
if ( max === max && max !== void 0 ) {
80+
break;
81+
}
82+
ix += strideX;
8083
}
8184
if ( i === N ) {
82-
return NaN;
85+
return NaN;
8386
}
8487
i += 1;
85-
for( i ; i < N ; i++ ) {
88+
for ( i; i < N; i++ ) {
8689
ix += strideX;
8790
v = clbk.call( thisArg, get( xbuf, ix ), i, ix, x );
88-
if ( v === void 0 || isnan( v ) ) {
89-
continue;
90-
}
91-
if( v > max || ( v === max && isPositiveZero( v ) ) ) {
91+
if ( v === void 0 || isnan( v ) ) {
92+
continue;
93+
}
94+
if ( v > max || ( v === max && isPositiveZero( v ) ) ) {
9295
max = v;
9396
}
9497
}
95-
return max;
98+
return max;
9699
}
97100

98101

0 commit comments

Comments
 (0)