Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/itertools/builtins.ts>min

🦕 A TypeScript port of Python's itertools and more-itertools for Deno
Go to Latest
function min
import { min } from "https://deno.land/x/itertools@v1.1.1/builtins.ts";

Return the smallest item in an iterable. Only works for numbers, as ordering is pretty poorly defined on any other data type in JS. The optional keyFn argument specifies a one-argument ordering function like that used for sorted().

If the iterable is empty, undefined is returned.

If multiple items are minimal, the function returns either one of them, but which one is not defined.

Parameters

iterable: Iterable<T>
optional
keyFn: (v: T) => number = [UNSUPPORTED]