lyb-js 1.6.16 → 1.6.18

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/libJs.js DELETED
@@ -1,353 +0,0 @@
1
- import { libJsGetDataType } from "./Base/LibJsGetDataType";
2
- import { libJsPromiseTimeout } from "./Base/LibJsPromiseTimeout";
3
- import { libJsColorConsole } from "./Browser/LibJsColorConsole";
4
- import { libJsIsMobile } from "./Browser/LibJsIsMobile";
5
- import { libJsIsPad } from "./Browser/LibJsIsPad";
6
- import { libJsPathParams } from "./Browser/LibJsPathParams";
7
- import { libJsSetTitleIcon } from "./Browser/LibJsSetTitleIcon";
8
- import { libJsTagTitleTip } from "./Browser/LibJsTagTitleTip";
9
- import { libJsObjToUrlParams } from "./Browser/LibJsObjToUrlParams";
10
- import { libJsChunkArray } from "./Data/LibJsChunkArray";
11
- import { libJsDeepJSONParse } from "./Data/LibJsDeepJSONParse";
12
- import { libJsGroupArrayByKey } from "./Data/LibJsGroupArrayByKey";
13
- import { libJsMatchEmail } from "./Data/LibJsMatchEmail";
14
- import { libJsShuffleArray } from "./Data/LibJsShuffleArray";
15
- import { libJsStepArray } from "./Data/LibJsStepArray";
16
- import { libReverseArrayFromIndex } from "./Data/LibReverseArrayFromIndex";
17
- import { libJsDownloadImageLink } from "./File/LibJsDownloadImageLink";
18
- import { libJsImageOptimizer } from "./File/LibJsImageOptimizer";
19
- import { libJsSaveJson } from "./File/LibJsSaveJson";
20
- import { libJsConvertAngle } from "./Math/LibJsConvertAngle";
21
- import { libJsCoordsAngle } from "./Math/LibJsCoordsAngle";
22
- import { libJsCoordsDistance } from "./Math/LibJsCoordsDistance";
23
- import { libJsDecimal } from "./Math/LibJsDecimal";
24
- import { libJsRegFormValidate } from "./Misc/LibJsRegFormValidate";
25
- import { libJsRetryRequest } from "./Misc/LibJsRetryRequest";
26
- import { libJsProbabilityResult } from "./Random/LibJsProbabilityResult";
27
- import { libJsRandom } from "./Random/LibJsRandom";
28
- import { libJsRandomColor } from "./Random/LibJsRandomColor";
29
- import { libJsUniqueRandomNumbers } from "./Random/LibJsUniqueRandomNumbers";
30
- import { libJsSameTimeCheck } from "./Time/LibJsSameTimeCheck";
31
- import { libJsTimeAgo } from "./Time/LibJsTimeAgo";
32
- import { libJsTimeGreeting } from "./Time/LibJsTimeGreeting";
33
- import { LibJsNumberStepper } from "./Misc/LibJsNumberStepper";
34
- import { libJsFormatterByte } from "./Formatter/LibJsFormatterByte";
35
- import { libJsMaskPhoneNumber } from "./Formatter/LibJsMaskPhoneNumber";
36
- import { libJsNumberUnit } from "./Formatter/LibJsNumberUnit";
37
- import { libJsNumComma } from "./Formatter/LibJsNumComma";
38
- import { libJsSecondsFormatterChinese } from "./Formatter/LibJsSecondsFormatterChinese";
39
- import { libJsCalculateExpression } from "./Math/LibJsCalculateExpression";
40
- import { LibJsEmitter } from "./Misc/LibJsEmitter";
41
- import { LibJsLerp } from "./Math/LibJsLerp";
42
- import { LibJsNormalizeInRange } from "./Math/LibJsNormalizeInRange";
43
- import { LibJsClassObservable } from "./Misc/LibJsClassObservable";
44
- import { libJsCopy } from "./Browser/LibJsCopy";
45
- import { LibJsResizeWatcher } from "./Base/LibJsResizeWatcher";
46
- import { LibJsPullUpLoad } from "./Misc/LibJsPullUpLoad";
47
- import { libJsPickUnique } from "./Data/libJsPickUnique";
48
- import { libJsCountdown } from "./Time/LibJsCountdown";
49
- /** @description 基础方法 */
50
- export const Base = {
51
- /**
52
- * @description 返回数据类型
53
- * @param v 需要判断类型的数据
54
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
55
- */
56
- libJsGetDataType,
57
- /**
58
- * @description 延时执行,切换到其他页面会暂停
59
- * @param delay 延时毫秒数
60
- * @param fn 延时执行函数
61
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPromiseTimeout-延时执行
62
- */
63
- libJsPromiseTimeout,
64
- /** @description 监听窗口变化,内部只注册一次resize事件,调用监听自身可取消监听 */
65
- LibJsResizeWatcher,
66
- };
67
- /** @description 浏览器相关方法 */
68
- export const Browser = {
69
- /** @description console颜色打印
70
- * @param title 标题
71
- * @param color 颜色
72
- * @param logs 信息
73
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsColorConsole-有色打印
74
- */
75
- libJsColorConsole,
76
- /** @description 判断是否为移动设备
77
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsMobile-判断手机
78
- */
79
- libJsIsMobile,
80
- /** @description 判断是否为平板
81
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsIsPad-判断平板
82
- */
83
- libJsIsPad,
84
- /** @description 获取浏览器地址栏参数
85
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsPathParams-地址栏参数
86
- */
87
- libJsPathParams,
88
- /** @description 动态设置网站标题及图标
89
- * @param title 网站标题
90
- * @param url 网站图标地址
91
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSetTitleIcon-网站标题图标
92
- */
93
- libJsSetTitleIcon,
94
- /** @description 网站标题交互,当从当前网页切换到其他网页,网站标题自动切换
95
- * @param backTitle 从其他网页返回时显示的标题
96
- * @param leaveTitle 从当前网页离开时显示的标题
97
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTagTitleTip-网站标题交互
98
- */
99
- libJsTagTitleTip,
100
- /** @description 对象转为url参数
101
- * @param params 对象参数
102
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsObjToUrlParams-对象转Url参数
103
- */
104
- libJsObjToUrlParams,
105
- /** @description 复制文本到剪贴板
106
- * @param text 要复制的文本
107
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#libJsCopy-复制文本到剪贴板
108
- */
109
- libJsCopy,
110
- };
111
- /** @description 数据相关方法 */
112
- export const Data = {
113
- /**
114
- * @description 将数组拆分成指定数组元素数量的多个数组
115
- * @param arr 需要拆分的数组
116
- * @param chunkSize 每个数组的元素数量
117
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsChunkArray-数组拆分
118
- */
119
- libJsChunkArray,
120
- /** @description 递归将JSON字符串深度解析为对象
121
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDeepJSONParse-深度解析JSON
122
- */
123
- libJsDeepJSONParse,
124
- /**
125
- * @description 分类汇总,将数组对象按照指定键值整理成一个以键值为键名的对象
126
- * @param arr 要分组的数组
127
- * @param key 分组的键
128
- * @returns 分组后的对象
129
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsGroupArrayByKey-分类汇总
130
- */
131
- libJsGroupArrayByKey,
132
- /**
133
- * @description 匹配电子邮件,可用于实时输入时,自动补全常用邮箱后缀
134
- * @param str 要匹配的字符串
135
- * @param emailList 电子邮件后缀列表
136
- * @returns 匹配结果数组
137
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMatchEmail-匹配E-Mail
138
- */
139
- libJsMatchEmail,
140
- /** @description 数组乱序
141
- * @param arr 需要乱序的数组
142
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsShuffleArray-数组乱序
143
- */
144
- libJsShuffleArray,
145
- /** @description 数组元素整体步数移动
146
- * @param arr 移动的数组
147
- * @param step 负数为向后移动,正数为向前移动
148
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsStepArray-数组偏移
149
- */
150
- libJsStepArray,
151
- /** @description 翻转指定索引后面的数组
152
- * @param arr 数组
153
- * @param index 开始索引
154
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibReverseArrayFromIndex-数组定位翻转
155
- */
156
- libReverseArrayFromIndex,
157
- /** @description 随机选择未使用元素 */
158
- libJsPickUnique,
159
- };
160
- /** @description 文件相关方法 */
161
- export const File = {
162
- /** @description 下载图片链接
163
- * @param link 图片链接
164
- * @param name 图片名称
165
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDownloadImageLink-图片下载
166
- */
167
- libJsDownloadImageLink,
168
- /** @description 图片压缩
169
- * @param obj 压缩参数
170
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsImageOptimizer-图片压缩
171
- */
172
- libJsImageOptimizer,
173
- /**
174
- * @description 保存文件到本地
175
- * @param data 要保存的数据
176
- * @param name 文件名
177
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSaveJson-保存文件
178
- */
179
- libJsSaveJson,
180
- };
181
- /** @description 格式化相关方法 */
182
- export const Formatter = {
183
- /**
184
- * @description 格式化字节大小
185
- * @param bytes 字节数
186
- * @returns ['大小', '单位', '大小及单位']
187
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsFormatterByte-字节格式化
188
- */
189
- libJsFormatterByte,
190
- /**
191
- * @description 隐藏手机号码中间的四位数字
192
- * @param mobile 需要处理的手机号码
193
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsMaskPhoneNumber-隐藏手机号码
194
- */
195
- libJsMaskPhoneNumber,
196
- /**
197
- * @description 数字每三位添加逗号
198
- * @param num 需要格式化的数字
199
- * @param reserve 保留小数位数
200
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumComma-数字逗号
201
- */
202
- libJsNumComma,
203
- /** @description 将大于1000的数字使用k为单位
204
- * @param num 数字
205
- * @param units 单位组,key为单位,value为格式化阈值
206
- * @returns [数字, 单位]
207
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumberUnit-数字单位
208
- */
209
- libJsNumberUnit,
210
- /**
211
- * @description 将秒数格式化为中文时间描述,支持扩展到年和月
212
- * @param seconds 秒数
213
- * @returns 格式化后的中文时间
214
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSecondsFormatterChinese-中文时间
215
- */
216
- libJsSecondsFormatterChinese,
217
- };
218
- /** @description 数学相关方法 */
219
- export const Math = {
220
- /** @description 计算表达式字符串
221
- * @param expression 表达式字符串
222
- * @param point 小数点精度
223
- * @returns 计算结果
224
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCalculateExpression-表达式字符串
225
- */
226
- libJsCalculateExpression,
227
- /**
228
- * @description 角度和弧度互相转换
229
- * @param value 角度值或弧度值
230
- * @param type 角度类型或弧度类型
231
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsConvertAngle-角弧度互转
232
- */
233
- libJsConvertAngle,
234
- /** @description 计算两点角度
235
- * @param coord1 起点坐标
236
- * @param coord2 终点坐标
237
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsAngle-两点角度
238
- */
239
- libJsCoordsAngle,
240
- /** @description 计算两点距离
241
- * @param coord1 起点坐标
242
- * @param coord2 终点坐标
243
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsCoordsDistance-两点距离
244
- */
245
- libJsCoordsDistance,
246
- /** @description 计算两个数的运算结果,并保留指定位数的小数
247
- * @param num1 第一个数
248
- * @param num2 第二个数
249
- * @param operator 运算符,支持加减乘除
250
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsDecimal-高精度计算
251
- */
252
- libJsDecimal,
253
- };
254
- /** @description 杂项相关方法 */
255
- export const Misc = {
256
- /**
257
- * @description 表单验证函数
258
- * @param form 表单数据对象
259
- * @param rules 验证规则数组
260
- * @returns 验证结果数组,包含未通过验证的项
261
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRegFormValidate-表单验证
262
- */
263
- libJsRegFormValidate,
264
- /** @description 请求失败重连
265
- * @param promiseFn 请求函数
266
- * @param maxRetries 最大重试次数
267
- * @param retryDelay 重试间隔时间
268
- * @param params 请求参数
269
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRetryRequest-请求重连
270
- */
271
- libJsRetryRequest,
272
- /** @description 数字步进器
273
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNumberStepper-数字步进器
274
- */
275
- LibJsNumberStepper,
276
- /** @description 线性插值
277
- * @param start 当 value = 0 时,返回 start
278
- * @param end 当 value = 1 时,返回 end
279
- * @param value 插值比例,取值范围 0~1
280
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsLerp-线性插值
281
- */
282
- LibJsLerp,
283
- /** @description 值介于起点与终点之间时返回一个介于0与1之间的数
284
- * @param start 起点
285
- * @param end 终点
286
- * @param value 动态值
287
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsNormalizeInRange-范围归一化
288
- */
289
- LibJsNormalizeInRange,
290
- /** @description 事件发射器
291
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsEmitter-事件发射器
292
- */
293
- LibJsEmitter,
294
- /** @description 类属性监听器
295
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsClassObservable-类属性监听器
296
- */
297
- LibJsClassObservable,
298
- /** @description 上拉加载 */
299
- LibJsPullUpLoad,
300
- };
301
- /** @description 随机相关方法 */
302
- export const Random = {
303
- /** @description 百分比概率结果
304
- * @param probability 触发概率,百分比,0-100
305
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsProbabilityResult-概率触发
306
- */
307
- libJsProbabilityResult,
308
- /** @description 随机数
309
- * @param min 最小值
310
- * @param max 最大值
311
- * @param num 保留小数位数
312
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandom-随机数
313
- */
314
- libJsRandom,
315
- /** @description 随机 RGBA 颜色
316
- * @param alpha 透明度
317
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsRandomColor-随机色
318
- */
319
- libJsRandomColor,
320
- /** @description 随机生成n个指定范围的随机数数组
321
- * @param min 最小值
322
- * @param max 最大值
323
- * @param count 数组长度
324
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsUniqueRandomNumbers-随机数数组
325
- */
326
- libJsUniqueRandomNumbers,
327
- };
328
- /** @description 时间相关方法 */
329
- export const Time = {
330
- /**
331
- * @description 传入时间戳与当前时间判断是否为同一天或同一周
332
- * @param timestamp 毫秒时间戳
333
- * @param unit 判断单位
334
- * @returns 0-同一单位时间 1-新单位时间 -1时间戳大于当前时间
335
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsSameTimeCheck-时间比对
336
- */
337
- libJsSameTimeCheck,
338
- /** @description 时间差计算
339
- * @param timestamp 毫秒时间戳
340
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeAgo-中文时间差
341
- */
342
- libJsTimeAgo,
343
- /**
344
- * @description 根据当前时间返回问候语
345
- * @param greet 自定义问候语对象
346
- * @link 使用方法:https://www.npmjs.com/package/lyb-js#LibJsTimeGreeting-时间问候
347
- */
348
- libJsTimeGreeting,
349
- /** @description 倒计时
350
- * @param endTime 毫秒时间戳
351
- */
352
- libJsCountdown,
353
- };