@raindrops-on-roses/number-cumulative-average
v0.0.3
Published
Calculates the cumulative average of the provided values.
Readme
@raindrops-on-roses/number-cumulative-average
Calculates the cumulative average of the provided values.
cumulativeAverage utility from raindrops-on-roses.
Install
npm install @raindrops-on-roses/number-cumulative-averageUsage
import { cumulativeAverage } from "@raindrops-on-roses/number-cumulative-average";
cumulativeAverage({
values: [10, 20, 30, 40],
}); // [10, 15, 20, 25]
cumulativeAverage({
values: [10, null, 20, undefined, 30],
}); // [10, null, 15, undefined, 20]
cumulativeAverage({
values: [10, null, 20, undefined, 30],
config: {
keepInvalid: false,
},
}); // [10, 15, 20]Parameters
values- The numeric series to processconfig.keepInvalid- Keep invalid values in the outputconfig.convertInvalidToZero- Converts invalid values to 0 ifconfig.keepInvalidistrue
With the complete library
You can also install the complete library:
npm install raindrops-on-rosesand import the utility from the umbrella package:
import { cumulativeAverage } from "raindrops-on-roses";Lore
Every new experience changes ever so slightly the average that came before.
