Skip to content

Commit 39ddc11

Browse files
committed
check
1 parent a612a0c commit 39ddc11

File tree

1 file changed

+7
-9
lines changed
  • lib/node_modules/@stdlib/stats/incr/nanprod/lib

1 file changed

+7
-9
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ var incrprod = require( '@stdlib/stats/incr/prod' );
5757
* // returns -10.0
5858
*/
5959
function incrnanprod() {
60-
var acc = incrprod();
60+
var prod = incrprod();
61+
return accumulator;
6162

6263
/**
6364
* If provided a value, the accumulator function returns an updated product. If not provided a value, the accumulator function returns the current product.
@@ -66,15 +67,12 @@ function incrnanprod() {
6667
* @param {number} [x] - new value
6768
* @returns {(number|null)} product or null
6869
*/
69-
return function accumulator( x ) {
70-
if ( arguments.length === 0 ) {
71-
return acc();
70+
function accumulator( x ) {
71+
if ( arguments.length === 0 || isnan( x ) ) {
72+
return prod();
7273
}
73-
if ( !isnan( x ) ) {
74-
return acc( x );
75-
}
76-
return acc();
77-
};
74+
return prod( x );
75+
}
7876
}
7977

8078

0 commit comments

Comments
 (0)