1.0.1 • Published 3 years ago

@fkul/avg v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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 calculation
  • get - gets the calculated average of the previously added numbers
  • getCount - gets the count of added numbers
  • setMaxCount - 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
1.0.1

3 years ago

1.0.0

3 years ago