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,11 +1,16 @@
"use strict";
exports.interval = interval;
var _index = require("./toDate.js");
import { normalizeDates } from "./_lib/normalizeDates.js";
/**
* The {@link interval} function options.
*/
/**
* The {@link interval} function result type. It resolves the proper data type.
* It uses the first argument date object type, starting from the start argument,
* then the end interval date. If a context function is passed, it uses the context
* function return type.
*/
/**
* @name interval
* @category Interval Helpers
@@ -14,7 +19,9 @@ var _index = require("./toDate.js");
* @description
* Creates a normalized interval object and validates its values. If the interval is invalid, an exception is thrown.
*
* @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 StartDate - Start date type.
* @typeParam EndDate - End date type.
* @typeParam Options - Options type.
*
* @param start - The start of the interval.
* @param end - The end of the interval.
@@ -26,11 +33,10 @@ var _index = require("./toDate.js");
*
* @returns The normalized and validated interval object.
*/
function interval(start, end, options) {
const _start = (0, _index.toDate)(start);
if (isNaN(+_start)) throw new TypeError("Start date is invalid");
export function interval(start, end, options) {
const [_start, _end] = normalizeDates(options?.in, start, end);
const _end = (0, _index.toDate)(end);
if (isNaN(+_start)) throw new TypeError("Start date is invalid");
if (isNaN(+_end)) throw new TypeError("End date is invalid");
if (options?.assertPositive && +_start > +_end)
@@ -38,3 +44,6 @@ function interval(start, end, options) {
return { start: _start, end: _end };
}
// Fallback for modularized imports:
export default interval;