registration
This commit is contained in:
42
frontend/style/node_modules/date-fns/clamp.js
generated
vendored
42
frontend/style/node_modules/date-fns/clamp.js
generated
vendored
@@ -1,12 +1,22 @@
|
||||
"use strict";
|
||||
exports.clamp = clamp;
|
||||
var _index = require("./max.js");
|
||||
var _index2 = require("./min.js");
|
||||
import { normalizeDates } from "./_lib/normalizeDates.js";
|
||||
import { max } from "./max.js";
|
||||
import { min } from "./min.js";
|
||||
|
||||
/**
|
||||
* The {@link clamp} function options.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The {@link clamp} function result type. It resolves the proper data type.
|
||||
* It uses the first argument date object type, starting from the date argument,
|
||||
* then the start interval date, and finally the end interval date. If
|
||||
* a context function is passed, it uses the context function return type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @name clamp
|
||||
* @category Interval Helpers
|
||||
* @summary Return a date bounded by the start and the end of the given interval
|
||||
* @summary Return a date bounded by the start and the end of the given interval.
|
||||
*
|
||||
* @description
|
||||
* Clamps a date to the lower bound with the start of the interval and the upper
|
||||
@@ -16,24 +26,34 @@ var _index2 = require("./min.js");
|
||||
* - When the date is greater than the end of the interval, the end is returned.
|
||||
* - Otherwise the date is returned.
|
||||
*
|
||||
* @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).
|
||||
* @typeParam DateType - Date argument type.
|
||||
* @typeParam IntervalType - Interval argument type.
|
||||
* @typeParam Options - Options type.
|
||||
*
|
||||
* @param date - The date to be bounded
|
||||
* @param interval - The interval to bound to
|
||||
* @param options - An object with options
|
||||
*
|
||||
* @returns The date bounded by the start and the end of the interval
|
||||
*
|
||||
* @example
|
||||
* // What is Mar, 21, 2021 bounded to an interval starting at Mar, 22, 2021 and ending at Apr, 01, 2021
|
||||
* // What is Mar 21, 2021 bounded to an interval starting at Mar 22, 2021 and ending at Apr 01, 2021
|
||||
* const result = clamp(new Date(2021, 2, 21), {
|
||||
* start: new Date(2021, 2, 22),
|
||||
* end: new Date(2021, 3, 1),
|
||||
* })
|
||||
* //=> Mon Mar 22 2021 00:00:00
|
||||
*/
|
||||
function clamp(date, interval) {
|
||||
return (0, _index2.min)([
|
||||
(0, _index.max)([date, interval.start]),
|
||||
export function clamp(date, interval, options) {
|
||||
const [date_, start, end] = normalizeDates(
|
||||
options?.in,
|
||||
date,
|
||||
interval.start,
|
||||
interval.end,
|
||||
]);
|
||||
);
|
||||
|
||||
return min([max([date_, start], options), end], options);
|
||||
}
|
||||
|
||||
// Fallback for modularized imports:
|
||||
export default clamp;
|
||||
|
||||
Reference in New Issue
Block a user