Function number

Keeps track of the total, min, max and avg in a stream of values. By default values are not stored.

Usage:

import { number } from 'https://unpkg.com/ixfx/dist/trackers.js';

const t = number();
t.seen(10);

t.avg / t.min/ t.max
t.initial; // initial value
t.size; // number of seen values
t.elapsed; // milliseconds since intialisation
t.last; // last value

To get { avg, min, max, total }

t.getMinMax()

Use t.reset() to clear everything.

Trackers can automatically reset after a given number of samples

// reset after 100 samples
const t = number({ resetAfterSamples: 100 });

To store values, use the storeIntermediate option:

const t = number({ storeIntermediate: true });

Difference between last value and initial value:

t.relativeDifference();

Get raw data (if it is being stored):

t.values; // array of numbers
t.timestampes; // array of millisecond times, indexes correspond to t.values