UNPKG

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