lyb-js 1.1.5 → 1.1.7

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.
Files changed (83) hide show
  1. package/README.md +110 -47
  2. package/dist/Base/LibJsGetDataType/index.d.ts +1 -5
  3. package/dist/Base/LibJsGetDataType/index.js +2 -6
  4. package/dist/Base/LibJsPromiseTimeout/index.d.ts +1 -5
  5. package/dist/Base/LibJsPromiseTimeout/index.js +12 -15
  6. package/dist/Browser/LibJsColorConsole/index.d.ts +1 -7
  7. package/dist/Browser/LibJsColorConsole/index.js +23 -19
  8. package/dist/Browser/LibJsIsMobile/index.d.ts +1 -4
  9. package/dist/Browser/LibJsIsMobile/index.js +3 -6
  10. package/dist/Browser/LibJsIsPad/index.d.ts +1 -4
  11. package/dist/Browser/LibJsIsPad/index.js +9 -12
  12. package/dist/Browser/LibJsObjToUrlParams/index.d.ts +1 -4
  13. package/dist/Browser/LibJsObjToUrlParams/index.js +6 -6
  14. package/dist/Browser/LibJsPathParams/index.d.ts +1 -4
  15. package/dist/Browser/LibJsPathParams/index.js +6 -9
  16. package/dist/Browser/LibJsSetTitleIcon/index.d.ts +1 -3
  17. package/dist/Browser/LibJsSetTitleIcon/index.js +4 -6
  18. package/dist/Browser/LibJsTagTitleTip/index.d.ts +1 -3
  19. package/dist/Browser/LibJsTagTitleTip/index.js +6 -8
  20. package/dist/Data/LibJsChunkArray/index.d.ts +1 -4
  21. package/dist/Data/LibJsChunkArray/index.js +4 -7
  22. package/dist/Data/LibJsDeepJSONParse/index.d.ts +1 -4
  23. package/dist/Data/LibJsDeepJSONParse/index.js +6 -9
  24. package/dist/Data/LibJsGroupArrayByKey/index.d.ts +1 -4
  25. package/dist/Data/LibJsGroupArrayByKey/index.js +4 -6
  26. package/dist/Data/LibJsMatchEmail/index.d.ts +1 -4
  27. package/dist/Data/LibJsMatchEmail/index.js +5 -8
  28. package/dist/Data/LibJsShuffleArray/index.d.ts +1 -4
  29. package/dist/Data/LibJsShuffleArray/index.js +16 -9
  30. package/dist/Data/LibJsStepArray/index.d.ts +1 -4
  31. package/dist/Data/LibJsStepArray/index.js +4 -7
  32. package/dist/Data/LibReverseArrayFromIndex/index.d.ts +1 -4
  33. package/dist/Data/LibReverseArrayFromIndex/index.js +13 -7
  34. package/dist/File/LibJsDownloadImageLink/index.d.ts +1 -3
  35. package/dist/File/LibJsDownloadImageLink/index.js +6 -8
  36. package/dist/File/LibJsImageOptimizer/index.d.ts +1 -14
  37. package/dist/File/LibJsImageOptimizer/index.js +37 -50
  38. package/dist/File/LibJsSaveJson/index.d.ts +1 -4
  39. package/dist/File/LibJsSaveJson/index.js +5 -8
  40. package/dist/Formatter/LibJsFormatterByte/index.d.ts +1 -4
  41. package/dist/Formatter/LibJsFormatterByte/index.js +7 -10
  42. package/dist/Formatter/LibJsMaskPhoneNumber/index.d.ts +1 -4
  43. package/dist/Formatter/LibJsMaskPhoneNumber/index.js +3 -6
  44. package/dist/Formatter/LibJsNumComma/index.d.ts +1 -4
  45. package/dist/Formatter/LibJsNumComma/index.js +5 -7
  46. package/dist/Formatter/LibJsNumberUnit/index.d.ts +6 -9
  47. package/dist/Formatter/LibJsNumberUnit/index.js +18 -14
  48. package/dist/Formatter/LibJsSecondsFormatterChinese/index.d.ts +1 -6
  49. package/dist/Formatter/LibJsSecondsFormatterChinese/index.js +16 -21
  50. package/dist/Math/LibJsCalculateExpression/index.d.ts +1 -4
  51. package/dist/Math/LibJsCalculateExpression/index.js +33 -32
  52. package/dist/Math/LibJsConvertAngle/index.d.ts +1 -7
  53. package/dist/Math/LibJsConvertAngle/index.js +2 -8
  54. package/dist/Math/LibJsCoordsAngle/index.d.ts +1 -5
  55. package/dist/Math/LibJsCoordsAngle/index.js +6 -10
  56. package/dist/Math/LibJsCoordsDistance/index.d.ts +1 -5
  57. package/dist/Math/LibJsCoordsDistance/index.js +5 -9
  58. package/dist/Math/LibJsDecimal/index.d.ts +1 -5
  59. package/dist/Math/LibJsDecimal/index.js +9 -12
  60. package/dist/Misc/LibJsRegFormValidate/index.d.ts +1 -16
  61. package/dist/Misc/LibJsRegFormValidate/index.js +7 -22
  62. package/dist/Misc/LibJsRetryRequest/index.d.ts +1 -12
  63. package/dist/Misc/LibJsRetryRequest/index.js +8 -18
  64. package/dist/Misc/LibNumerStepper/index.d.ts +1 -6
  65. package/dist/Misc/LibNumerStepper/index.js +28 -35
  66. package/dist/Random/LibJsProbabilityResult/index.d.ts +1 -5
  67. package/dist/Random/LibJsProbabilityResult/index.js +4 -6
  68. package/dist/Random/LibJsRandom/index.d.ts +1 -4
  69. package/dist/Random/LibJsRandom/index.js +3 -5
  70. package/dist/Random/LibJsRandomColor/index.d.ts +1 -4
  71. package/dist/Random/LibJsRandomColor/index.js +7 -9
  72. package/dist/Random/LibJsUniqueRandomNumbers/index.d.ts +1 -4
  73. package/dist/Random/LibJsUniqueRandomNumbers/index.js +7 -9
  74. package/dist/Time/LibJsSameTimeCheck/index.d.ts +1 -5
  75. package/dist/Time/LibJsSameTimeCheck/index.js +4 -8
  76. package/dist/Time/LibJsTimeAgo/index.d.ts +1 -6
  77. package/dist/Time/LibJsTimeAgo/index.js +9 -13
  78. package/dist/Time/LibJsTimeGreeting/index.d.ts +1 -5
  79. package/dist/Time/LibJsTimeGreeting/index.js +5 -8
  80. package/dist/libJs.d.ts +42 -201
  81. package/dist/libJs.js +95 -256
  82. package/package.json +1 -1
  83. package/umd/lyb.js +3 -3
