From 23a4f7138e5b117d83812be759ca0b13e377b68d Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Mon, 29 Mar 2021 21:46:29 +0200 Subject: [PATCH] Remove unused utils --- src/module/common/utils.ts | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 src/module/common/utils.ts diff --git a/src/module/common/utils.ts b/src/module/common/utils.ts deleted file mode 100644 index df5fe8f3..00000000 --- a/src/module/common/utils.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Partition an array into two, following a predicate. - * @param input - The Array to split. - * @param predicate - The predicate by which to split. - * @returns A tuple of two arrays, the first one containing all elements from `input` that match the predicate, the second one containing those that do not. - */ -export function partition(input: Array, predicate: (v: T) => boolean): [T[], T[]] { - return input.reduce( - (p: [Array, Array], cur: T) => { - if (predicate(cur)) { - p[0].push(cur); - } else { - p[1].push(cur); - } - return p; - }, - [[], []], - ); -} - -/** - * Zips two Arrays to an array of pairs of elements with corresponding indices. Excessive elements are dropped. - * @param a1 - First array to zip. - * @param a2 - Second array to zip. - * - * @typeParam T - Type of elements contained in `a1`. - * @typeParam U - Type of elements contained in `a2`. - * - * @returns The array of pairs that had the same index in their source array. - */ -export function zip(a1: Array, a2: Array): Array<[T, U]> { - if (a1.length <= a2.length) { - return a1.map((e1, i) => [e1, a2[i]]); - } else { - return a2.map((e2, i) => [a1[i], e2]); - } -}