Skip to content

Commit a612a0c

Browse files
committed
check
1 parent f076764 commit a612a0c

File tree

1 file changed

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

1 file changed

+9
-7
lines changed

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

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

6362
/**
6463
* If provided a value, the accumulator function returns an updated product. If not provided a value, the accumulator function returns the current product.
@@ -67,12 +66,15 @@ function incrnanprod() {
6766
* @param {number} [x] - new value
6867
* @returns {(number|null)} product or null
6968
*/
70-
function accumulator( x ) {
71-
if ( arguments.length === 0 || isnan( x ) ) {
72-
return prod();
69+
return function accumulator( x ) {
70+
if ( arguments.length === 0 ) {
71+
return acc();
7372
}
74-
return prod( x );
75-
}
73+
if ( !isnan( x ) ) {
74+
return acc( x );
75+
}
76+
return acc();
77+
};
7678
}
7779

7880

0 commit comments

Comments
 (0)