Casting summary values back to integers after toFixed. Fixes #1672
This commit is contained in:
parent
ed697bd234
commit
5bcec839f4
|
|
@ -49,20 +49,20 @@ module.exports = {
|
|||
let percentiles = options.percentiles || [0, 90, 100];
|
||||
let decimals = options.decimals || 0;
|
||||
let data = {
|
||||
median: stats.median().toFixed(decimals),
|
||||
mean: stats.amean().toFixed(decimals)
|
||||
median: parseInt(stats.median().toFixed(decimals)),
|
||||
mean: parseInt(stats.amean().toFixed(decimals))
|
||||
};
|
||||
percentiles.forEach((p) => {
|
||||
let name = percentileName(p);
|
||||
const percentile = stats.percentile(p);
|
||||
if (Number.isFinite(percentile)) {
|
||||
data[name] = percentile.toFixed(decimals);
|
||||
data[name] = parseInt(percentile.toFixed(decimals));
|
||||
} else {
|
||||
throw new Error('Failed to calculate ' + name + ' for stats: ' + JSON.stringify(stats, null, 2));
|
||||
}
|
||||
});
|
||||
if (options.includeSum) {
|
||||
data.sum = stats.Σ().toFixed(decimals);
|
||||
data.sum = parseInt(stats.Σ().toFixed(decimals));
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
|
|||
Loading…
Reference in New Issue