UNPKG

1.3 kBJavaScriptView Raw
1/**
2 * Returns true if `matcher` is of type {@link DateInterval}.
3 *
4 * @group Utilities
5 */
6export function isDateInterval(matcher) {
7 return Boolean(matcher &&
8 typeof matcher === "object" &&
9 "before" in matcher &&
10 "after" in matcher);
11}
12/**
13 * Returns true if `value` is a {@link DateRange} type.
14 *
15 * @group Utilities
16 */
17export function isDateRange(value) {
18 return Boolean(value && typeof value === "object" && "from" in value);
19}
20/**
21 * Returns true if `value` is of type {@link DateAfter}.
22 *
23 * @group Utilities
24 */
25export function isDateAfterType(value) {
26 return Boolean(value && typeof value === "object" && "after" in value);
27}
28/**
29 * Returns true if `value` is of type {@link DateBefore}.
30 *
31 * @group Utilities
32 */
33export function isDateBeforeType(value) {
34 return Boolean(value && typeof value === "object" && "before" in value);
35}
36/**
37 * Returns true if `value` is a {@link DayOfWeek} type.
38 *
39 * @group Utilities
40 */
41export function isDayOfWeekType(value) {
42 return Boolean(value && typeof value === "object" && "dayOfWeek" in value);
43}
44/** Returns true if `value` is an array of valid dates. */
45export function isDatesArray(value, dateLib) {
46 return Array.isArray(value) && value.every(dateLib.isDate);
47}
48//# sourceMappingURL=typeguards.js.map
\No newline at end of file