From bff996066d54a6e3114014db4f3d244a794db9b4 Mon Sep 17 00:00:00 2001 From: Seve Badajoz Date: Mon, 9 Aug 2021 12:14:14 -0700 Subject: [PATCH] type quantile --- client/src/util/quantile.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/client/src/util/quantile.ts b/client/src/util/quantile.ts index 53a0fbf0..60a6a9b1 100644 --- a/client/src/util/quantile.ts +++ b/client/src/util/quantile.ts @@ -14,15 +14,25 @@ Arguments: import { sortArray } from "./typedCrossfilter/sort"; -// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'quantArr' implicitly has an 'any' type. -// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS. -export default function quantile(quantArr, tarr, sorted = false) { +export default function quantile( + quantArr: Array, + tarr: + | Int8Array + | Uint8Array + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Uint8ClampedArray + | Float32Array + | Float64Array, + sorted = false +): Array { /* start with the naive (sort) implementation. Later, use a faster partition */ - const arr = sorted ? tarr : sortArray(new tarr.constructor(tarr)); // copy + const arr = sorted ? tarr : sortArray(tarr.constructor(tarr)); // copy const len = arr.length; - // @ts-expect-error ts-migrate(7006) FIXME: Parameter 'q' implicitly has an 'any' type. return quantArr.map((q) => { if (q === 1) { return arr[len - 1];