Rocky_Mountain_Vending/.pnpm-store/v10/files/b6/cf77abba246d15b308722c692113ad30c5d2901ff031578f8d9c2aec8123e1d95d8e4c377e60ea6d8738acaf9ed43862bdf374599cd4925171d0f77d6796b3
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

83 lines
2.3 KiB
Text

import type { DateLib } from "../classes/DateLib.js";
import type {
DateAfter,
DateBefore,
DateInterval,
DateRange,
DayOfWeek
} from "../types/index.js";
/**
* 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
*/
export function isDateInterval(matcher: unknown): matcher is DateInterval {
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
*/
export function isDateRange(value: unknown): value is DateRange {
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
*/
export function isDateAfterType(value: unknown): value is DateAfter {
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
*/
export function isDateBeforeType(value: unknown): value is DateBefore {
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
*/
export function isDayOfWeekType(value: unknown): value is DayOfWeek {
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`.
*/
export function isDatesArray(
value: unknown,
dateLib: DateLib
): value is Date[] {
return Array.isArray(value) && value.every(dateLib.isDate);
}