From 2b84eb5c27baaeb428a6e146b73a93d84f5f2a1c Mon Sep 17 00:00:00 2001 From: William Candillon Date: Thu, 22 Oct 2020 18:17:01 +0200 Subject: [PATCH] =?UTF-8?q?=20feat(=F0=9F=A7=AE):=20avg()=20(#386)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Math.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Math.ts b/src/Math.ts index 65d061df..71b9a6cc 100644 --- a/src/Math.ts +++ b/src/Math.ts @@ -30,6 +30,15 @@ export const toRad = (deg: number) => { return (deg * Math.PI) / 180; }; +/** + * + * @summary Returns the average value + */ +export const avg = (values: number[]) => { + "worklet"; + return values.reduce((a, v) => a + v, 0) / values.length; +}; + /** * @summary Returns true if node is within lowerBound and upperBound. */