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