From 4df2f00b110325a1cefad6b4a6785d9c1f997587 Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 16 Jun 2025 12:48:43 -0700 Subject: [PATCH] Define type for result from stats function. --- src/utils/index.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index 26b66b6..38f3f86 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -9,8 +9,28 @@ export * from './queue' export const SEND = 0xfffffff800000000n export const RECEIVE: bigint = 0xfffffe0000000000n -export function stats (times: number[]) { - if (times == null || times.length === 0) return {} +type Averages = { + count: number, + total: number, + rate: number, + min: number, + max: number, + median: number, + arithmetic: number, + geometric: number, + harmonic: number, + truncatedCount: number, + truncatedTotal: number, + truncatedRate: number, + truncatedMin: number, + truncatedMax: number, + truncatedArithmetic: number, + truncatedGeometric: number, + truncatedHarmonic: number, +} + +export function stats (times: number[]): Averages | null { + if (times == null || times.length === 0) return null const count = times.length const truncatedStart = Math.floor(count * 0.1) -- 2.47.3