diff --git a/collections/max_by.ts b/collections/max_by.ts index 972f7a1d1b48..911118e372bc 100644 --- a/collections/max_by.ts +++ b/collections/max_by.ts @@ -23,27 +23,7 @@ */ export function maxBy( array: Iterable, - selector: (el: T) => number, -): T | undefined; -export function maxBy( - array: Iterable, - selector: (el: T) => string, -): T | undefined; -export function maxBy( - array: Iterable, - selector: (el: T) => bigint, -): T | undefined; -export function maxBy( - array: Iterable, - selector: (el: T) => Date, -): T | undefined; -export function maxBy( - array: Iterable, - selector: - | ((el: T) => number) - | ((el: T) => string) - | ((el: T) => bigint) - | ((el: T) => Date), + selector: (el: T) => number | string | bigint | Date, ): T | undefined { let max: T | undefined = undefined; let maxValue: ReturnType | undefined = undefined; diff --git a/collections/max_of.ts b/collections/max_of.ts index 6004d6403e2c..70ddab9c688f 100644 --- a/collections/max_of.ts +++ b/collections/max_of.ts @@ -22,17 +22,7 @@ * assertEquals(maxCount, 32); * ``` */ -export function maxOf( - array: Iterable, - selector: (el: T) => number, -): number | undefined; - -export function maxOf( - array: Iterable, - selector: (el: T) => bigint, -): bigint | undefined; - -export function maxOf number) | ((el: T) => bigint)>( +export function maxOf number | bigint>( array: Iterable, selector: S, ): ReturnType | undefined { diff --git a/collections/min_by.ts b/collections/min_by.ts index 3bc69e5fc599..4d44d6932f12 100644 --- a/collections/min_by.ts +++ b/collections/min_by.ts @@ -23,27 +23,7 @@ */ export function minBy( array: Iterable, - selector: (el: T) => number, -): T | undefined; -export function minBy( - array: Iterable, - selector: (el: T) => string, -): T | undefined; -export function minBy( - array: Iterable, - selector: (el: T) => bigint, -): T | undefined; -export function minBy( - array: Iterable, - selector: (el: T) => Date, -): T | undefined; -export function minBy( - array: Iterable, - selector: - | ((el: T) => number) - | ((el: T) => string) - | ((el: T) => bigint) - | ((el: T) => Date), + selector: (el: T) => number | string | bigint | Date, ): T | undefined { let min: T | undefined = undefined; let minValue: ReturnType | undefined = undefined; diff --git a/collections/min_of.ts b/collections/min_of.ts index 64ae52d10d05..dfde5e850c86 100644 --- a/collections/min_of.ts +++ b/collections/min_of.ts @@ -21,17 +21,7 @@ * assertEquals(minCount, 2); * ``` */ -export function minOf( - array: Iterable, - selector: (el: T) => number, -): number | undefined; - -export function minOf( - array: Iterable, - selector: (el: T) => bigint, -): bigint | undefined; - -export function minOf number) | ((el: T) => bigint)>( +export function minOf number | bigint>( array: Iterable, selector: S, ): ReturnType | undefined { diff --git a/collections/partition.ts b/collections/partition.ts index 2888d4f067a9..7745a150b18a 100644 --- a/collections/partition.ts +++ b/collections/partition.ts @@ -18,20 +18,12 @@ * assertEquals(odd, [5, 7, 9]); * ``` */ -export function partition( - array: Iterable, - predicate: (el: T) => el is U, -): [U[], Exclude[]]; export function partition( array: Iterable, predicate: (el: T) => boolean, -): [T[], T[]]; -export function partition( - array: Iterable, - predicate: (el: unknown) => boolean, -): [unknown[], unknown[]] { - const matches: Array = []; - const rest: Array = []; +): [T[], T[]] { + const matches = []; + const rest = []; for (const element of array) { if (predicate(element)) { diff --git a/collections/sort_by.ts b/collections/sort_by.ts index d38846da1d86..3cc682877f6b 100644 --- a/collections/sort_by.ts +++ b/collections/sort_by.ts @@ -43,31 +43,7 @@ export type SortByOptions = { */ export function sortBy( array: readonly T[], - selector: (el: T) => number, - options?: SortByOptions, -): T[]; -export function sortBy( - array: readonly T[], - selector: (el: T) => string, - options?: SortByOptions, -): T[]; -export function sortBy( - array: readonly T[], - selector: (el: T) => bigint, - options?: SortByOptions, -): T[]; -export function sortBy( - array: readonly T[], - selector: (el: T) => Date, - options?: SortByOptions, -): T[]; -export function sortBy( - array: readonly T[], - selector: - | ((el: T) => number) - | ((el: T) => string) - | ((el: T) => bigint) - | ((el: T) => Date), + selector: (el: T) => number | string | bigint | Date, options?: SortByOptions, ): T[] { const len = array.length; diff --git a/collections/zip.ts b/collections/zip.ts index d5ec404330c8..c396030909b4 100644 --- a/collections/zip.ts +++ b/collections/zip.ts @@ -1,6 +1,8 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. +import { minOf } from "./min_of.ts"; + /** * Builds N-tuples of elements from the given N arrays with matching indices, * stopping when the smallest array's end is reached. @@ -26,9 +28,6 @@ * ); * ``` */ - -import { minOf } from "./min_of.ts"; - export function zip( ...arrays: { [K in keyof T]: ReadonlyArray } ): T[] {