lyb-js 1.0.7 → 1.0.9
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/README.md +143 -144
- package/dist/Base/LibJsGetDataType/index.d.ts +10 -0
- package/dist/Base/{LibGetDataType → LibJsGetDataType}/index.js +4 -4
- package/dist/Base/{LibPromiseTimeout → LibJsPromiseTimeout}/index.d.ts +2 -2
- package/dist/Base/{LibPromiseTimeout → LibJsPromiseTimeout}/index.js +2 -2
- package/dist/Browser/LibJsColorConsole/index.d.ts +15 -0
- package/dist/Browser/{LibColorConsole → LibJsColorConsole}/index.js +3 -3
- package/dist/Browser/{LibIsMobile → LibJsIsMobile}/index.d.ts +1 -1
- package/dist/Browser/{LibIsMobile → LibJsIsMobile}/index.js +1 -1
- package/dist/Browser/{LibIsPad → LibJsIsPad}/index.d.ts +2 -2
- package/dist/Browser/{LibIsPad → LibJsIsPad}/index.js +2 -2
- package/dist/Browser/{LibPathParams → LibJsPathParams}/index.d.ts +2 -2
- package/dist/Browser/{LibPathParams → LibJsPathParams}/index.js +2 -2
- package/dist/Browser/LibJsSetTitleIcon/index.d.ts +7 -0
- package/dist/Browser/{LibSetTitleIcon → LibJsSetTitleIcon}/index.js +2 -2
- package/dist/Browser/{LibTagTitleTip → LibJsTagTitleTip}/index.d.ts +3 -3
- package/dist/Browser/{LibTagTitleTip → LibJsTagTitleTip}/index.js +3 -3
- package/dist/Data/{LibChunkArray → LibJsChunkArray}/index.d.ts +2 -2
- package/dist/Data/{LibChunkArray → LibJsChunkArray}/index.js +2 -2
- package/dist/Data/LibJsDeepJSONParse/index.d.ts +6 -0
- package/dist/Data/{LibDeepJSONParse → LibJsDeepJSONParse}/index.js +5 -5
- package/dist/Data/{LibGroupArrayByKey → LibJsGroupArrayByKey}/index.d.ts +2 -2
- package/dist/Data/{LibGroupArrayByKey → LibJsGroupArrayByKey}/index.js +2 -2
- package/dist/Data/{LibMatchEmail → LibJsMatchEmail}/index.d.ts +2 -2
- package/dist/Data/{LibMatchEmail → LibJsMatchEmail}/index.js +2 -2
- package/dist/Data/{LibShuffleArray → LibJsShuffleArray}/index.d.ts +2 -2
- package/dist/Data/{LibShuffleArray → LibJsShuffleArray}/index.js +2 -2
- package/dist/Data/{LibStepArray → LibJsStepArray}/index.d.ts +2 -2
- package/dist/Data/{LibStepArray → LibJsStepArray}/index.js +2 -2
- package/dist/File/LibJsDownloadImageLink/index.d.ts +7 -0
- package/dist/File/{LibDownloadImageLink → LibJsDownloadImageLink}/index.js +2 -2
- package/dist/File/{LibImageOptimizer → LibJsImageOptimizer}/index.d.ts +3 -4
- package/dist/File/{LibImageOptimizer → LibJsImageOptimizer}/index.js +2 -3
- package/dist/File/LibJsSaveJson/index.d.ts +9 -0
- package/dist/File/{LibSaveJson → LibJsSaveJson}/index.js +3 -3
- package/dist/Formatter/{LibFormatterByte → LibJsFormatterByte}/index.d.ts +2 -2
- package/dist/Formatter/{LibFormatterByte → LibJsFormatterByte}/index.js +2 -2
- package/dist/Formatter/{LibMaskPhoneNumber → LibJsMaskPhoneNumber}/index.d.ts +2 -2
- package/dist/Formatter/{LibMaskPhoneNumber → LibJsMaskPhoneNumber}/index.js +2 -2
- package/dist/Formatter/{LibNumComma → LibJsNumComma}/index.d.ts +2 -2
- package/dist/Formatter/{LibNumComma → LibJsNumComma}/index.js +2 -2
- package/dist/Formatter/{LibNumberUnit → LibJsNumberUnit}/index.d.ts +3 -3
- package/dist/Formatter/{LibNumberUnit → LibJsNumberUnit}/index.js +2 -2
- package/dist/Formatter/LibJsSecondsFormatterChinese/index.d.ts +11 -0
- package/dist/Formatter/{LibSecondsFormatterChinese → LibJsSecondsFormatterChinese}/index.js +5 -5
- package/dist/Math/{LibCalculateExpression → LibJsCalculateExpression}/index.d.ts +2 -2
- package/dist/Math/{LibCalculateExpression → LibJsCalculateExpression}/index.js +2 -2
- package/dist/Math/LibJsConvertAngle/index.d.ts +12 -0
- package/dist/Math/{LibConvertAngle → LibJsConvertAngle}/index.js +3 -3
- package/dist/Math/LibJsCoordsAngle/index.d.ts +15 -0
- package/dist/Math/{LibCoordsAngle → LibJsCoordsAngle}/index.js +4 -4
- package/dist/Math/LibJsCoordsDistance/index.d.ts +15 -0
- package/dist/Math/{LibCoordsDistance → LibJsCoordsDistance}/index.js +4 -4
- package/dist/Math/LibJsDecimal/index.d.ts +10 -0
- package/dist/Math/{LibDecimal → LibJsDecimal}/index.js +4 -4
- package/dist/Misc/{LibRegFormValidate → LibJsRegFormValidate}/index.d.ts +3 -3
- package/dist/Misc/{LibRegFormValidate → LibJsRegFormValidate}/index.js +3 -3
- package/dist/Misc/{LibRetryRequest → LibJsRetryRequest}/index.d.ts +2 -2
- package/dist/Misc/{LibRetryRequest → LibJsRetryRequest}/index.js +2 -2
- package/dist/Random/LibJsProbabilityResult/index.d.ts +8 -0
- package/dist/Random/LibJsProbabilityResult/index.js +8 -0
- package/dist/Random/LibJsRandom/index.d.ts +9 -0
- package/dist/Random/{LibRandom → LibJsRandom}/index.js +3 -3
- package/dist/Random/LibJsRandomColor/index.d.ts +7 -0
- package/dist/Random/{LibRandomColor → LibJsRandomColor}/index.js +3 -3
- package/dist/Random/LibJsUniqueRandomNumbers/index.d.ts +9 -0
- package/dist/Random/{LibUniqueRandomNumbers → LibJsUniqueRandomNumbers}/index.js +3 -3
- package/dist/Time/{LibSameTimeCheck → LibJsSameTimeCheck}/index.d.ts +1 -1
- package/dist/Time/{LibSameTimeCheck → LibJsSameTimeCheck}/index.js +1 -1
- package/dist/Time/LibJsTimeAgo/index.d.ts +9 -0
- package/dist/Time/{LibTimeAgo → LibJsTimeAgo}/index.js +5 -5
- package/dist/Time/LibJsTimeGreeting/index.d.ts +17 -0
- package/dist/Time/{LibTimeGreeting → LibJsTimeGreeting}/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{lib.d.ts → libJs.d.ts} +97 -97
- package/dist/{lib.js → libJs.js} +132 -132
- package/package.json +1 -1
- package/dist/Base/LibGetDataType/index.d.ts +0 -10
- package/dist/Browser/LibColorConsole/index.d.ts +0 -15
- package/dist/Browser/LibSetTitleIcon/index.d.ts +0 -7
- package/dist/Data/LibDeepJSONParse/index.d.ts +0 -6
- package/dist/File/LibDownloadImageLink/index.d.ts +0 -7
- package/dist/File/LibSaveJson/index.d.ts +0 -9
- package/dist/Formatter/LibSecondsFormatterChinese/index.d.ts +0 -11
- package/dist/Math/LibConvertAngle/index.d.ts +0 -12
- package/dist/Math/LibCoordsAngle/index.d.ts +0 -15
- package/dist/Math/LibCoordsDistance/index.d.ts +0 -15
- package/dist/Math/LibDecimal/index.d.ts +0 -10
- package/dist/Random/LibProbabilityResult/index.d.ts +0 -8
- package/dist/Random/LibProbabilityResult/index.js +0 -8
- package/dist/Random/LibRandom/index.d.ts +0 -9
- package/dist/Random/LibRandomColor/index.d.ts +0 -7
- package/dist/Random/LibUniqueRandomNumbers/index.d.ts +0 -9
- package/dist/Time/LibTimeAgo/index.d.ts +0 -9
- package/dist/Time/LibTimeGreeting/index.d.ts +0 -17
|
@@ -4,21 +4,21 @@ export declare const Base: {
|
|
|
4
4
|
* @description 返回数据类型
|
|
5
5
|
* @param v 需要判断类型的数据
|
|
6
6
|
* @example
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* libJsGetDataType(123); //"number"
|
|
8
|
+
* libJsGetDataType("hello"); //"string"
|
|
9
|
+
* libJsGetDataType([1, 2, 3]); //"array"
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
libJsGetDataType: (v: any) => import("./Base/LibJsGetDataType").LibJsGetDataTypeReturnType;
|
|
12
12
|
/**
|
|
13
13
|
* @description 延时执行,切换到其他页面会暂停
|
|
14
14
|
* @param delay 延时毫秒数
|
|
15
15
|
* @param fn 延时执行函数
|
|
16
16
|
* @example
|
|
17
|
-
*
|
|
17
|
+
* libJsPromiseTimeout(3000, () => {
|
|
18
18
|
* console.log("执行延时函数");
|
|
19
19
|
* });
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
libJsPromiseTimeout: (delay?: number, fn?: () => void) => Promise<void>;
|
|
22
22
|
};
|
|
23
23
|
/** @description 浏览器相关方法 */
|
|
24
24
|
export declare const Browser: {
|
|
@@ -28,47 +28,47 @@ export declare const Browser: {
|
|
|
28
28
|
* @param logs 信息
|
|
29
29
|
* @example
|
|
30
30
|
* //使用红色打印日志
|
|
31
|
-
*
|
|
31
|
+
* libJsColorConsole("错误提示", "red", [{ label: "错误代码", value: 500 }]);
|
|
32
32
|
*
|
|
33
33
|
* //使用蓝色打印简单日志
|
|
34
|
-
*
|
|
34
|
+
* libJsColorConsole("信息", "blue", "操作成功");
|
|
35
35
|
*/
|
|
36
|
-
|
|
36
|
+
libJsColorConsole: (title: string, color: "red" | "orange" | "yellow" | "green" | "blue" | "purple", logs?: {
|
|
37
37
|
label: string;
|
|
38
38
|
value: any;
|
|
39
39
|
}[] | any) => void;
|
|
40
40
|
/** @description 判断是否为移动设备
|
|
41
41
|
* @example
|
|
42
|
-
* const isMobile =
|
|
42
|
+
* const isMobile = libJsIsMobile();
|
|
43
43
|
* console.log(isMobile); //true 或 false
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
libJsIsMobile: () => boolean;
|
|
46
46
|
/** @description 判断是否为平板
|
|
47
47
|
* @example
|
|
48
|
-
* const isPad =
|
|
48
|
+
* const isPad = libJsIsPad();
|
|
49
49
|
* console.log(isPad); //true 或 false
|
|
50
50
|
*/
|
|
51
|
-
|
|
51
|
+
libJsIsPad: () => boolean;
|
|
52
52
|
/** @description 获取浏览器地址栏参数
|
|
53
53
|
* @example
|
|
54
|
-
* const params =
|
|
54
|
+
* const params = libJsPathParams();
|
|
55
55
|
* console.log(params); //{ param1: "value1", param2: "value2" }
|
|
56
56
|
*/
|
|
57
|
-
|
|
57
|
+
libJsPathParams: () => Record<string, string>;
|
|
58
58
|
/** @description 动态设置网站标题及图标
|
|
59
59
|
* @param title 网站标题
|
|
60
60
|
* @param url 网站图标地址
|
|
61
61
|
* @example
|
|
62
|
-
*
|
|
62
|
+
* libJsSetTitleIcon("我的网站", "https://example.com/favicon.ico");
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
libJsSetTitleIcon: (title: string, url: string) => void;
|
|
65
65
|
/** @description 网站标题交互,当从当前网页切换到其他网页,网站标题自动切换
|
|
66
66
|
* @param backTitle 从其他网页返回时显示的标题
|
|
67
67
|
* @param leaveTitle 从当前网页离开时显示的标题
|
|
68
68
|
* * @example
|
|
69
|
-
*
|
|
69
|
+
* libJsTagTitleTip("欢迎回来", "来和妲己玩耍吧!");
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
libJsTagTitleTip: (backTitle: string, leaveTitle: string) => void;
|
|
72
72
|
};
|
|
73
73
|
/** @description 数据相关方法 */
|
|
74
74
|
export declare const Data: {
|
|
@@ -77,51 +77,51 @@ export declare const Data: {
|
|
|
77
77
|
* @param arr 需要拆分的数组
|
|
78
78
|
* @param chunkSize 每个数组的元素数量
|
|
79
79
|
* @example
|
|
80
|
-
* const chunks =
|
|
80
|
+
* const chunks = libJsChunkArray([1, 2, 3, 4, 5, 6], 2);
|
|
81
81
|
* console.log(chunks); //[[1, 2], [3, 4], [5, 6]]
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
libJsChunkArray: <T>(arr: T[], chunkSize: number) => T[][];
|
|
84
84
|
/** @description 递归将JSON字符串深度解析为对象
|
|
85
85
|
* @example
|
|
86
|
-
* const obj =
|
|
86
|
+
* const obj = libJsDeepJSONParse('{"a": 1, "b": "{\"c\": 2}"}');
|
|
87
87
|
* console.log(obj); //{ a: 1, b: { c: 2 } }
|
|
88
88
|
*/
|
|
89
|
-
|
|
89
|
+
libJsDeepJSONParse: <T>(data: any) => T;
|
|
90
90
|
/**
|
|
91
91
|
* @description 分类汇总,将数组对象按照指定键值整理成一个以键值为键名的对象
|
|
92
92
|
* @param arr 要分组的数组
|
|
93
93
|
* @param key 分组的键
|
|
94
94
|
* @returns 分组后的对象
|
|
95
95
|
* @example
|
|
96
|
-
* const grouped =
|
|
96
|
+
* const grouped = libJsGroupArrayByKey([{ id: 1, name: 'A' }, { id: 2, name: 'B' }, { id: 1, name: 'C' }], 'id');
|
|
97
97
|
* console.log(grouped); //{ 1: [{ id: 1, name: 'A' }, { id: 1, name: 'C' }], 2: [{ id: 2, name: 'B' }] }
|
|
98
98
|
*/
|
|
99
|
-
|
|
99
|
+
libJsGroupArrayByKey: (arr: any[] | undefined, key: string) => any;
|
|
100
100
|
/**
|
|
101
101
|
* @description 匹配电子邮件,可用于实时输入时,自动补全常用邮箱后缀
|
|
102
102
|
* @param str 要匹配的字符串
|
|
103
103
|
* @param emailList 电子邮件后缀列表
|
|
104
104
|
* @returns 匹配结果数组
|
|
105
105
|
* @example
|
|
106
|
-
* const emails =
|
|
106
|
+
* const emails = libJsMatchEmail("user", ["@gmail.com", "@yahoo.com"]);
|
|
107
107
|
* console.log(emails); //["user@gmail.com", "user@yahoo.com"]
|
|
108
108
|
*/
|
|
109
|
-
|
|
109
|
+
libJsMatchEmail: (str: string, emailList: string[]) => string[];
|
|
110
110
|
/** @description 数组乱序
|
|
111
111
|
* @param arr 需要乱序的数组
|
|
112
112
|
* @example
|
|
113
|
-
* const shuffled =
|
|
113
|
+
* const shuffled = libJsShuffleArray([1, 2, 3, 4, 5]);
|
|
114
114
|
* console.log(shuffled); //[3, 5, 2, 1, 4] (结果每次不同)
|
|
115
115
|
*/
|
|
116
|
-
|
|
116
|
+
libJsShuffleArray: <T>(arr: T[]) => T[];
|
|
117
117
|
/** @description 数组元素整体步数移动
|
|
118
118
|
* @param arr 移动的数组
|
|
119
119
|
* @param step 负数为向后移动,正数为向前移动
|
|
120
120
|
* @example
|
|
121
|
-
* const moved =
|
|
121
|
+
* const moved = libJsStepArray([1, 2, 3, 4, 5], 2);
|
|
122
122
|
* console.log(moved); //[4, 5, 1, 2, 3]
|
|
123
123
|
*/
|
|
124
|
-
|
|
124
|
+
libJsStepArray: <T>(arr: T[], step: number) => T[];
|
|
125
125
|
};
|
|
126
126
|
/** @description 文件相关方法 */
|
|
127
127
|
export declare const File: {
|
|
@@ -129,14 +129,14 @@ export declare const File: {
|
|
|
129
129
|
* @param link 图片链接
|
|
130
130
|
* @param name 图片名称
|
|
131
131
|
* @example
|
|
132
|
-
*
|
|
132
|
+
* libJsDownloadImageLink("https://example.com/image.jpg", "downloaded-image.jpg");
|
|
133
133
|
*/
|
|
134
|
-
|
|
134
|
+
libJsDownloadImageLink: (link: string, name: string) => void;
|
|
135
135
|
/** @description 图片压缩
|
|
136
136
|
* @param obj 压缩参数
|
|
137
137
|
* @example
|
|
138
138
|
* //图片压缩使用示例
|
|
139
|
-
*
|
|
139
|
+
* libJsImageOptimizerOptionsParams({
|
|
140
140
|
* file: myFile,
|
|
141
141
|
* ratio: 0.8,
|
|
142
142
|
* width: 800,
|
|
@@ -149,15 +149,15 @@ export declare const File: {
|
|
|
149
149
|
* }
|
|
150
150
|
* });
|
|
151
151
|
*/
|
|
152
|
-
|
|
152
|
+
libJsImageOptimizer: (obj: import("./File/LibJsImageOptimizer").LibJsImageOptimizerOptionsParams) => void;
|
|
153
153
|
/**
|
|
154
154
|
* @description 保存文件到本地
|
|
155
155
|
* @param data 要保存的数据
|
|
156
156
|
* @param name 文件名
|
|
157
157
|
* @example
|
|
158
|
-
*
|
|
158
|
+
* libJsSaveJson(JSON.stringify({ key: "value" }), "example.json");
|
|
159
159
|
*/
|
|
160
|
-
|
|
160
|
+
libJsSaveJson: (data: BlobPart, name: string) => void;
|
|
161
161
|
};
|
|
162
162
|
/** @description 格式化相关方法 */
|
|
163
163
|
export declare const Formatter: {
|
|
@@ -166,47 +166,47 @@ export declare const Formatter: {
|
|
|
166
166
|
* @param bytes 字节数
|
|
167
167
|
* @returns ['大小', '单位', '大小及单位']
|
|
168
168
|
* @example
|
|
169
|
-
* const [size, unit, formatted] =
|
|
169
|
+
* const [size, unit, formatted] = libJsFormatterByte(2048);
|
|
170
170
|
* console.log(size, unit, formatted); //2.00 KB 2.00 KB
|
|
171
171
|
*/
|
|
172
|
-
|
|
172
|
+
libJsFormatterByte: (bytes: number) => (string | number)[];
|
|
173
173
|
/**
|
|
174
174
|
* @description 隐藏手机号码中间的四位数字
|
|
175
175
|
* @param mobile 需要处理的手机号码
|
|
176
176
|
* @example
|
|
177
|
-
* const masked =
|
|
177
|
+
* const masked = libJsMaskPhoneNumber("13812345678");
|
|
178
178
|
* console.log(masked); //138****5678
|
|
179
179
|
*/
|
|
180
|
-
|
|
180
|
+
libJsMaskPhoneNumber: (mobile: number | string) => string;
|
|
181
181
|
/**
|
|
182
182
|
* @description 数字每三位添加逗号
|
|
183
183
|
* @param num 需要格式化的数字
|
|
184
184
|
* @param reserve 保留小数位数
|
|
185
185
|
* @example
|
|
186
|
-
* const formatted =
|
|
186
|
+
* const formatted = libJsNumComma(1234567.89);
|
|
187
187
|
* console.log(formatted); //1,234,567.89
|
|
188
188
|
*/
|
|
189
|
-
|
|
189
|
+
libJsNumComma: (num: number, reserve?: number) => string;
|
|
190
190
|
/** @description 将大于1000的数字使用k为单位
|
|
191
191
|
* @param num 数字
|
|
192
192
|
* @param units 单位组,key为单位,value为格式化阈值
|
|
193
193
|
* @returns [数字, 单位]
|
|
194
194
|
* @example
|
|
195
|
-
* const [value, unit] =
|
|
195
|
+
* const [value, unit] = libJsNumberUnit(1500, { K: 1000, M: 1000000 });
|
|
196
196
|
* console.log(value, unit); //1.50 K
|
|
197
197
|
*/
|
|
198
|
-
|
|
198
|
+
libJsNumberUnit: (num: number, units: import("./Formatter/LibJsNumberUnit").LibJsNumberUnitParams) => string[];
|
|
199
199
|
/**
|
|
200
200
|
* @description 将秒数格式化为中文时间描述,支持扩展到年和月
|
|
201
201
|
* @param seconds 秒数
|
|
202
202
|
* @returns 格式化后的中文时间
|
|
203
203
|
* @example
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
204
|
+
* libJsSecondsFormatterChinese(100000); //"1天3小时46分40秒"
|
|
205
|
+
* libJsSecondsFormatterChinese(31536000); //"1年"
|
|
206
|
+
* libJsSecondsFormatterChinese(3600); //"1小时"
|
|
207
|
+
* libJsSecondsFormatterChinese(90); //"1分30秒"
|
|
208
208
|
*/
|
|
209
|
-
|
|
209
|
+
libJsSecondsFormatterChinese: (seconds: number) => string;
|
|
210
210
|
};
|
|
211
211
|
/** @description 数学相关方法 */
|
|
212
212
|
export declare const Math: {
|
|
@@ -216,31 +216,31 @@ export declare const Math: {
|
|
|
216
216
|
* @returns 计算结果
|
|
217
217
|
*
|
|
218
218
|
* @example
|
|
219
|
-
* const result =
|
|
219
|
+
* const result = libJsCalculateExpression("(1+2)-(3*4)/5");
|
|
220
220
|
* console.log(result); //0.6
|
|
221
221
|
*/
|
|
222
|
-
|
|
222
|
+
libJsCalculateExpression: (expression: string, point?: number) => number;
|
|
223
223
|
/**
|
|
224
224
|
* @description 角度和弧度互相转换
|
|
225
225
|
* @param value 角度值或弧度值
|
|
226
226
|
* @param type 角度类型或弧度类型
|
|
227
227
|
* @example
|
|
228
228
|
* //角度转弧度
|
|
229
|
-
*
|
|
229
|
+
* libJsConvertAngle(90, "rad"); //返回 1.5708... (π/2)
|
|
230
230
|
*
|
|
231
231
|
* //弧度转角度
|
|
232
|
-
*
|
|
232
|
+
* libJsConvertAngle(Math.PI, "deg"); //返回 180
|
|
233
233
|
*/
|
|
234
|
-
|
|
234
|
+
libJsConvertAngle: (value: number, type: "rad" | "deg") => number;
|
|
235
235
|
/** @description 计算两点角度
|
|
236
236
|
* @param coord1 起点坐标
|
|
237
237
|
* @param coord2 终点坐标
|
|
238
238
|
* @example
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
239
|
+
* libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 0 }); //0
|
|
240
|
+
* libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 1 }); //45
|
|
241
|
+
* libJsCoordsAngle({ x: 0, y: 0 }, { x: 0, y: 1 }); //90
|
|
242
242
|
*/
|
|
243
|
-
|
|
243
|
+
libJsCoordsAngle: (coord1: {
|
|
244
244
|
x: number;
|
|
245
245
|
y: number;
|
|
246
246
|
}, coord2: {
|
|
@@ -251,11 +251,11 @@ export declare const Math: {
|
|
|
251
251
|
* @param coord1 起点坐标
|
|
252
252
|
* @param coord2 终点坐标
|
|
253
253
|
* @example
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
254
|
+
* libJsCoordsDistance({ x: 0, y: 0 }, { x: 3, y: 4 }); //5
|
|
255
|
+
* libJsCoordsDistance({ x: 1, y: 1 }, { x: 4, y: 5 }); //5
|
|
256
|
+
* libJsCoordsDistance({ x: 0, y: 0 }, { x: 0, y: 0 }); //0
|
|
257
257
|
*/
|
|
258
|
-
|
|
258
|
+
libJsCoordsDistance: (coord1: {
|
|
259
259
|
x: number;
|
|
260
260
|
y: number;
|
|
261
261
|
}, coord2: {
|
|
@@ -267,11 +267,11 @@ export declare const Math: {
|
|
|
267
267
|
* @param num2 第二个数
|
|
268
268
|
* @param operator 运算符,支持加减乘除
|
|
269
269
|
* @example
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
270
|
+
* libJsDecimal(10, 3, "+"); //13
|
|
271
|
+
* libJsDecimal(10, 3, "-"); //7
|
|
272
|
+
* libJsDecimal(10, 3, "/", 2); //3.33
|
|
273
273
|
*/
|
|
274
|
-
|
|
274
|
+
libJsDecimal: (num1: number, num2: number, operator: "+" | "-" | "*" | "/", point?: number) => number;
|
|
275
275
|
};
|
|
276
276
|
/** @description 杂项相关方法 */
|
|
277
277
|
export declare const Misc: {
|
|
@@ -286,22 +286,22 @@ export declare const Misc: {
|
|
|
286
286
|
* { key: "username", verify: /^[a-zA-Z0-9]{3,}$/, msg: "用户名不合法", name: "用户名" },
|
|
287
287
|
* { key: "email", verify: /^\S+@\S+\.\S+$/, msg: "邮箱格式不正确", name: "邮箱" },
|
|
288
288
|
* ];
|
|
289
|
-
*
|
|
289
|
+
* libJsRegFormValidate(form, rules);
|
|
290
290
|
* //返回结果: []
|
|
291
291
|
*
|
|
292
292
|
* const invalidForm = { username: "jo", email: "invalid-email" };
|
|
293
|
-
*
|
|
293
|
+
* libJsRegFormValidate(invalidForm, rules);
|
|
294
294
|
* //返回结果: [
|
|
295
295
|
* // { key: "username", msg: "用户名不合法", name: "用户名" },
|
|
296
296
|
* // { key: "email", msg: "邮箱格式不正确", name: "邮箱" }
|
|
297
297
|
* //]
|
|
298
298
|
*/
|
|
299
|
-
|
|
299
|
+
libJsRegFormValidate: (form: Record<string, any>, rules: Array<{
|
|
300
300
|
key: string;
|
|
301
301
|
verify: RegExp | ((value: any) => boolean);
|
|
302
302
|
msg: string;
|
|
303
303
|
name: string;
|
|
304
|
-
}>) => import("./Misc/
|
|
304
|
+
}>) => import("./Misc/LibJsRegFormValidate").ValidationResult[];
|
|
305
305
|
/** @description 请求失败重连
|
|
306
306
|
* @param promiseFn 请求函数
|
|
307
307
|
* @param maxRetries 最大重试次数
|
|
@@ -310,7 +310,7 @@ export declare const Misc: {
|
|
|
310
310
|
* @example
|
|
311
311
|
* const requestFn = (params: { url: string }) => fetch(params.url).then(res => res.json());
|
|
312
312
|
* const params = { url: "https://api.example.com/data" };
|
|
313
|
-
*
|
|
313
|
+
* libJsRetryRequest({
|
|
314
314
|
* promiseFn: requestFn,
|
|
315
315
|
* params,
|
|
316
316
|
* maxRetries: 5,
|
|
@@ -319,7 +319,7 @@ export declare const Misc: {
|
|
|
319
319
|
* .then(data => console.log(data))
|
|
320
320
|
* .catch(err => console.error(err));
|
|
321
321
|
*/
|
|
322
|
-
|
|
322
|
+
libJsRetryRequest: <T>({ promiseFn, maxRetries, retryDelay, params, }: {
|
|
323
323
|
promiseFn: (params?: any) => Promise<T>;
|
|
324
324
|
params?: any;
|
|
325
325
|
maxRetries?: number;
|
|
@@ -332,37 +332,37 @@ export declare const Random: {
|
|
|
332
332
|
/** @description 百分比概率结果
|
|
333
333
|
* @param probability 触发概率,百分比,0-100
|
|
334
334
|
* @example
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
335
|
+
* libJsProbabilityResult(50); //50% 概率为 true
|
|
336
|
+
* libJsProbabilityResult(80); //80% 概率为 true
|
|
337
|
+
* libJsProbabilityResult(100); //100% 概率为 true
|
|
338
338
|
*/
|
|
339
|
-
|
|
339
|
+
libJsProbabilityResult: (probability: number) => boolean;
|
|
340
340
|
/** @description 随机数
|
|
341
341
|
* @param min 最小值
|
|
342
342
|
* @param max 最大值
|
|
343
343
|
* @param num 保留小数位数
|
|
344
344
|
* @example
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
345
|
+
* libJsRandom(1, 10); //1 到 10 之间的随机整数
|
|
346
|
+
* libJsRandom(1, 10, 2); //1 到 10 之间保留两位小数的随机数
|
|
347
|
+
* libJsRandom(5, 5, 3); //返回 5.000
|
|
348
348
|
*/
|
|
349
|
-
|
|
349
|
+
libJsRandom: (min: number, max: number, num?: number) => number;
|
|
350
350
|
/** @description 随机 RGBA 颜色
|
|
351
351
|
* @param alpha 透明度
|
|
352
352
|
* @example
|
|
353
|
-
*
|
|
354
|
-
*
|
|
353
|
+
* libJsRandomColor(); //生成随机的 RGBA 颜色,默认透明度 1
|
|
354
|
+
* libJsRandomColor(0.5); //生成随机的 RGBA 颜色,透明度为 0.5
|
|
355
355
|
*/
|
|
356
|
-
|
|
356
|
+
libJsRandomColor: (alpha?: number) => string;
|
|
357
357
|
/** @description 随机生成n个指定范围的随机数数组
|
|
358
358
|
* @param min 最小值
|
|
359
359
|
* @param max 最大值
|
|
360
360
|
* @param count 数组长度
|
|
361
361
|
* @example
|
|
362
|
-
*
|
|
363
|
-
*
|
|
362
|
+
* libJsUniqueRandomNumbers(1, 10, 5); //从 1 到 10 中随机生成 5 个唯一数字
|
|
363
|
+
* libJsUniqueRandomNumbers(1, 100, 10); //从 1 到 100 中随机生成 10 个唯一数字
|
|
364
364
|
*/
|
|
365
|
-
|
|
365
|
+
libJsUniqueRandomNumbers: (min: number, max: number, count: number) => number[];
|
|
366
366
|
};
|
|
367
367
|
/** @description 时间相关方法 */
|
|
368
368
|
export declare const Time: {
|
|
@@ -372,23 +372,23 @@ export declare const Time: {
|
|
|
372
372
|
* @param unit 判断单位
|
|
373
373
|
* @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
|
|
374
374
|
*/
|
|
375
|
-
|
|
375
|
+
libJsSameTimeCheck: (timestamp: number, unit: import("dayjs").OpUnitType) => 0 | 1 | -1;
|
|
376
376
|
/** @description 时间差计算
|
|
377
377
|
* @param timestamp 毫秒时间戳
|
|
378
378
|
* @example
|
|
379
|
-
*
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
*
|
|
379
|
+
* libJsTimeAgotamp(Date.now() - 3600000); //"1 小时前"
|
|
380
|
+
* libJsTimeAgotamp(Date.now() - 86400000); //"1 天前"
|
|
381
|
+
* libJsTimeAgotamp(Date.now() - 31536000000); //"1 年前"
|
|
382
|
+
* libJsTimeAgotamp(Date.now() - 10000); //"刚刚"
|
|
383
383
|
*/
|
|
384
|
-
|
|
384
|
+
libJsTimeAgo: (timestamp: number) => string;
|
|
385
385
|
/**
|
|
386
386
|
* @description 根据当前时间返回问候语
|
|
387
387
|
* @param greet 自定义问候语对象
|
|
388
388
|
* @example
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
389
|
+
* libJsTimeGreeting(); //根据当前时间返回默认问候语
|
|
390
|
+
* libJsTimeGreeting({ morning: "早安" }); //自定义早上问候语
|
|
391
|
+
* libJsTimeGreeting({ afternoon: "午后好" }); //自定义下午问候语
|
|
392
392
|
*/
|
|
393
|
-
|
|
393
|
+
libJsTimeGreeting: (greet?: import("./Time/LibJsTimeGreeting").LibTimeGreetingParams) => string;
|
|
394
394
|
};
|