( date: DateType, interval: IntervalType, options?: Options, )
| 63 | * //=> Mon Mar 22 2021 00:00:00 |
| 64 | */ |
| 65 | export function clamp< |
| 66 | DateType extends DateArg<Date>, |
| 67 | IntervalType extends Interval, |
| 68 | Options extends ClampOptions | undefined = undefined, |
| 69 | >( |
| 70 | date: DateType, |
| 71 | interval: IntervalType, |
| 72 | options?: Options, |
| 73 | ): ClampResult<DateType, IntervalType, Options> { |
| 74 | const [date_, start, end] = normalizeDates( |
| 75 | options?.in, |
| 76 | date, |
| 77 | interval.start, |
| 78 | interval.end, |
| 79 | ); |
| 80 | |
| 81 | return min([max([date_, start], options), end], options) as ClampResult< |
| 82 | DateType, |
| 83 | IntervalType, |
| 84 | Options |
| 85 | >; |
| 86 | } |
no test coverage detected