json-processing
Version:
JSON Processing Tool
24 lines (23 loc) • 875 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const fast_stats_1 = require("fast-stats");
const operators_1 = require("rxjs/operators");
function stats(elementSelector = (e) => e) {
return rxjs_1.pipe(operators_1.map(elementSelector), operators_1.reduce((accumulator, current) => accumulator.push(+current), new fast_stats_1.Stats()), operators_1.map((stats) => ({
min: stats.min,
max: stats.max,
sum: stats.sum,
zeroes: stats.zeroes,
mean: stats.amean(),
stddev: stats.stddev(),
p01: stats.percentile(1),
p10: stats.percentile(10),
p25: stats.percentile(25),
p50: stats.percentile(50),
p75: stats.percentile(75),
p90: stats.percentile(90),
p99: stats.percentile(99)
})));
}
exports.default = stats;