closestTo
import { closestTo } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030?
const dateToCompare = new Date(2015, 8, 6)
const result = closestTo(dateToCompare, [
new Date(2000, 0, 1),
new Date(2030, 0, 1)
])
//=> Tue Jan 01 2030 00:00:00
function closestTo<DateType extends Date>(dateToCompare: DateType | number | string, dates: Array<DateType | number | string>): DateType | undefined;