Skip to content

Commit dc6ae0c

Browse files
fix: fixing linting errors for the nanminmaxabs module
1 parent 8a7f5ad commit dc6ae0c

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

lib/node_modules/@stdlib/stats/incr/nanminmaxabs/benchmark/benchmark.js

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-
'use strict';
19+
"use strict";
2020

2121
// MODULES //
2222

@@ -69,4 +69,3 @@ bench(pkg + "::accumulator", function benchmark(b) {
6969
b.pass("benchmark finished");
7070
b.end();
7171
});
72-

lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/index.js

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

19-
'use strict';
19+
"use strict";
2020

2121
/**
2222
* Compute minimum and maximum absolute values incrementally, **ignoring NaN values**.
@@ -52,7 +52,7 @@
5252

5353
// MODULES //
5454

55-
var main = require( './main' );
55+
var main = require("./main.js");
5656

5757
// EXPORTS //
5858

lib/node_modules/@stdlib/stats/incr/nanminmaxabs/lib/main.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
// MODULES //
2222
var incrminmaxabs = require("@stdlib/stats/incr/minmaxabs");
2323
var isnan = require("@stdlib/math/base/assert/is-nan");
24+
var isArrayLike = require("@stdlib/assert/is-array-like");
2425

2526
/**
2627
* Returns an accumulator function which incrementally computes minimum and maximum absolute values, ignoring NaNs.
2728
*
29+
* @module @stdlib
2830
* @param {Collection} [out] - output array
2931
* @returns {Function} accumulator function
32+
* @throws {TypeError} if out is not an array-like object
3033
*
3134
* @example
3235
* var accumulator = incrnanminmaxabs();
@@ -47,19 +50,25 @@ var isnan = require("@stdlib/math/base/assert/is-nan");
4750
* // returns [ 2.0, 5.0 ]
4851
*/
4952
function incrnanminmaxabs(out) {
50-
if (arguments.length === 0) {
51-
out = [0.0, 0.0]; // Default output array
53+
// Throw error if out is provided but not array-like (e.g., undefined, null, false)
54+
if (arguments.length > 0 && !isArrayLike(out)) {
55+
throw new TypeError(
56+
"invalid argument. Output argument must be an array-like object."
57+
);
5258
}
53-
var accumulator = incrminmaxabs(out); // Use the original function
59+
// Use provided out if valid, otherwise default to empty array
60+
var accumulator = incrminmaxabs(out || []);
61+
var hasValues = false;
5462

5563
return function (x) {
5664
if (arguments.length === 0) {
57-
return accumulator(); // Return current min/max if no input
65+
return hasValues ? accumulator() : null;
5866
}
5967
if (isnan(x)) {
60-
return accumulator(); // Ignore NaN
68+
return hasValues ? accumulator() : null;
6169
}
62-
return accumulator(x); // Pass valid numbers
70+
hasValues = true;
71+
return accumulator(x);
6372
};
6473
}
6574

lib/node_modules/@stdlib/stats/incr/nanminmaxabs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"extrema",
6969
"incremental",
7070
"accumulator",
71-
"NaN",
72-
"ignore NaNs"
71+
"nan",
72+
"ignore-nans"
7373
]
7474
}

0 commit comments

Comments
 (0)