function minWith
minWith<T>(array: Iterable<T>,comparator: (a: T,b: T) => number): T | undefinedReturns the first element having the smallest value according to the provided comparator or undefined if there are no elements
Examples
Example 1
Example 1
import { minWith } from "@std/collections/min_with"; import { assertEquals } from "@std/assert/assert_equals"; const people = ["Kim", "Anna", "John"]; const smallestName = minWith(people, (a, b) => a.length - b.length); assertEquals(smallestName, "Kim");
Type Parameters
TParameters
Return Type
T | undefined