calc-stats
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -52,3 +52,3 @@ const { getOrCreateIterator } = require("iter-fun"); | ||
index++; | ||
if (value !== noData && filter({ count, index, value }) === true) { | ||
if (typeof value === "number" && value !== noData && filter({ count, index, value }) === true) { | ||
process(value); | ||
@@ -58,7 +58,7 @@ } | ||
} else if (typeof noData === "number") { | ||
step = value => value !== noData && process(value); | ||
step = value => typeof value === "number" && value !== noData && process(value); | ||
} else if (typeof filter === "function") { | ||
step = value => { | ||
index++; | ||
if (filter({ count, index, value }) === true) { | ||
if (typeof value === "number" && filter({ count, index, value }) === true) { | ||
process(value); | ||
@@ -68,3 +68,3 @@ } | ||
} else { | ||
step = process; | ||
step = value => typeof value === "number" && process(value); | ||
} | ||
@@ -74,4 +74,3 @@ | ||
const results = {}; | ||
if (calcMedian) | ||
results.median = fasterMedian({ counts: histogram, total: count }); | ||
if (calcMedian) results.median = fasterMedian({ counts: histogram, total: count }); | ||
if (calcMin) results.min = min; | ||
@@ -99,4 +98,3 @@ if (calcMax) results.max = max; | ||
// compute mean value of all the most popular numbers | ||
if (calcMode) | ||
results.mode = modes.reduce((acc, n) => acc + n, 0) / modes.length; | ||
if (calcMode) results.mode = modes.reduce((acc, n) => acc + n, 0) / modes.length; | ||
} | ||
@@ -103,0 +101,0 @@ |
{ | ||
"name": "calc-stats", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Memory-Aware Statistical Calculations", | ||
@@ -10,3 +10,3 @@ "main": "calc-stats.js", | ||
"scripts": { | ||
"format": "npx prettier --arrow-parens=avoid --trailing-comma=none --write *.js", | ||
"format": "npx prettier --arrow-parens=avoid --print-width=120 --trailing-comma=none --write *.js", | ||
"test": "node test.js" | ||
@@ -13,0 +13,0 @@ }, |
14027
100