UNPKG

react-day-picker

Version:

Customizable Date Picker for React

73 lines 2.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isDateInterval = isDateInterval; exports.isDateRange = isDateRange; exports.isDateAfterType = isDateAfterType; exports.isDateBeforeType = isDateBeforeType; exports.isDayOfWeekType = isDayOfWeekType; exports.isDatesArray = isDatesArray; /** * Checks if the given value is of type {@link DateInterval}. * * @param matcher - The value to check. * @returns `true` if the value is a {@link DateInterval}, otherwise `false`. * @group Utilities */ function isDateInterval(matcher) { return Boolean(matcher && typeof matcher === "object" && "before" in matcher && "after" in matcher); } /** * Checks if the given value is of type {@link DateRange}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateRange}, otherwise `false`. * @group Utilities */ function isDateRange(value) { return Boolean(value && typeof value === "object" && "from" in value); } /** * Checks if the given value is of type {@link DateAfter}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateAfter}, otherwise `false`. * @group Utilities */ function isDateAfterType(value) { return Boolean(value && typeof value === "object" && "after" in value); } /** * Checks if the given value is of type {@link DateBefore}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateBefore}, otherwise `false`. * @group Utilities */ function isDateBeforeType(value) { return Boolean(value && typeof value === "object" && "before" in value); } /** * Checks if the given value is of type {@link DayOfWeek}. * * @param value - The value to check. * @returns `true` if the value is a {@link DayOfWeek}, otherwise `false`. * @group Utilities */ function isDayOfWeekType(value) { return Boolean(value && typeof value === "object" && "dayOfWeek" in value); } /** * Checks if the given value is an array of valid dates. * * @private * @param value - The value to check. * @param dateLib - The date utility library instance. * @returns `true` if the value is an array of valid dates, otherwise `false`. */ function isDatesArray(value, dateLib) { return Array.isArray(value) && value.every(dateLib.isDate); } //# sourceMappingURL=typeguards.js.map