@fkul/avg
v1.0.1
Published
Helps at calculating an average of numbers
Downloads
5
Readme
Avg
Helps at calculating an average of numbers.
Getting started
yarn add @fkul/avg
Interface
type Avg = {
add(number: number): void
get(): number
getCount(): number
setMaxCount(count: number): void
reset(): void
}
add
- adds a number for calculationget
- gets the calculated average of the previously added numbersgetCount
- gets the count of added numberssetMaxCount
- limits the numbers count - adding new numbers will remove the oldest (default: 100)reset
- resets all values to their defaults
Example
import { useAvg } from '@fkul/avg';
const avg = useAvg();
avg.add(10);
avg.add(30);
const result = avg.get() // 20
Building
yarn build
Testing
yarn test