move getAverage to util

This commit is contained in:
Aakansha Doshi 2021-02-07 20:59:09 +05:30
parent 60d3bf1718
commit 85b8050cc5
2 changed files with 8 additions and 5 deletions

View file

@ -386,6 +386,11 @@ export const formatTime = (mseconds: number): string => {
? `${mseconds} ms`
: `${(mseconds / 1000).toFixed(1)} s`;
};
export const getAverage = (arr: Array<number>): number => {
return arr.reduce((sum, currentVal) => sum + currentVal) / arr.length;
};
// Adapted from https://github.com/Modernizr/Modernizr/blob/master/feature-detects/emoji.js
export const supportsEmoji = () => {
const canvas = document.createElement("canvas");