UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

9 lines (8 loc) 233 B
import { sum } from './sum'; export function average(values) { const length = values.length; if (length === 0) { throw new Error('Cannot calculate average of an empty array'); } return sum(values) / length; }