1.0.2 • Published 7 years ago
smry v1.0.2
smry
Computes a summary for number array
Install
npm i smryUsage
smry(array, options);array- array of numbers for computing statistic summary.options(optional) - object with following options:sorted- Boolean.truemeans that object preliminarily sorted. Otherwise it will be sorted insmry. Defaults tofalse.fractionDigits- number of digits to appear after the decimal point in every summary field. Defaults to 10.quantile- probability (number between 0 and 1) for computing quantile of array. Or array of probabilities.
Returns object with following fields:
min- minimum value of arraymax- maximum value of arraysum- sum of all array elementslen- size of arrayavg- average value of all array elementsquantile- object with specified quantiles of array (only ifquantileoption present).
Example
const smry = require('smry');
console.log(smry([4, 1, 3, 5, 2]));
/*
{ min: 1,
max: 5,
sum: 15,
len: 5,
avg: 3 }
*/License
MIT