registration

This commit is contained in:
User
2025-02-02 16:08:03 +03:00
parent 7f6495eb4d
commit 78afbaed71
6334 changed files with 196774 additions and 165754 deletions

View File

@@ -1,6 +1,9 @@
"use strict";
exports.min = min;
var _index = require("./toDate.js");
import { constructFrom } from "./constructFrom.js";
import { toDate } from "./toDate.js";
/**
* The {@link min} function options.
*/
/**
* @name min
@@ -11,6 +14,7 @@ var _index = require("./toDate.js");
* Returns the earliest of the given dates.
*
* @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 ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
*
* @param dates - The dates to compare
*
@@ -26,15 +30,21 @@ var _index = require("./toDate.js");
* ])
* //=> Wed Feb 11 1987 00:00:00
*/
function min(dates) {
export function min(dates, options) {
let result;
let context = options?.in;
dates.forEach((dirtyDate) => {
const date = (0, _index.toDate)(dirtyDate);
if (!result || result > date || isNaN(+date)) {
result = date;
}
dates.forEach((date) => {
// Use the first date object as the context function
if (!context && typeof date === "object")
context = constructFrom.bind(null, date);
const date_ = toDate(date, context);
if (!result || result > date_ || isNaN(+date_)) result = date_;
});
return result || new Date(NaN);
return constructFrom(context, result || NaN);
}
// Fallback for modularized imports:
export default min;