@vope/utils 1.6.1 → 1.6.3
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/calc.d.ts +13 -0
- package/dist/calc.js +22 -0
- package/dist/cron.d.ts +177 -0
- package/dist/cron.js +674 -0
- package/dist/index.cjs.js +713 -19
- package/dist/index.d.ts +2 -0
- package/dist/index.js +32 -1
- package/package.json +1 -1
- package/sub_storage/offline.cjs.js +0 -1
package/dist/calc.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Ls = `${string}(${string})` | `${number}${string}`;
|
|
2
|
+
type Lv = Ls | number;
|
|
3
|
+
export declare namespace Calc {
|
|
4
|
+
type Value = Lv;
|
|
5
|
+
}
|
|
6
|
+
declare const formatter: (value: Lv) => 0 | Ls;
|
|
7
|
+
interface Calc {
|
|
8
|
+
(...list: Lv[]): 0 | Ls;
|
|
9
|
+
formatter: typeof formatter;
|
|
10
|
+
}
|
|
11
|
+
export declare const isCalc: (value: Ls) => value is `calc(${string})`;
|
|
12
|
+
declare const calc: Calc;
|
|
13
|
+
export { calc, };
|
package/dist/calc.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isNumber } from "lodash-es";
|
|
2
|
+
const formatter = (value) => isNumber(value) ? value && `${value}px` : value;
|
|
3
|
+
const isCalc = (value) => value.slice(0, 5) === "calc(" && value.slice(-1) === ")";
|
|
4
|
+
const calc = (...list) => {
|
|
5
|
+
const size = list.length;
|
|
6
|
+
if (size === 0) return 0;
|
|
7
|
+
if (size === 1) return formatter(list[1]);
|
|
8
|
+
const value = list.reduce((caches, value2) => {
|
|
9
|
+
let tmp = formatter(value2);
|
|
10
|
+
if (tmp === 0) return caches;
|
|
11
|
+
if (isCalc(tmp)) {
|
|
12
|
+
tmp = tmp.slice(4);
|
|
13
|
+
}
|
|
14
|
+
return caches ? `${caches} + ${tmp}` : tmp;
|
|
15
|
+
}, "");
|
|
16
|
+
return value === "" ? 0 : `calc(${value})`;
|
|
17
|
+
};
|
|
18
|
+
calc.formatter = formatter;
|
|
19
|
+
export {
|
|
20
|
+
calc,
|
|
21
|
+
isCalc
|
|
22
|
+
};
|
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 {};
|