lyb-js 1.1.1 → 1.1.4
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 +12 -0
- package/dist/Base/LibJsGetDataType/index.d.ts +1 -0
- package/dist/Base/LibJsGetDataType/index.js +1 -0
- package/dist/Base/LibJsPromiseTimeout/index.d.ts +1 -0
- package/dist/Base/LibJsPromiseTimeout/index.js +1 -0
- package/dist/Browser/LibJsColorConsole/index.d.ts +1 -0
- package/dist/Browser/LibJsColorConsole/index.js +1 -0
- package/dist/Browser/LibJsIsMobile/index.d.ts +1 -0
- package/dist/Browser/LibJsIsMobile/index.js +1 -0
- package/dist/Browser/LibJsIsPad/index.d.ts +1 -0
- package/dist/Browser/LibJsIsPad/index.js +1 -0
- package/dist/Browser/LibJsObjToUrlParams/index.d.ts +1 -0
- package/dist/Browser/LibJsObjToUrlParams/index.js +1 -0
- package/dist/Browser/LibJsPathParams/index.d.ts +1 -0
- package/dist/Browser/LibJsPathParams/index.js +1 -0
- package/dist/Browser/LibJsSetTitleIcon/index.d.ts +1 -0
- package/dist/Browser/LibJsSetTitleIcon/index.js +1 -0
- package/dist/Browser/LibJsTagTitleTip/index.d.ts +1 -0
- package/dist/Browser/LibJsTagTitleTip/index.js +1 -0
- package/dist/Data/LibJsChunkArray/index.d.ts +1 -0
- package/dist/Data/LibJsChunkArray/index.js +1 -0
- package/dist/Data/LibJsDeepJSONParse/index.d.ts +1 -0
- package/dist/Data/LibJsDeepJSONParse/index.js +1 -0
- package/dist/Data/LibJsGroupArrayByKey/index.d.ts +1 -0
- package/dist/Data/LibJsGroupArrayByKey/index.js +1 -0
- package/dist/Data/LibJsMatchEmail/index.d.ts +1 -0
- package/dist/Data/LibJsMatchEmail/index.js +1 -0
- package/dist/Data/LibJsShuffleArray/index.d.ts +1 -0
- package/dist/Data/LibJsShuffleArray/index.js +1 -0
- package/dist/Data/LibJsStepArray/index.d.ts +2 -1
- package/dist/Data/LibJsStepArray/index.js +2 -1
- package/dist/Data/LibReverseArrayFromIndex/index.d.ts +1 -0
- package/dist/Data/LibReverseArrayFromIndex/index.js +1 -0
- package/dist/File/LibJsDownloadImageLink/index.d.ts +1 -0
- package/dist/File/LibJsDownloadImageLink/index.js +1 -0
- package/dist/File/LibJsImageOptimizer/index.d.ts +1 -0
- package/dist/File/LibJsImageOptimizer/index.js +1 -0
- package/dist/File/LibJsSaveJson/index.d.ts +1 -0
- package/dist/File/LibJsSaveJson/index.js +1 -0
- package/dist/Formatter/LibJsFormatterByte/index.d.ts +1 -0
- package/dist/Formatter/LibJsFormatterByte/index.js +1 -0
- package/dist/Formatter/LibJsMaskPhoneNumber/index.d.ts +2 -1
- package/dist/Formatter/LibJsMaskPhoneNumber/index.js +2 -1
- package/dist/Formatter/LibJsNumComma/index.d.ts +1 -0
- package/dist/Formatter/LibJsNumComma/index.js +1 -0
- package/dist/Formatter/LibJsNumberUnit/index.d.ts +1 -0
- package/dist/Formatter/LibJsNumberUnit/index.js +1 -0
- package/dist/Formatter/LibJsSecondsFormatterChinese/index.d.ts +1 -0
- package/dist/Formatter/LibJsSecondsFormatterChinese/index.js +1 -0
- package/dist/Math/LibJsCalculateExpression/index.d.ts +1 -0
- package/dist/Math/LibJsCalculateExpression/index.js +1 -0
- package/dist/Math/LibJsConvertAngle/index.d.ts +1 -0
- package/dist/Math/LibJsConvertAngle/index.js +1 -0
- package/dist/Math/LibJsCoordsAngle/index.d.ts +1 -0
- package/dist/Math/LibJsCoordsAngle/index.js +1 -0
- package/dist/Math/LibJsCoordsDistance/index.d.ts +1 -0
- package/dist/Math/LibJsCoordsDistance/index.js +1 -0
- package/dist/Math/LibJsDecimal/index.d.ts +1 -0
- package/dist/Math/LibJsDecimal/index.js +1 -0
- package/dist/Misc/LibJsRegFormValidate/index.d.ts +1 -0
- package/dist/Misc/LibJsRegFormValidate/index.js +1 -0
- package/dist/Misc/LibJsRetryRequest/index.d.ts +1 -0
- package/dist/Misc/LibJsRetryRequest/index.js +1 -0
- package/dist/Misc/LibNumerStepper/index.d.ts +1 -0
- package/dist/Misc/LibNumerStepper/index.js +1 -0
- package/dist/Random/LibJsProbabilityResult/index.d.ts +1 -0
- package/dist/Random/LibJsProbabilityResult/index.js +1 -0
- package/dist/Random/LibJsRandom/index.d.ts +2 -1
- package/dist/Random/LibJsRandom/index.js +2 -1
- package/dist/Random/LibJsRandomColor/index.d.ts +1 -0
- package/dist/Random/LibJsRandomColor/index.js +1 -0
- package/dist/Random/LibJsUniqueRandomNumbers/index.d.ts +1 -0
- package/dist/Random/LibJsUniqueRandomNumbers/index.js +1 -0
- package/dist/Time/LibJsSameTimeCheck/index.d.ts +1 -0
- package/dist/Time/LibJsSameTimeCheck/index.js +1 -0
- package/dist/Time/LibJsTimeAgo/index.d.ts +1 -0
- package/dist/Time/LibJsTimeAgo/index.js +1 -0
- package/dist/Time/LibJsTimeGreeting/index.d.ts +1 -0
- package/dist/Time/LibJsTimeGreeting/index.js +1 -0
- package/dist/libJs.d.ts +39 -1
- package/dist/libJs.js +39 -1
- package/package.json +12 -5
- package/umd/lyb.js +8 -0
|
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
|
|
4
4
|
* @param timestamp 毫秒时间戳
|
|
5
5
|
* @param unit 判断单位
|
|
6
6
|
* @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
|
|
7
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
7
8
|
* @example
|
|
8
9
|
* const timestamp = 1679872800000; //时间戳
|
|
9
10
|
* const result = libSameTimeCheck(timestamp, 'day'); //判断是否为同一天
|
|
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
|
|
4
4
|
* @param timestamp 毫秒时间戳
|
|
5
5
|
* @param unit 判断单位
|
|
6
6
|
* @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
|
|
7
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
7
8
|
* @example
|
|
8
9
|
* const timestamp = 1679872800000; //时间戳
|
|
9
10
|
* const result = libSameTimeCheck(timestamp, 'day'); //判断是否为同一天
|
|
@@ -9,6 +9,7 @@ export interface LibTimeGreetingParams {
|
|
|
9
9
|
/**
|
|
10
10
|
* @description 根据当前时间返回问候语
|
|
11
11
|
* @param greet 自定义问候语对象
|
|
12
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
12
13
|
* @example
|
|
13
14
|
* libJsTimeGreeting(); //根据当前时间返回默认问候语
|
|
14
15
|
* libJsTimeGreeting({ morning: "早安" }); //自定义早上问候语
|
package/dist/libJs.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare const Base: {
|
|
|
4
4
|
/**
|
|
5
5
|
* @description 返回数据类型
|
|
6
6
|
* @param v 需要判断类型的数据
|
|
7
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
7
8
|
* @example
|
|
8
9
|
* libJsGetDataType(123); //"number"
|
|
9
10
|
* libJsGetDataType("hello"); //"string"
|
|
@@ -14,6 +15,7 @@ export declare const Base: {
|
|
|
14
15
|
* @description 延时执行,切换到其他页面会暂停
|
|
15
16
|
* @param delay 延时毫秒数
|
|
16
17
|
* @param fn 延时执行函数
|
|
18
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
17
19
|
* @example
|
|
18
20
|
* libJsPromiseTimeout(3000, () => {
|
|
19
21
|
* console.log("执行延时函数");
|
|
@@ -27,6 +29,7 @@ export declare const Browser: {
|
|
|
27
29
|
* @param title 标题
|
|
28
30
|
* @param color 颜色
|
|
29
31
|
* @param logs 信息
|
|
32
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
30
33
|
* @example
|
|
31
34
|
* //使用红色打印日志
|
|
32
35
|
* libJsColorConsole("错误提示", "red", [{ label: "错误代码", value: 500 }]);
|
|
@@ -39,18 +42,21 @@ export declare const Browser: {
|
|
|
39
42
|
value: any;
|
|
40
43
|
}[] | any) => void;
|
|
41
44
|
/** @description 判断是否为移动设备
|
|
45
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
42
46
|
* @example
|
|
43
47
|
* const isMobile = libJsIsMobile();
|
|
44
48
|
* console.log(isMobile); //true 或 false
|
|
45
49
|
*/
|
|
46
50
|
libJsIsMobile: () => boolean;
|
|
47
51
|
/** @description 判断是否为平板
|
|
52
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
48
53
|
* @example
|
|
49
54
|
* const isPad = libJsIsPad();
|
|
50
55
|
* console.log(isPad); //true 或 false
|
|
51
56
|
*/
|
|
52
57
|
libJsIsPad: () => boolean;
|
|
53
58
|
/** @description 获取浏览器地址栏参数
|
|
59
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
54
60
|
* @example
|
|
55
61
|
* const params = libJsPathParams();
|
|
56
62
|
* console.log(params); //{ param1: "value1", param2: "value2" }
|
|
@@ -59,6 +65,7 @@ export declare const Browser: {
|
|
|
59
65
|
/** @description 动态设置网站标题及图标
|
|
60
66
|
* @param title 网站标题
|
|
61
67
|
* @param url 网站图标地址
|
|
68
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
62
69
|
* @example
|
|
63
70
|
* libJsSetTitleIcon("我的网站", "https://example.com/favicon.ico");
|
|
64
71
|
*/
|
|
@@ -66,12 +73,14 @@ export declare const Browser: {
|
|
|
66
73
|
/** @description 网站标题交互,当从当前网页切换到其他网页,网站标题自动切换
|
|
67
74
|
* @param backTitle 从其他网页返回时显示的标题
|
|
68
75
|
* @param leaveTitle 从当前网页离开时显示的标题
|
|
69
|
-
* * @
|
|
76
|
+
* * @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
77
|
+
* @example
|
|
70
78
|
* libJsTagTitleTip("欢迎回来", "来和妲己玩耍吧!");
|
|
71
79
|
*/
|
|
72
80
|
libJsTagTitleTip: (backTitle: string, leaveTitle: string) => void;
|
|
73
81
|
/** @description 对象转为url参数
|
|
74
82
|
* @param params 对象参数
|
|
83
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
75
84
|
* @example
|
|
76
85
|
* libJsObjToUrlParams({ name: "John", age: 30, active: true });
|
|
77
86
|
* // "name=John&age=30&active=true"
|
|
@@ -84,12 +93,14 @@ export declare const Data: {
|
|
|
84
93
|
* @description 将数组拆分成指定数组元素数量的多个数组
|
|
85
94
|
* @param arr 需要拆分的数组
|
|
86
95
|
* @param chunkSize 每个数组的元素数量
|
|
96
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
87
97
|
* @example
|
|
88
98
|
* const chunks = libJsChunkArray([1, 2, 3, 4, 5, 6], 2);
|
|
89
99
|
* console.log(chunks); //[[1, 2], [3, 4], [5, 6]]
|
|
90
100
|
*/
|
|
91
101
|
libJsChunkArray: <T>(arr: T[], chunkSize: number) => T[][];
|
|
92
102
|
/** @description 递归将JSON字符串深度解析为对象
|
|
103
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
93
104
|
* @example
|
|
94
105
|
* const obj = libJsDeepJSONParse('{"a": 1, "b": "{\"c\": 2}"}');
|
|
95
106
|
* console.log(obj); //{ a: 1, b: { c: 2 } }
|
|
@@ -100,6 +111,7 @@ export declare const Data: {
|
|
|
100
111
|
* @param arr 要分组的数组
|
|
101
112
|
* @param key 分组的键
|
|
102
113
|
* @returns 分组后的对象
|
|
114
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
103
115
|
* @example
|
|
104
116
|
* const grouped = libJsGroupArrayByKey([{ id: 1, name: 'A' }, { id: 2, name: 'B' }, { id: 1, name: 'C' }], 'id');
|
|
105
117
|
* console.log(grouped); //{ 1: [{ id: 1, name: 'A' }, { id: 1, name: 'C' }], 2: [{ id: 2, name: 'B' }] }
|
|
@@ -110,6 +122,7 @@ export declare const Data: {
|
|
|
110
122
|
* @param str 要匹配的字符串
|
|
111
123
|
* @param emailList 电子邮件后缀列表
|
|
112
124
|
* @returns 匹配结果数组
|
|
125
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
113
126
|
* @example
|
|
114
127
|
* const emails = libJsMatchEmail("user", ["@gmail.com", "@yahoo.com"]);
|
|
115
128
|
* console.log(emails); //["user@gmail.com", "user@yahoo.com"]
|
|
@@ -117,6 +130,7 @@ export declare const Data: {
|
|
|
117
130
|
libJsMatchEmail: (str: string, emailList: string[]) => string[];
|
|
118
131
|
/** @description 数组乱序
|
|
119
132
|
* @param arr 需要乱序的数组
|
|
133
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
120
134
|
* @example
|
|
121
135
|
* const shuffled = libJsShuffleArray([1, 2, 3, 4, 5]);
|
|
122
136
|
* console.log(shuffled); //[3, 5, 2, 1, 4] (结果每次不同)
|
|
@@ -125,6 +139,7 @@ export declare const Data: {
|
|
|
125
139
|
/** @description 数组元素整体步数移动
|
|
126
140
|
* @param arr 移动的数组
|
|
127
141
|
* @param step 负数为向后移动,正数为向前移动
|
|
142
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
128
143
|
* @example
|
|
129
144
|
* const moved = libJsStepArray([1, 2, 3, 4, 5], 2);
|
|
130
145
|
* console.log(moved); //[4, 5, 1, 2, 3]
|
|
@@ -133,6 +148,7 @@ export declare const Data: {
|
|
|
133
148
|
/** @description 翻转指定索引后面的数组
|
|
134
149
|
* @param arr 数组
|
|
135
150
|
* @param index 开始索引
|
|
151
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
136
152
|
* @example
|
|
137
153
|
* libReverseArrayFromIndex([1, 2, 3, 4, 5], 1);
|
|
138
154
|
* // [1, 2, 5, 4, 3]
|
|
@@ -144,12 +160,14 @@ export declare const File: {
|
|
|
144
160
|
/** @description 下载图片链接
|
|
145
161
|
* @param link 图片链接
|
|
146
162
|
* @param name 图片名称
|
|
163
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
147
164
|
* @example
|
|
148
165
|
* libJsDownloadImageLink("https://example.com/image.jpg", "downloaded-image.jpg");
|
|
149
166
|
*/
|
|
150
167
|
libJsDownloadImageLink: (link: string, name: string) => void;
|
|
151
168
|
/** @description 图片压缩
|
|
152
169
|
* @param obj 压缩参数
|
|
170
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
153
171
|
* @example
|
|
154
172
|
* //图片压缩使用示例
|
|
155
173
|
* libJsImageOptimizerOptionsParams({
|
|
@@ -170,6 +188,7 @@ export declare const File: {
|
|
|
170
188
|
* @description 保存文件到本地
|
|
171
189
|
* @param data 要保存的数据
|
|
172
190
|
* @param name 文件名
|
|
191
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
173
192
|
* @example
|
|
174
193
|
* libJsSaveJson("example.json", JSON.stringify({ key: "value" }));
|
|
175
194
|
*/
|
|
@@ -181,6 +200,7 @@ export declare const Formatter: {
|
|
|
181
200
|
* @description 格式化字节大小
|
|
182
201
|
* @param bytes 字节数
|
|
183
202
|
* @returns ['大小', '单位', '大小及单位']
|
|
203
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
184
204
|
* @example
|
|
185
205
|
* const [size, unit, formatted] = libJsFormatterByte(2048);
|
|
186
206
|
* console.log(size, unit, formatted); //2.00 KB 2.00 KB
|
|
@@ -189,6 +209,7 @@ export declare const Formatter: {
|
|
|
189
209
|
/**
|
|
190
210
|
* @description 隐藏手机号码中间的四位数字
|
|
191
211
|
* @param mobile 需要处理的手机号码
|
|
212
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
192
213
|
* @example
|
|
193
214
|
* const masked = libJsMaskPhoneNumber("13812345678");
|
|
194
215
|
* console.log(masked); //138****5678
|
|
@@ -198,6 +219,7 @@ export declare const Formatter: {
|
|
|
198
219
|
* @description 数字每三位添加逗号
|
|
199
220
|
* @param num 需要格式化的数字
|
|
200
221
|
* @param reserve 保留小数位数
|
|
222
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
201
223
|
* @example
|
|
202
224
|
* const formatted = libJsNumComma(1234567.89);
|
|
203
225
|
* console.log(formatted); //1,234,567.89
|
|
@@ -207,6 +229,7 @@ export declare const Formatter: {
|
|
|
207
229
|
* @param num 数字
|
|
208
230
|
* @param units 单位组,key为单位,value为格式化阈值
|
|
209
231
|
* @returns [数字, 单位]
|
|
232
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
210
233
|
* @example
|
|
211
234
|
* const [value, unit] = libJsNumberUnit(1500, { K: 1000, M: 1000000 });
|
|
212
235
|
* console.log(value, unit); //1.50 K
|
|
@@ -216,6 +239,7 @@ export declare const Formatter: {
|
|
|
216
239
|
* @description 将秒数格式化为中文时间描述,支持扩展到年和月
|
|
217
240
|
* @param seconds 秒数
|
|
218
241
|
* @returns 格式化后的中文时间
|
|
242
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
219
243
|
* @example
|
|
220
244
|
* libJsSecondsFormatterChinese(100000); //"1天3小时46分40秒"
|
|
221
245
|
* libJsSecondsFormatterChinese(31536000); //"1年"
|
|
@@ -231,6 +255,7 @@ export declare const Math: {
|
|
|
231
255
|
* @param point 小数点精度
|
|
232
256
|
* @returns 计算结果
|
|
233
257
|
*
|
|
258
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
234
259
|
* @example
|
|
235
260
|
* const result = libJsCalculateExpression("(1+2)-(3*4)/5");
|
|
236
261
|
* console.log(result); //0.6
|
|
@@ -240,6 +265,7 @@ export declare const Math: {
|
|
|
240
265
|
* @description 角度和弧度互相转换
|
|
241
266
|
* @param value 角度值或弧度值
|
|
242
267
|
* @param type 角度类型或弧度类型
|
|
268
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
243
269
|
* @example
|
|
244
270
|
* //角度转弧度
|
|
245
271
|
* libJsConvertAngle(90, "rad"); //返回 1.5708... (π/2)
|
|
@@ -251,6 +277,7 @@ export declare const Math: {
|
|
|
251
277
|
/** @description 计算两点角度
|
|
252
278
|
* @param coord1 起点坐标
|
|
253
279
|
* @param coord2 终点坐标
|
|
280
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
254
281
|
* @example
|
|
255
282
|
* libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 0 }); //0
|
|
256
283
|
* libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 1 }); //45
|
|
@@ -266,6 +293,7 @@ export declare const Math: {
|
|
|
266
293
|
/** @description 计算两点距离
|
|
267
294
|
* @param coord1 起点坐标
|
|
268
295
|
* @param coord2 终点坐标
|
|
296
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
269
297
|
* @example
|
|
270
298
|
* libJsCoordsDistance({ x: 0, y: 0 }, { x: 3, y: 4 }); //5
|
|
271
299
|
* libJsCoordsDistance({ x: 1, y: 1 }, { x: 4, y: 5 }); //5
|
|
@@ -282,6 +310,7 @@ export declare const Math: {
|
|
|
282
310
|
* @param num1 第一个数
|
|
283
311
|
* @param num2 第二个数
|
|
284
312
|
* @param operator 运算符,支持加减乘除
|
|
313
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
285
314
|
* @example
|
|
286
315
|
* libJsDecimal(10, 3, "+"); //13
|
|
287
316
|
* libJsDecimal(10, 3, "-"); //7
|
|
@@ -296,6 +325,7 @@ export declare const Misc: {
|
|
|
296
325
|
* @param form 表单数据对象
|
|
297
326
|
* @param rules 验证规则数组
|
|
298
327
|
* @returns 验证结果数组,包含未通过验证的项
|
|
328
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
299
329
|
* @example
|
|
300
330
|
* const form = { username: "john", email: "john@example.com" };
|
|
301
331
|
* const rules = [
|
|
@@ -323,6 +353,7 @@ export declare const Misc: {
|
|
|
323
353
|
* @param maxRetries 最大重试次数
|
|
324
354
|
* @param retryDelay 重试间隔时间
|
|
325
355
|
* @param params 请求参数
|
|
356
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
326
357
|
* @example
|
|
327
358
|
* const requestFn = (params: { url: string }) => fetch(params.url).then(res => res.json());
|
|
328
359
|
* const params = { url: "https://api.example.com/data" };
|
|
@@ -343,6 +374,7 @@ export declare const Misc: {
|
|
|
343
374
|
onRetry?: () => void;
|
|
344
375
|
}) => Promise<T>;
|
|
345
376
|
/** @description 数字步进器
|
|
377
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
346
378
|
* @example
|
|
347
379
|
* const stepper = new libNumerStepper(10, (index) => console.log(index));
|
|
348
380
|
* stepper.down("add"); // 索引加1
|
|
@@ -355,6 +387,7 @@ export declare const Misc: {
|
|
|
355
387
|
export declare const Random: {
|
|
356
388
|
/** @description 百分比概率结果
|
|
357
389
|
* @param probability 触发概率,百分比,0-100
|
|
390
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
358
391
|
* @example
|
|
359
392
|
* libJsProbabilityResult(50); //50% 概率为 true
|
|
360
393
|
* libJsProbabilityResult(80); //80% 概率为 true
|
|
@@ -365,6 +398,7 @@ export declare const Random: {
|
|
|
365
398
|
* @param min 最小值
|
|
366
399
|
* @param max 最大值
|
|
367
400
|
* @param num 保留小数位数
|
|
401
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
368
402
|
* @example
|
|
369
403
|
* libJsRandom(1, 10); //1 到 10 之间的随机整数
|
|
370
404
|
* libJsRandom(1, 10, 2); //1 到 10 之间保留两位小数的随机数
|
|
@@ -373,6 +407,7 @@ export declare const Random: {
|
|
|
373
407
|
libJsRandom: (min: number, max: number, num?: number) => number;
|
|
374
408
|
/** @description 随机 RGBA 颜色
|
|
375
409
|
* @param alpha 透明度
|
|
410
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
376
411
|
* @example
|
|
377
412
|
* libJsRandomColor(); //生成随机的 RGBA 颜色,默认透明度 1
|
|
378
413
|
* libJsRandomColor(0.5); //生成随机的 RGBA 颜色,透明度为 0.5
|
|
@@ -382,6 +417,7 @@ export declare const Random: {
|
|
|
382
417
|
* @param min 最小值
|
|
383
418
|
* @param max 最大值
|
|
384
419
|
* @param count 数组长度
|
|
420
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
385
421
|
* @example
|
|
386
422
|
* libJsUniqueRandomNumbers(1, 10, 5); //从 1 到 10 中随机生成 5 个唯一数字
|
|
387
423
|
* libJsUniqueRandomNumbers(1, 100, 10); //从 1 到 100 中随机生成 10 个唯一数字
|
|
@@ -399,6 +435,7 @@ export declare const Time: {
|
|
|
399
435
|
libJsSameTimeCheck: (timestamp: number, unit: import("dayjs").OpUnitType) => 0 | 1 | -1;
|
|
400
436
|
/** @description 时间差计算
|
|
401
437
|
* @param timestamp 毫秒时间戳
|
|
438
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
402
439
|
* @example
|
|
403
440
|
* libJsTimeAgotamp(Date.now() - 3600000); //"1 小时前"
|
|
404
441
|
* libJsTimeAgotamp(Date.now() - 86400000); //"1 天前"
|
|
@@ -409,6 +446,7 @@ export declare const Time: {
|
|
|
409
446
|
/**
|
|
410
447
|
* @description 根据当前时间返回问候语
|
|
411
448
|
* @param greet 自定义问候语对象
|
|
449
|
+
* @link 了解更多:https://www.npmjs.com/package/lyb-js
|
|
412
450
|
* @example
|
|
413
451
|
* libJsTimeGreeting(); //根据当前时间返回默认问候语
|
|
414
452
|
* libJsTimeGreeting({ morning: "早安" }); //自定义早上问候语
|