* @summary Return a date from the array closest to the given date.
5
*
6
* @description
7
* Return a date from the array closest to the given date.
8
*
9
* @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
10
*
11
* @param dateToCompare - The date to compare with
12
* @param dates - The array to search
13
*
14
* @returns The date from the array closest to the given date or undefined if no valid value is given
15
*
16
* @example
17
* // Which date is closer to 6 September 2015: 1 January 2000 or 1 January 2030?