MCPcopy
hub / github.com/date-fns/date-fns / clamp

Function clamp

pkgs/core/src/clamp/index.ts:65–86  ·  view source on GitHub ↗
(
  date: DateType,
  interval: IntervalType,
  options?: Options,
)

Source from the content-addressed store, hash-verified

63 * //=> Mon Mar 22 2021 00:00:00
64 */
65export 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}

Callers 1

test.tsFile · 0.90

Calls 3

normalizeDatesFunction · 0.90
minFunction · 0.90
maxFunction · 0.90

Tested by

no test coverage detected