@vope/utils 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cron.d.ts ADDED
@@ -0,0 +1,177 @@
1
+ interface Item {
2
+ key: string;
3
+ value: number;
4
+ }
5
+ declare class Dic {
6
+ private dics;
7
+ private keys;
8
+ private values;
9
+ constructor(dics: Item[]);
10
+ item(key: string): number;
11
+ at(value: number): string;
12
+ reduce<U>(callbackfn: (previousValue: U, currentValue: Item, currentIndex: number) => U, initialValue: U): U;
13
+ }
14
+ export declare const weekDic: Dic;
15
+ interface Options {
16
+ /**
17
+ * 是否支持具名匹配
18
+ * @default true
19
+ */
20
+ enableSlot?: boolean;
21
+ /**
22
+ * 是否支持秒
23
+ * @default true
24
+ */
25
+ enableSecond?: boolean;
26
+ /**
27
+ * 是否支持年
28
+ * @default true
29
+ */
30
+ enableYear?: boolean;
31
+ /**
32
+ * 值是否匹配最大值
33
+ * @default true
34
+ */
35
+ enableMax?: boolean;
36
+ /**
37
+ * 增幅是否匹配最大值(如果enableMax等于false则该值也始终为false)
38
+ * @default true
39
+ */
40
+ enableIncrementMax?: boolean;
41
+ /**
42
+ * 日/周是否支持无效设置
43
+ * @default true
44
+ */
45
+ enableInvalid?: boolean;
46
+ /**
47
+ * 日期是否支持倒数值
48
+ * @default true
49
+ */
50
+ enableDayLast?: boolean;
51
+ /**
52
+ * 周是否支持倒数值
53
+ * @default true
54
+ */
55
+ enableWeekLast?: boolean;
56
+ /**
57
+ * 周是否支持7
58
+ * @default true
59
+ */
60
+ enableWeekSupport7?: boolean;
61
+ /**
62
+ * 周是否支持字典
63
+ * @default true
64
+ */
65
+ enableWeekSupportDic?: boolean;
66
+ /**
67
+ * 周字典是否支持大小写混写
68
+ * @default true
69
+ */
70
+ enableDicEnumSupportMixin?: boolean;
71
+ /**
72
+ * 数值是否支持前缀0
73
+ */
74
+ enablePrefixZero?: boolean;
75
+ }
76
+ export declare const default_max_second = 59;
77
+ export declare const default_min_second = 0;
78
+ export declare const default_max_minute = 59;
79
+ export declare const default_min_minute = 0;
80
+ export declare const default_max_hour = 23;
81
+ export declare const default_min_hour = 0;
82
+ export declare const default_max_day = 31;
83
+ export declare const default_min_day = 1;
84
+ export declare const default_max_month = 12;
85
+ export declare const default_min_month = 1;
86
+ export declare const default_max_week = 6;
87
+ export declare const default_min_week = 0;
88
+ export declare const createCronRegexText: (options?: Options) => {
89
+ regex: string;
90
+ enableSlot: boolean;
91
+ enableSecond: boolean;
92
+ enableYear: boolean;
93
+ enableDayLast: boolean;
94
+ enableWeekLast: boolean;
95
+ enableInvalid: boolean;
96
+ };
97
+ interface BasicValue {
98
+ text(): string;
99
+ }
100
+ export declare class InvalidValue implements BasicValue {
101
+ private isEnableInvalid;
102
+ constructor(isEnableInvalid: boolean);
103
+ text(): "?" | "*";
104
+ }
105
+ export declare const isInvalidValue: (value: unknown) => value is InvalidValue;
106
+ declare abstract class LastValue implements BasicValue {
107
+ value: number;
108
+ constructor(value: number);
109
+ abstract text(): string;
110
+ }
111
+ export declare class DayLastValue extends LastValue {
112
+ text(): string;
113
+ }
114
+ export declare const isDayLastValue: (value: unknown) => value is DayLastValue;
115
+ export declare class WeekLastValue extends LastValue {
116
+ text(): string;
117
+ }
118
+ export declare const isWeekLastValue: (value: unknown) => value is WeekLastValue;
119
+ export declare class WildcardValue implements BasicValue {
120
+ text(): string;
121
+ }
122
+ export declare const isWildcardValue: (value: unknown) => value is WildcardValue;
123
+ export declare class RangeValue implements BasicValue {
124
+ start: number;
125
+ stop: number;
126
+ constructor(start: number, stop: number);
127
+ text(): string;
128
+ }
129
+ export declare const isRangeValue: (value: unknown) => value is RangeValue;
130
+ type IGroup = number | DayLastValue | WeekLastValue | RangeValue;
131
+ type IValues = WildcardValue | IGroup[];
132
+ export declare class DigitsValue implements BasicValue {
133
+ values: IValues;
134
+ increment?: number | undefined;
135
+ constructor(values: IValues, increment?: number | undefined);
136
+ text(): string;
137
+ }
138
+ export declare const isDigitsValue: (value: unknown) => value is DigitsValue;
139
+ type Digits<T extends string = never> = '*' | number | T | (number | T | [number, number])[];
140
+ type BasicDigits = Digits;
141
+ type DayDigits = Digits<'L' | `L-${number}`>;
142
+ type WeekDigits = Digits<`${number}L`>;
143
+ declare class Parse {
144
+ cron: Cron;
145
+ second?: DigitsValue;
146
+ minute: DigitsValue;
147
+ hour: DigitsValue;
148
+ day: InvalidValue | DigitsValue;
149
+ month: DigitsValue;
150
+ week: InvalidValue | DigitsValue;
151
+ year?: DigitsValue;
152
+ constructor(second: string | undefined, minute: string, hour: string, day: string, month: string, week: string, year: string | undefined, cron: Cron);
153
+ parse(text: string): InvalidValue | DigitsValue;
154
+ setSecond(value: BasicDigits, increment?: number): boolean;
155
+ setMinute(value: BasicDigits, increment?: number): boolean;
156
+ setHour(value: BasicDigits, increment?: number): boolean;
157
+ setDayInvalid(): void;
158
+ setDay(value: '?'): boolean;
159
+ setDay(value: DayDigits, increment?: number): boolean;
160
+ setMonth(value: BasicDigits, increment?: number): boolean;
161
+ setWeekInvalid(): void;
162
+ setWeek(value: '?'): boolean;
163
+ setWeek(value: WeekDigits, increment?: number): boolean;
164
+ setYear(value: BasicDigits, increment?: number): boolean;
165
+ text(): string;
166
+ }
167
+ export declare class Cron {
168
+ #private;
169
+ get isEnableSecond(): boolean;
170
+ get isEnableYear(): boolean;
171
+ get isEnableDayLast(): boolean;
172
+ get isEnableWeekLast(): boolean;
173
+ get isEnableInvalid(): boolean;
174
+ constructor(options?: Options);
175
+ parse(text: string): Parse | undefined;
176
+ }
177
+ export {};