From: Chris Duncan Date: Mon, 16 Jun 2025 19:48:43 +0000 (-0700) Subject: Define type for result from stats function. X-Git-Tag: v5.0.0~11 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=4df2f00b110325a1cefad6b4a6785d9c1f997587;p=nano-pow.git Define type for result from stats function. --- 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)