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