package/dist/libJs.js CHANGED
@@ -38,431 +38,270 @@ import { libJsTimeAgo } from "./Time/LibJsTimeAgo";
38
38
  import { libJsTimeGreeting } from "./Time/LibJsTimeGreeting";
39
39
  import { libNumerStepper } from "./Misc/LibNumerStepper";
40
40
  /** @description 基础方法 */
41
- export const Base = {
41
+ export var Base = {
42
42
  /**
43
43
  * @description 返回数据类型
44
44
  * @param v 需要判断类型的数据
45
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
46
- * @example
47
- * libJsGetDataType(123); //"number"
48
- * libJsGetDataType("hello"); //"string"
49
- * libJsGetDataType([1, 2, 3]); //"array"
45
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
50
46
  */
51
- libJsGetDataType,
47
+ libJsGetDataType: libJsGetDataType,
52
48
  /**
53
49
  * @description 延时执行,切换到其他页面会暂停
54
50
  * @param delay 延时毫秒数
55
51
  * @param fn 延时执行函数
56
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
57
- * @example
58
- * libJsPromiseTimeout(3000, () => {
59
- * console.log("执行延时函数");
60
- * });
52
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPromiseTimeout-延时执行
61
53
  */
62
- libJsPromiseTimeout,
54
+ libJsPromiseTimeout: libJsPromiseTimeout,
63
55
  };
64
56
  /** @description 浏览器相关方法 */
65
- export const Browser = {
57
+ export var Browser = {
66
58
  /** @description console颜色打印
67
59
  * @param title 标题
68
60
  * @param color 颜色
69
61
  * @param logs 信息
70
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
71
- * @example
72
- * //使用红色打印日志
73
- * libJsColorConsole("错误提示", "red", [{ label: "错误代码", value: 500 }]);
74
- *
75
- * //使用蓝色打印简单日志
76
- * libJsColorConsole("信息", "blue", "操作成功");
77
- */
78
- libJsColorConsole,
62
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
63
+ */
64
+ libJsColorConsole: libJsColorConsole,
79
65
  /** @description 判断是否为移动设备
80
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
81
- * @example
82
- * const isMobile = libJsIsMobile();
83
- * console.log(isMobile); //true 或 false
66
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsMobile-判断手机
84
67
  */
85
- libJsIsMobile,
68
+ libJsIsMobile: libJsIsMobile,
86
69
  /** @description 判断是否为平板
87
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
88
- * @example
89
- * const isPad = libJsIsPad();
90
- * console.log(isPad); //true 或 false
70
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsPad-判断平板
91
71
  */
92
- libJsIsPad,
72
+ libJsIsPad: libJsIsPad,
93
73
  /** @description 获取浏览器地址栏参数
94
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
95
- * @example
96
- * const params = libJsPathParams();
97
- * console.log(params); //{ param1: "value1", param2: "value2" }
74
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPathParams-地址栏参数
98
75
  */
99
- libJsPathParams,
76
+ libJsPathParams: libJsPathParams,
100
77
  /** @description 动态设置网站标题及图标
101
78
  * @param title 网站标题
102
79
  * @param url 网站图标地址
103
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
104
- * @example
105
- * libJsSetTitleIcon("我的网站", "https://example.com/favicon.ico");
80
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSetTitleIcon-网站标题图标
106
81
  */
107
- libJsSetTitleIcon,
82
+ libJsSetTitleIcon: libJsSetTitleIcon,
108
83
  /** @description 网站标题交互,当从当前网页切换到其他网页,网站标题自动切换
109
84
  * @param backTitle 从其他网页返回时显示的标题
110
85
  * @param leaveTitle 从当前网页离开时显示的标题
111
- * * @link 了解更多:https://www.npmjs.com/package/lyb-js
112
- * @example
113
- * libJsTagTitleTip("欢迎回来", "来和妲己玩耍吧!");
86
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTagTitleTip-网站标题交互
114
87
  */
115
- libJsTagTitleTip,
88
+ libJsTagTitleTip: libJsTagTitleTip,
116
89
  /** @description 对象转为url参数
117
90
  * @param params 对象参数
118
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
119
- * @example
120
- * libJsObjToUrlParams({ name: "John", age: 30, active: true });
121
- * // "name=John&age=30&active=true"
91
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsObjToUrlParams-对象转Url参数
122
92
  */
123
- libJsObjToUrlParams,
93
+ libJsObjToUrlParams: libJsObjToUrlParams,
124
94
  };
125
95
  /** @description 数据相关方法 */
126
- export const Data = {
96
+ export var Data = {
127
97
  /**
128
98
  * @description 将数组拆分成指定数组元素数量的多个数组
129
99
  * @param arr 需要拆分的数组
130
100
  * @param chunkSize 每个数组的元素数量
131
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
132
- * @example
133
- * const chunks = libJsChunkArray([1, 2, 3, 4, 5, 6], 2);
134
- * console.log(chunks); //[[1, 2], [3, 4], [5, 6]]
101
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsChunkArray-数组拆分
135
102
  */
136
- libJsChunkArray,
103
+ libJsChunkArray: libJsChunkArray,
137
104
  /** @description 递归将JSON字符串深度解析为对象
138
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
139
- * @example
140
- * const obj = libJsDeepJSONParse('{"a": 1, "b": "{\"c\": 2}"}');
141
- * console.log(obj); //{ a: 1, b: { c: 2 } }
105
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDeepJSONParse-深度解析JSON
142
106
  */
143
- libJsDeepJSONParse,
107
+ libJsDeepJSONParse: libJsDeepJSONParse,
144
108
  /**
145
109
  * @description 分类汇总,将数组对象按照指定键值整理成一个以键值为键名的对象
146
110
  * @param arr 要分组的数组
147
111
  * @param key 分组的键
148
112
  * @returns 分组后的对象
149
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
150
- * @example
151
- * const grouped = libJsGroupArrayByKey([{ id: 1, name: 'A' }, { id: 2, name: 'B' }, { id: 1, name: 'C' }], 'id');
152
- * console.log(grouped); //{ 1: [{ id: 1, name: 'A' }, { id: 1, name: 'C' }], 2: [{ id: 2, name: 'B' }] }
113
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsGroupArrayByKey-分类汇总
153
114
  */
154
- libJsGroupArrayByKey,
115
+ libJsGroupArrayByKey: libJsGroupArrayByKey,
155
116
  /**
156
117
  * @description 匹配电子邮件,可用于实时输入时,自动补全常用邮箱后缀
157
118
  * @param str 要匹配的字符串
158
119
  * @param emailList 电子邮件后缀列表
159
120
  * @returns 匹配结果数组
160
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
161
- * @example
162
- * const emails = libJsMatchEmail("user", ["@gmail.com", "@yahoo.com"]);
163
- * console.log(emails); //["user@gmail.com", "user@yahoo.com"]
121
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMatchEmail-匹配E-Mail
164
122
  */
165
- libJsMatchEmail,
123
+ libJsMatchEmail: libJsMatchEmail,
166
124
  /** @description 数组乱序
167
125
  * @param arr 需要乱序的数组
168
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
169
- * @example
170
- * const shuffled = libJsShuffleArray([1, 2, 3, 4, 5]);
171
- * console.log(shuffled); //[3, 5, 2, 1, 4] (结果每次不同)
126
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsShuffleArray-数组乱序
172
127
  */
173
- libJsShuffleArray,
128
+ libJsShuffleArray: libJsShuffleArray,
174
129
  /** @description 数组元素整体步数移动
175
130
  * @param arr 移动的数组
176
131
  * @param step 负数为向后移动,正数为向前移动
177
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
178
- * @example
179
- * const moved = libJsStepArray([1, 2, 3, 4, 5], 2);
180
- * console.log(moved); //[4, 5, 1, 2, 3]
132
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsStepArray-数组偏移
181
133
  */
182
- libJsStepArray,
134
+ libJsStepArray: libJsStepArray,
183
135
  /** @description 翻转指定索引后面的数组
184
136
  * @param arr 数组
185
137
  * @param index 开始索引
186
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
187
- * @example
188
- * libReverseArrayFromIndex([1, 2, 3, 4, 5], 1);
189
- * // [1, 2, 5, 4, 3]
138
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibReverseArrayFromIndex-数组定位翻转
190
139
  */
191
- libReverseArrayFromIndex,
140
+ libReverseArrayFromIndex: libReverseArrayFromIndex,
192
141
  };
193
142
  /** @description 文件相关方法 */
194
- export const File = {
143
+ export var File = {
195
144
  /** @description 下载图片链接
196
145
  * @param link 图片链接
197
146
  * @param name 图片名称
198
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
199
- * @example
200
- * libJsDownloadImageLink("https://example.com/image.jpg", "downloaded-image.jpg");
147
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDownloadImageLink-图片下载
201
148
  */
202
- libJsDownloadImageLink,
149
+ libJsDownloadImageLink: libJsDownloadImageLink,
203
150
  /** @description 图片压缩
204
151
  * @param obj 压缩参数
205
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
206
- * @example
207
- * //图片压缩使用示例
208
- * libJsImageOptimizerOptionsParams({
209
- * file: myFile,
210
- * ratio: 0.8,
211
- * width: 800,
212
- * maxSize: 1024,
213
- * success: (data, file, url) => {
214
- * console.log('压缩成功', data, file, url);
215
- * },
216
- * fail: (error) => {
217
- * console.error('压缩失败', error);
218
- * }
219
- * });
220
- */
221
- libJsImageOptimizer,
152
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsImageOptimizer-图片压缩
153
+ */
154
+ libJsImageOptimizer: libJsImageOptimizer,
222
155
  /**
223
156
  * @description 保存文件到本地
224
157
  * @param data 要保存的数据
225
158
  * @param name 文件名
226
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
227
- * @example
228
- * libJsSaveJson("example.json", JSON.stringify({ key: "value" }));
159
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSaveJson-保存文件
229
160
  */
230
- libJsSaveJson,
161
+ libJsSaveJson: libJsSaveJson,
231
162
  };
232
163
  /** @description 格式化相关方法 */
233
- export const Formatter = {
164
+ export var Formatter = {
234
165
  /**
235
166
  * @description 格式化字节大小
236
167
  * @param bytes 字节数
237
168
  * @returns ['大小', '单位', '大小及单位']
238
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
239
- * @example
240
- * const [size, unit, formatted] = libJsFormatterByte(2048);
241
- * console.log(size, unit, formatted); //2.00 KB 2.00 KB
169
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsFormatterByte-字节格式化
242
170
  */
243
- libJsFormatterByte,
171
+ libJsFormatterByte: libJsFormatterByte,
244
172
  /**
245
173
  * @description 隐藏手机号码中间的四位数字
246
174
  * @param mobile 需要处理的手机号码
247
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
248
- * @example
249
- * const masked = libJsMaskPhoneNumber("13812345678");
250
- * console.log(masked); //138****5678
175
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMaskPhoneNumber-隐藏手机号码
251
176
  */
252
- libJsMaskPhoneNumber,
177
+ libJsMaskPhoneNumber: libJsMaskPhoneNumber,
253
178
  /**
254
179
  * @description 数字每三位添加逗号
255
180
  * @param num 需要格式化的数字
256
181
  * @param reserve 保留小数位数
257
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
258
- * @example
259
- * const formatted = libJsNumComma(1234567.89);
260
- * console.log(formatted); //1,234,567.89
182
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumComma-数字逗号
261
183
  */
262
- libJsNumComma,
184
+ libJsNumComma: libJsNumComma,
263
185
  /** @description 将大于1000的数字使用k为单位
264
186
  * @param num 数字
265
187
  * @param units 单位组,key为单位,value为格式化阈值
266
188
  * @returns [数字, 单位]
267
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
268
- * @example
269
- * const [value, unit] = libJsNumberUnit(1500, { K: 1000, M: 1000000 });
270
- * console.log(value, unit); //1.50 K
189
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumberUnit-数字单位
271
190
  */
272
- libJsNumberUnit,
191
+ libJsNumberUnit: libJsNumberUnit,
273
192
  /**
274
193
  * @description 将秒数格式化为中文时间描述,支持扩展到年和月
275
194
  * @param seconds 秒数
276
195
  * @returns 格式化后的中文时间
277
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
278
- * @example
279
- * libJsSecondsFormatterChinese(100000); //"1天3小时46分40秒"
280
- * libJsSecondsFormatterChinese(31536000); //"1年"
281
- * libJsSecondsFormatterChinese(3600); //"1小时"
282
- * libJsSecondsFormatterChinese(90); //"1分30秒"
283
- */
284
- libJsSecondsFormatterChinese,
196
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSecondsFormatterChinese-中文时间
197
+ */
198
+ libJsSecondsFormatterChinese: libJsSecondsFormatterChinese,
285
199
  };
286
200
  /** @description 数学相关方法 */
287
- export const Math = {
201
+ export var Math = {
288
202
  /** @description 计算表达式字符串
289
203
  * @param expression 表达式字符串
290
204
  * @param point 小数点精度
291
205
  * @returns 计算结果
292
- *
293
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
294
- * @example
295
- * const result = libJsCalculateExpression("(1+2)-(3*4)/5");
296
- * console.log(result); //0.6
206
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCalculateExpression-表达式字符串
297
207
  */
298
- libJsCalculateExpression,
208
+ libJsCalculateExpression: libJsCalculateExpression,
299
209
  /**
300
210
  * @description 角度和弧度互相转换
301
211
  * @param value 角度值或弧度值
302
212
  * @param type 角度类型或弧度类型
303
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
304
- * @example
305
- * //角度转弧度
306
- * libJsConvertAngle(90, "rad"); //返回 1.5708... (π/2)
307
- *
308
- * //弧度转角度
309
- * libJsConvertAngle(Math.PI, "deg"); //返回 180
310
- */
311
- libJsConvertAngle,
213
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsConvertAngle-角弧度互转
214
+ */
215
+ libJsConvertAngle: libJsConvertAngle,
312
216
  /** @description 计算两点角度
313
217
  * @param coord1 起点坐标
314
218
  * @param coord2 终点坐标
315
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
316
- * @example
317
- * libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 0 }); //0
318
- * libJsCoordsAngle({ x: 0, y: 0 }, { x: 1, y: 1 }); //45
319
- * libJsCoordsAngle({ x: 0, y: 0 }, { x: 0, y: 1 }); //90
219
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsAngle-两点角度
320
220
  */
321
- libJsCoordsAngle,
221
+ libJsCoordsAngle: libJsCoordsAngle,
322
222
  /** @description 计算两点距离
323
223
  * @param coord1 起点坐标
324
224
  * @param coord2 终点坐标
325
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
326
- * @example
327
- * libJsCoordsDistance({ x: 0, y: 0 }, { x: 3, y: 4 }); //5
328
- * libJsCoordsDistance({ x: 1, y: 1 }, { x: 4, y: 5 }); //5
329
- * libJsCoordsDistance({ x: 0, y: 0 }, { x: 0, y: 0 }); //0
225
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsDistance-两点距离
330
226
  */
331
- libJsCoordsDistance,
227
+ libJsCoordsDistance: libJsCoordsDistance,
332
228
  /** @description 计算两个数的运算结果,并保留指定位数的小数
333
229
  * @param num1 第一个数
334
230
  * @param num2 第二个数
335
231
  * @param operator 运算符,支持加减乘除
336
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
337
- * @example
338
- * libJsDecimal(10, 3, "+"); //13
339
- * libJsDecimal(10, 3, "-"); //7
340
- * libJsDecimal(10, 3, "/", 2); //3.33
232
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDecimal-高精度计算
341
233
  */
342
- libJsDecimal,
234
+ libJsDecimal: libJsDecimal,
343
235
  };
344
236
  /** @description 杂项相关方法 */
345
- export const Misc = {
237
+ export var Misc = {
346
238
  /**
347
239
  * @description 表单验证函数
348
240
  * @param form 表单数据对象
349
241
  * @param rules 验证规则数组
350
242
  * @returns 验证结果数组,包含未通过验证的项
351
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
352
- * @example
353
- * const form = { username: "john", email: "john@example.com" };
354
- * const rules = [
355
- * { key: "username", verify: /^[a-zA-Z0-9]{3,}$/, msg: "用户名不合法", name: "用户名" },
356
- * { key: "email", verify: /^\S+@\S+\.\S+$/, msg: "邮箱格式不正确", name: "邮箱" },
357
- * ];
358
- * libJsRegFormValidate(form, rules);
359
- * //返回结果: []
360
- *
361
- * const invalidForm = { username: "jo", email: "invalid-email" };
362
- * libJsRegFormValidate(invalidForm, rules);
363
- * //返回结果: [
364
- * // { key: "username", msg: "用户名不合法", name: "用户名" },
365
- * // { key: "email", msg: "邮箱格式不正确", name: "邮箱" }
366
- * //]
367
- */
368
- libJsRegFormValidate,
243
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRegFormValidate-表单验证
244
+ */
245
+ libJsRegFormValidate: libJsRegFormValidate,
369
246
  /** @description 请求失败重连
370
247
  * @param promiseFn 请求函数
371
248
  * @param maxRetries 最大重试次数
372
249
  * @param retryDelay 重试间隔时间
373
250
  * @param params 请求参数
374
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
375
- * @example
376
- * const requestFn = (params: { url: string }) => fetch(params.url).then(res => res.json());
377
- * const params = { url: "https://api.example.com/data" };
378
- * libJsRetryRequest({
379
- * promiseFn: requestFn,
380
- * params,
381
- * maxRetries: 5,
382
- * retryDelay: 1000
383
- * })
384
- * .then(data => console.log(data))
385
- * .catch(err => console.error(err));
386
- */
387
- libJsRetryRequest,
251
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRetryRequest-请求重连
252
+ */
253
+ libJsRetryRequest: libJsRetryRequest,
388
254
  /** @description 数字步进器
389
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
390
- * @example
391
- * const stepper = new libNumerStepper(10, (index) => console.log(index));
392
- * stepper.down("add"); // 索引加1
393
- * stepper.updateIndex(5); // 更新索引为5
394
- * stepper.down("sub"); // 索引减1
395
- */
396
- libNumerStepper,
255
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibNumerStepper-数字步进器
256
+ */
257
+ libNumerStepper: libNumerStepper,
397
258
  };
398
259
  /** @description 随机相关方法 */
399
- export const Random = {
260
+ export var Random = {
400
261
  /** @description 百分比概率结果
401
262
  * @param probability 触发概率,百分比,0-100
402
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
403
- * @example
404
- * libJsProbabilityResult(50); //50% 概率为 true
405
- * libJsProbabilityResult(80); //80% 概率为 true
406
- * libJsProbabilityResult(100); //100% 概率为 true
263
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsProbabilityResult-概率触发
407
264
  */
408
- libJsProbabilityResult,
265
+ libJsProbabilityResult: libJsProbabilityResult,
409
266
  /** @description 随机数
410
267
  * @param min 最小值
411
268
  * @param max 最大值
412
269
  * @param num 保留小数位数
413
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
414
- * @example
415
- * libJsRandom(1, 10); //1 到 10 之间的随机整数
416
- * libJsRandom(1, 10, 2); //1 到 10 之间保留两位小数的随机数
417
- * libJsRandom(5, 5, 3); //返回 5.000
270
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandom-随机数
418
271
  */
419
- libJsRandom,
272
+ libJsRandom: libJsRandom,
420
273
  /** @description 随机 RGBA 颜色
421
274
  * @param alpha 透明度
422
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
423
- * @example
424
- * libJsRandomColor(); //生成随机的 RGBA 颜色,默认透明度 1
425
- * libJsRandomColor(0.5); //生成随机的 RGBA 颜色,透明度为 0.5
275
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandomColor-随机色
426
276
  */
427
- libJsRandomColor,
277
+ libJsRandomColor: libJsRandomColor,
428
278
  /** @description 随机生成n个指定范围的随机数数组
429
279
  * @param min 最小值
430
280
  * @param max 最大值
431
281
  * @param count 数组长度
432
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
433
- * @example
434
- * libJsUniqueRandomNumbers(1, 10, 5); //从 1 到 10 中随机生成 5 个唯一数字
435
- * libJsUniqueRandomNumbers(1, 100, 10); //从 1 到 100 中随机生成 10 个唯一数字
282
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsUniqueRandomNumbers-随机数数组
436
283
  */
437
- libJsUniqueRandomNumbers,
284
+ libJsUniqueRandomNumbers: libJsUniqueRandomNumbers,
438
285
  };
439
286
  /** @description 时间相关方法 */
440
- export const Time = {
287
+ export var Time = {
441
288
  /**
442
289
  * @description 传入时间戳与当前时间判断是否为同一天或同一周
443
290
  * @param timestamp 毫秒时间戳
444
291
  * @param unit 判断单位
445
292
  * @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
293
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSameTimeCheck-时间比对
446
294
  */
447
- libJsSameTimeCheck,
295
+ libJsSameTimeCheck: libJsSameTimeCheck,
448
296
  /** @description 时间差计算
449
297
  * @param timestamp 毫秒时间戳
450
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
451
- * @example
452
- * libJsTimeAgotamp(Date.now() - 3600000); //"1 小时前"
453
- * libJsTimeAgotamp(Date.now() - 86400000); //"1 天前"
454
- * libJsTimeAgotamp(Date.now() - 31536000000); //"1 年前"
455
- * libJsTimeAgotamp(Date.now() - 10000); //"刚刚"
456
- */
457
- libJsTimeAgo,
298
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeAgo-中文时间差
299
+ */
300
+ libJsTimeAgo: libJsTimeAgo,
458
301
  /**
459
302
  * @description 根据当前时间返回问候语
460
303
  * @param greet 自定义问候语对象
461
- * @link 了解更多:https://www.npmjs.com/package/lyb-js
462
- * @example
463
- * libJsTimeGreeting(); //根据当前时间返回默认问候语
464
- * libJsTimeGreeting({ morning: "早安" }); //自定义早上问候语
465
- * libJsTimeGreeting({ afternoon: "午后好" }); //自定义下午问候语
304
+ * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeGreeting-时间问候
466
305
  */
467
- libJsTimeGreeting,
306
+ libJsTimeGreeting: libJsTimeGreeting,
468
307
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lyb-js",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "自用JS方法库",
5
5
  "license": "ISC",
6
6
  "type": "module",