1.0.1 • Published 4 years ago
@fkul/avg v1.0.1
Avg
Helps at calculating an average of numbers.
Getting started
yarn add @fkul/avgInterface
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() // 20Building
yarn buildTesting
yarn test