@alibarbar/common 1.0.0

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 (210) hide show
  1. package/README.md +338 -0
  2. package/dist/algorithm.d.mts +66 -0
  3. package/dist/algorithm.d.ts +66 -0
  4. package/dist/algorithm.js +44 -0
  5. package/dist/algorithm.js.map +1 -0
  6. package/dist/algorithm.mjs +3 -0
  7. package/dist/algorithm.mjs.map +1 -0
  8. package/dist/array.d.mts +139 -0
  9. package/dist/array.d.ts +139 -0
  10. package/dist/array.js +84 -0
  11. package/dist/array.js.map +1 -0
  12. package/dist/array.mjs +3 -0
  13. package/dist/array.mjs.map +1 -0
  14. package/dist/chunk-27UDDVLZ.js +259 -0
  15. package/dist/chunk-27UDDVLZ.js.map +1 -0
  16. package/dist/chunk-2FFSQ573.mjs +138 -0
  17. package/dist/chunk-2FFSQ573.mjs.map +1 -0
  18. package/dist/chunk-4RGXV4SJ.js +106 -0
  19. package/dist/chunk-4RGXV4SJ.js.map +1 -0
  20. package/dist/chunk-56W6YECK.js +374 -0
  21. package/dist/chunk-56W6YECK.js.map +1 -0
  22. package/dist/chunk-5BGSUGTI.mjs +128 -0
  23. package/dist/chunk-5BGSUGTI.mjs.map +1 -0
  24. package/dist/chunk-7E6GELHJ.mjs +302 -0
  25. package/dist/chunk-7E6GELHJ.mjs.map +1 -0
  26. package/dist/chunk-7V5UQXIO.js +89 -0
  27. package/dist/chunk-7V5UQXIO.js.map +1 -0
  28. package/dist/chunk-A4SWQXX7.mjs +484 -0
  29. package/dist/chunk-A4SWQXX7.mjs.map +1 -0
  30. package/dist/chunk-ALDC6LRJ.mjs +85 -0
  31. package/dist/chunk-ALDC6LRJ.mjs.map +1 -0
  32. package/dist/chunk-BHCRFURU.js +491 -0
  33. package/dist/chunk-BHCRFURU.js.map +1 -0
  34. package/dist/chunk-D7CS5EKF.js +110 -0
  35. package/dist/chunk-D7CS5EKF.js.map +1 -0
  36. package/dist/chunk-DYBSRI7V.js +189 -0
  37. package/dist/chunk-DYBSRI7V.js.map +1 -0
  38. package/dist/chunk-F3LAGHPG.js +332 -0
  39. package/dist/chunk-F3LAGHPG.js.map +1 -0
  40. package/dist/chunk-HLDFI7R2.mjs +175 -0
  41. package/dist/chunk-HLDFI7R2.mjs.map +1 -0
  42. package/dist/chunk-HME2N3VY.mjs +354 -0
  43. package/dist/chunk-HME2N3VY.mjs.map +1 -0
  44. package/dist/chunk-I3L42475.js +145 -0
  45. package/dist/chunk-I3L42475.js.map +1 -0
  46. package/dist/chunk-JBLX27WD.mjs +240 -0
  47. package/dist/chunk-JBLX27WD.mjs.map +1 -0
  48. package/dist/chunk-JHZ7M2MR.mjs +133 -0
  49. package/dist/chunk-JHZ7M2MR.mjs.map +1 -0
  50. package/dist/chunk-JK2SE3I2.js +100 -0
  51. package/dist/chunk-JK2SE3I2.js.map +1 -0
  52. package/dist/chunk-JQZBPAPO.js +157 -0
  53. package/dist/chunk-JQZBPAPO.js.map +1 -0
  54. package/dist/chunk-JXYGC2C5.mjs +100 -0
  55. package/dist/chunk-JXYGC2C5.mjs.map +1 -0
  56. package/dist/chunk-KGFTD255.js +104 -0
  57. package/dist/chunk-KGFTD255.js.map +1 -0
  58. package/dist/chunk-LBHBNPNJ.mjs +148 -0
  59. package/dist/chunk-LBHBNPNJ.mjs.map +1 -0
  60. package/dist/chunk-LCXGZISK.js +158 -0
  61. package/dist/chunk-LCXGZISK.js.map +1 -0
  62. package/dist/chunk-LF4CILQS.mjs +87 -0
  63. package/dist/chunk-LF4CILQS.mjs.map +1 -0
  64. package/dist/chunk-MMR6XQNX.js +98 -0
  65. package/dist/chunk-MMR6XQNX.js.map +1 -0
  66. package/dist/chunk-NSSDYX2U.mjs +80 -0
  67. package/dist/chunk-NSSDYX2U.mjs.map +1 -0
  68. package/dist/chunk-O3O67R4I.js +143 -0
  69. package/dist/chunk-O3O67R4I.js.map +1 -0
  70. package/dist/chunk-OX5PLOWB.js +90 -0
  71. package/dist/chunk-OX5PLOWB.js.map +1 -0
  72. package/dist/chunk-PJ7UCTX4.mjs +362 -0
  73. package/dist/chunk-PJ7UCTX4.mjs.map +1 -0
  74. package/dist/chunk-QIBE7GVN.mjs +81 -0
  75. package/dist/chunk-QIBE7GVN.mjs.map +1 -0
  76. package/dist/chunk-QIOC54LQ.mjs +130 -0
  77. package/dist/chunk-QIOC54LQ.mjs.map +1 -0
  78. package/dist/chunk-QV6MIQ7H.mjs +328 -0
  79. package/dist/chunk-QV6MIQ7H.mjs.map +1 -0
  80. package/dist/chunk-TQN37HIN.js +94 -0
  81. package/dist/chunk-TQN37HIN.js.map +1 -0
  82. package/dist/chunk-XJTZDXSR.mjs +94 -0
  83. package/dist/chunk-XJTZDXSR.mjs.map +1 -0
  84. package/dist/chunk-XVUE53T3.js +361 -0
  85. package/dist/chunk-XVUE53T3.js.map +1 -0
  86. package/dist/chunk-Y364QIQH.js +139 -0
  87. package/dist/chunk-Y364QIQH.js.map +1 -0
  88. package/dist/chunk-YXM6Q4JS.mjs +94 -0
  89. package/dist/chunk-YXM6Q4JS.mjs.map +1 -0
  90. package/dist/chunk-ZDMFMUDR.js +309 -0
  91. package/dist/chunk-ZDMFMUDR.js.map +1 -0
  92. package/dist/chunk-ZVJ6NQUM.mjs +82 -0
  93. package/dist/chunk-ZVJ6NQUM.mjs.map +1 -0
  94. package/dist/color.d.mts +74 -0
  95. package/dist/color.d.ts +74 -0
  96. package/dist/color.js +40 -0
  97. package/dist/color.js.map +1 -0
  98. package/dist/color.mjs +3 -0
  99. package/dist/color.mjs.map +1 -0
  100. package/dist/crypto.d.mts +92 -0
  101. package/dist/crypto.d.ts +92 -0
  102. package/dist/crypto.js +60 -0
  103. package/dist/crypto.js.map +1 -0
  104. package/dist/crypto.mjs +3 -0
  105. package/dist/crypto.mjs.map +1 -0
  106. package/dist/data-structure.d.mts +213 -0
  107. package/dist/data-structure.d.ts +213 -0
  108. package/dist/data-structure.js +32 -0
  109. package/dist/data-structure.js.map +1 -0
  110. package/dist/data-structure.mjs +3 -0
  111. package/dist/data-structure.mjs.map +1 -0
  112. package/dist/date.d.mts +108 -0
  113. package/dist/date.d.ts +108 -0
  114. package/dist/date.js +72 -0
  115. package/dist/date.js.map +1 -0
  116. package/dist/date.mjs +3 -0
  117. package/dist/date.mjs.map +1 -0
  118. package/dist/dom.d.mts +92 -0
  119. package/dist/dom.d.ts +92 -0
  120. package/dist/dom.js +56 -0
  121. package/dist/dom.js.map +1 -0
  122. package/dist/dom.mjs +3 -0
  123. package/dist/dom.mjs.map +1 -0
  124. package/dist/file.d.mts +44 -0
  125. package/dist/file.d.ts +44 -0
  126. package/dist/file.js +32 -0
  127. package/dist/file.js.map +1 -0
  128. package/dist/file.mjs +3 -0
  129. package/dist/file.mjs.map +1 -0
  130. package/dist/i18n.d.mts +77 -0
  131. package/dist/i18n.d.ts +77 -0
  132. package/dist/i18n.js +40 -0
  133. package/dist/i18n.js.map +1 -0
  134. package/dist/i18n.mjs +3 -0
  135. package/dist/i18n.mjs.map +1 -0
  136. package/dist/index.d.mts +155 -0
  137. package/dist/index.d.ts +155 -0
  138. package/dist/index.js +839 -0
  139. package/dist/index.js.map +1 -0
  140. package/dist/index.mjs +22 -0
  141. package/dist/index.mjs.map +1 -0
  142. package/dist/network.d.mts +47 -0
  143. package/dist/network.d.ts +47 -0
  144. package/dist/network.js +28 -0
  145. package/dist/network.js.map +1 -0
  146. package/dist/network.mjs +3 -0
  147. package/dist/network.mjs.map +1 -0
  148. package/dist/number.d.mts +100 -0
  149. package/dist/number.d.ts +100 -0
  150. package/dist/number.js +56 -0
  151. package/dist/number.js.map +1 -0
  152. package/dist/number.mjs +3 -0
  153. package/dist/number.mjs.map +1 -0
  154. package/dist/object.d.mts +132 -0
  155. package/dist/object.d.ts +132 -0
  156. package/dist/object.js +80 -0
  157. package/dist/object.js.map +1 -0
  158. package/dist/object.mjs +3 -0
  159. package/dist/object.mjs.map +1 -0
  160. package/dist/performance.d.mts +85 -0
  161. package/dist/performance.d.ts +85 -0
  162. package/dist/performance.js +40 -0
  163. package/dist/performance.js.map +1 -0
  164. package/dist/performance.mjs +3 -0
  165. package/dist/performance.mjs.map +1 -0
  166. package/dist/storage.d.mts +176 -0
  167. package/dist/storage.d.ts +176 -0
  168. package/dist/storage.js +33 -0
  169. package/dist/storage.js.map +1 -0
  170. package/dist/storage.mjs +4 -0
  171. package/dist/storage.mjs.map +1 -0
  172. package/dist/string.d.mts +105 -0
  173. package/dist/string.d.ts +105 -0
  174. package/dist/string.js +68 -0
  175. package/dist/string.js.map +1 -0
  176. package/dist/string.mjs +3 -0
  177. package/dist/string.mjs.map +1 -0
  178. package/dist/tracking.d.mts +182 -0
  179. package/dist/tracking.d.ts +182 -0
  180. package/dist/tracking.js +52 -0
  181. package/dist/tracking.js.map +1 -0
  182. package/dist/tracking.mjs +3 -0
  183. package/dist/tracking.mjs.map +1 -0
  184. package/dist/transform.d.mts +53 -0
  185. package/dist/transform.d.ts +53 -0
  186. package/dist/transform.js +32 -0
  187. package/dist/transform.js.map +1 -0
  188. package/dist/transform.mjs +3 -0
  189. package/dist/transform.mjs.map +1 -0
  190. package/dist/upload-DzlQtUBc.d.mts +202 -0
  191. package/dist/upload-DzlQtUBc.d.ts +202 -0
  192. package/dist/upload.d.mts +1 -0
  193. package/dist/upload.d.ts +1 -0
  194. package/dist/upload.js +17 -0
  195. package/dist/upload.js.map +1 -0
  196. package/dist/upload.mjs +4 -0
  197. package/dist/upload.mjs.map +1 -0
  198. package/dist/url.d.mts +82 -0
  199. package/dist/url.d.ts +82 -0
  200. package/dist/url.js +44 -0
  201. package/dist/url.js.map +1 -0
  202. package/dist/url.mjs +3 -0
  203. package/dist/url.mjs.map +1 -0
  204. package/dist/validation.d.mts +83 -0
  205. package/dist/validation.d.ts +83 -0
  206. package/dist/validation.js +60 -0
  207. package/dist/validation.js.map +1 -0
  208. package/dist/validation.mjs +3 -0
  209. package/dist/validation.mjs.map +1 -0
  210. package/package.json +170 -0
@@ -0,0 +1,132 @@
1
+ /**
2
+ * 对象工具函数
3
+ */
4
+ /**
5
+ * 深拷贝对象
6
+ * 支持 Date、Array、RegExp、Map、Set 等特殊类型
7
+ * @param obj - 输入对象
8
+ * @returns 深拷贝后的对象
9
+ */
10
+ declare function deepClone<T>(obj: T): T;
11
+ /**
12
+ * 对象合并
13
+ * @param target - 目标对象
14
+ * @param sources - 源对象数组
15
+ * @returns 合并后的对象
16
+ */
17
+ declare function merge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
18
+ /**
19
+ * 深合并对象
20
+ * @param target - 目标对象
21
+ * @param sources - 源对象数组
22
+ * @returns 深合并后的对象
23
+ */
24
+ declare function deepMerge<T extends Record<string, unknown>>(target: T, ...sources: Partial<T>[]): T;
25
+ /**
26
+ * 获取对象嵌套属性值
27
+ * @param obj - 对象
28
+ * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']
29
+ * @param defaultValue - 默认值
30
+ * @returns 属性值
31
+ */
32
+ declare function get<T = unknown>(obj: Record<string, unknown>, path: string | string[], defaultValue?: T): T | undefined;
33
+ /**
34
+ * 设置嵌套属性值
35
+ * @param obj - 对象
36
+ * @param path - 属性路径,如 'a.b.c' 或 ['a', 'b', 'c']
37
+ * @param value - 要设置的值
38
+ * @returns 设置后的新对象(不修改原对象)
39
+ */
40
+ declare function set<T extends Record<string, unknown>>(obj: T, path: string | string[], value: unknown): T;
41
+ /**
42
+ * 选择指定属性
43
+ * @param obj - 对象
44
+ * @param keys - 要选择的属性键数组
45
+ * @returns 包含指定属性的新对象
46
+ */
47
+ declare function pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
48
+ /**
49
+ * 排除指定属性
50
+ * @param obj - 对象
51
+ * @param keys - 要排除的属性键数组
52
+ * @returns 排除指定属性后的新对象
53
+ */
54
+ declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
55
+ /**
56
+ * 获取所有键(支持深度)
57
+ * @param obj - 对象
58
+ * @param deep - 是否深度获取,默认为 false
59
+ * @returns 键数组
60
+ */
61
+ declare function keys<T extends Record<string, unknown>>(obj: T, deep?: boolean): string[];
62
+ /**
63
+ * 获取所有值(支持深度)
64
+ * @param obj - 对象
65
+ * @param deep - 是否深度获取,默认为 false
66
+ * @returns 值数组
67
+ */
68
+ declare function values<T extends Record<string, unknown>>(obj: T, deep?: boolean): unknown[];
69
+ /**
70
+ * 键映射
71
+ * @param obj - 对象
72
+ * @param fn - 键转换函数
73
+ * @returns 键映射后的新对象
74
+ */
75
+ declare function mapKeys<T extends Record<string, unknown>>(obj: T, fn: (key: string, value: unknown) => string): Record<string, unknown>;
76
+ /**
77
+ * 值映射
78
+ * @param obj - 对象
79
+ * @param fn - 值转换函数
80
+ * @returns 值映射后的新对象
81
+ */
82
+ declare function mapValues<T extends Record<string, unknown>, R>(obj: T, fn: (value: unknown, key: string) => R): Record<string, R>;
83
+ /**
84
+ * 键值反转
85
+ * @param obj - 对象
86
+ * @returns 键值反转后的新对象
87
+ */
88
+ declare function invert<T extends Record<string, string | number>>(obj: T): Record<string, string>;
89
+ /**
90
+ * 设置默认值
91
+ * @param obj - 对象
92
+ * @param defaults - 默认值对象
93
+ * @returns 合并默认值后的新对象
94
+ */
95
+ declare function defaults<T extends Record<string, unknown>>(obj: Partial<T>, ...defaults: Partial<T>[]): T;
96
+ /**
97
+ * 判断对象是否为空
98
+ * @param obj - 对象
99
+ * @returns 是否为空
100
+ */
101
+ declare function isEmptyObject(obj: Record<string, unknown>): boolean;
102
+ /**
103
+ * 深度比较两个对象
104
+ * @param obj1 - 第一个对象
105
+ * @param obj2 - 第二个对象
106
+ * @returns 是否相等
107
+ */
108
+ declare function isEqual<T>(obj1: T, obj2: T): boolean;
109
+ /**
110
+ * 对象转换
111
+ * @param obj - 对象
112
+ * @param iteratee - 转换函数
113
+ * @param accumulator - 累加器,默认为空对象
114
+ * @returns 转换后的对象
115
+ */
116
+ declare function transform<T extends Record<string, unknown>, R extends Record<string, unknown>>(obj: T, iteratee: (result: R, value: unknown, key: string) => void, accumulator?: R): R;
117
+ /**
118
+ * 条件选择属性
119
+ * @param obj - 对象
120
+ * @param predicate - 条件函数
121
+ * @returns 满足条件的属性组成的新对象
122
+ */
123
+ declare function pickBy<T extends Record<string, unknown>>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
124
+ /**
125
+ * 条件排除属性
126
+ * @param obj - 对象
127
+ * @param predicate - 条件函数
128
+ * @returns 不满足条件的属性组成的新对象
129
+ */
130
+ declare function omitBy<T extends Record<string, unknown>>(obj: T, predicate: (value: unknown, key: string) => boolean): Partial<T>;
131
+
132
+ export { deepClone, deepMerge, defaults, get, invert, isEmptyObject, isEqual, keys, mapKeys, mapValues, merge, omit, omitBy, pick, pickBy, set, transform, values };
package/dist/object.js ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var chunk27UDDVLZ_js = require('./chunk-27UDDVLZ.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "deepClone", {
8
+ enumerable: true,
9
+ get: function () { return chunk27UDDVLZ_js.deepClone; }
10
+ });
11
+ Object.defineProperty(exports, "deepMerge", {
12
+ enumerable: true,
13
+ get: function () { return chunk27UDDVLZ_js.deepMerge; }
14
+ });
15
+ Object.defineProperty(exports, "defaults", {
16
+ enumerable: true,
17
+ get: function () { return chunk27UDDVLZ_js.defaults; }
18
+ });
19
+ Object.defineProperty(exports, "get", {
20
+ enumerable: true,
21
+ get: function () { return chunk27UDDVLZ_js.get; }
22
+ });
23
+ Object.defineProperty(exports, "invert", {
24
+ enumerable: true,
25
+ get: function () { return chunk27UDDVLZ_js.invert; }
26
+ });
27
+ Object.defineProperty(exports, "isEmptyObject", {
28
+ enumerable: true,
29
+ get: function () { return chunk27UDDVLZ_js.isEmptyObject; }
30
+ });
31
+ Object.defineProperty(exports, "isEqual", {
32
+ enumerable: true,
33
+ get: function () { return chunk27UDDVLZ_js.isEqual; }
34
+ });
35
+ Object.defineProperty(exports, "keys", {
36
+ enumerable: true,
37
+ get: function () { return chunk27UDDVLZ_js.keys; }
38
+ });
39
+ Object.defineProperty(exports, "mapKeys", {
40
+ enumerable: true,
41
+ get: function () { return chunk27UDDVLZ_js.mapKeys; }
42
+ });
43
+ Object.defineProperty(exports, "mapValues", {
44
+ enumerable: true,
45
+ get: function () { return chunk27UDDVLZ_js.mapValues; }
46
+ });
47
+ Object.defineProperty(exports, "merge", {
48
+ enumerable: true,
49
+ get: function () { return chunk27UDDVLZ_js.merge; }
50
+ });
51
+ Object.defineProperty(exports, "omit", {
52
+ enumerable: true,
53
+ get: function () { return chunk27UDDVLZ_js.omit; }
54
+ });
55
+ Object.defineProperty(exports, "omitBy", {
56
+ enumerable: true,
57
+ get: function () { return chunk27UDDVLZ_js.omitBy; }
58
+ });
59
+ Object.defineProperty(exports, "pick", {
60
+ enumerable: true,
61
+ get: function () { return chunk27UDDVLZ_js.pick; }
62
+ });
63
+ Object.defineProperty(exports, "pickBy", {
64
+ enumerable: true,
65
+ get: function () { return chunk27UDDVLZ_js.pickBy; }
66
+ });
67
+ Object.defineProperty(exports, "set", {
68
+ enumerable: true,
69
+ get: function () { return chunk27UDDVLZ_js.set; }
70
+ });
71
+ Object.defineProperty(exports, "transform", {
72
+ enumerable: true,
73
+ get: function () { return chunk27UDDVLZ_js.transform; }
74
+ });
75
+ Object.defineProperty(exports, "values", {
76
+ enumerable: true,
77
+ get: function () { return chunk27UDDVLZ_js.values; }
78
+ });
79
+ //# sourceMappingURL=object.js.map
80
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"object.js"}
@@ -0,0 +1,3 @@
1
+ export { deepClone, deepMerge, defaults, get, invert, isEmptyObject, isEqual, keys, mapKeys, mapValues, merge, omit, omitBy, pick, pickBy, set, transform, values } from './chunk-JBLX27WD.mjs';
2
+ //# sourceMappingURL=object.mjs.map
3
+ //# sourceMappingURL=object.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"object.mjs"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 性能工具函数
3
+ */
4
+ /**
5
+ * 防抖函数
6
+ * @param fn - 要防抖的函数
7
+ * @param delay - 延迟时间(毫秒)
8
+ * @returns 防抖后的函数
9
+ */
10
+ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
11
+ /**
12
+ * 节流函数
13
+ * @param fn - 要节流的函数
14
+ * @param delay - 延迟时间(毫秒)
15
+ * @returns 节流后的函数
16
+ */
17
+ declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
18
+ /**
19
+ * 函数记忆化
20
+ * @param fn - 要记忆化的函数
21
+ * @param keyFn - 缓存键生成函数,可选
22
+ * @returns 记忆化后的函数
23
+ */
24
+ declare function memoize<T extends (...args: unknown[]) => unknown>(fn: T, keyFn?: (...args: Parameters<T>) => string): T;
25
+ /**
26
+ * 只执行一次的函数
27
+ * @param fn - 要执行的函数
28
+ * @returns 包装后的函数
29
+ */
30
+ declare function once<T extends (...args: unknown[]) => unknown>(fn: T): T;
31
+ /**
32
+ * 重试机制
33
+ * @param fn - 要重试的函数
34
+ * @param retryCount - 重试次数,默认为 3
35
+ * @param retryDelay - 重试延迟(毫秒),默认为 1000
36
+ * @returns Promise<T>
37
+ */
38
+ declare function retry<T>(fn: () => Promise<T>, retryCount?: number, retryDelay?: number): Promise<T>;
39
+ /**
40
+ * 超时控制
41
+ * @param fn - 要执行的函数
42
+ * @param timeout - 超时时间(毫秒)
43
+ * @returns Promise<T>
44
+ */
45
+ declare function timeout<T>(fn: () => Promise<T>, timeout: number): Promise<T>;
46
+ /**
47
+ * 批量处理
48
+ * @param items - 要处理的项数组
49
+ * @param fn - 处理函数
50
+ * @param batchSize - 每批大小,默认为 10
51
+ * @returns Promise<T[]>
52
+ */
53
+ declare function batch<T, R>(items: T[], fn: (item: T) => Promise<R>, batchSize?: number): Promise<R[]>;
54
+ /**
55
+ * 队列处理
56
+ */
57
+ declare class Queue<T> {
58
+ private items;
59
+ private processing;
60
+ private processor?;
61
+ /**
62
+ * 添加项到队列
63
+ * @param item - 要添加的项
64
+ */
65
+ enqueue(item: T): void;
66
+ /**
67
+ * 设置处理函数并开始处理
68
+ * @param processor - 处理函数
69
+ */
70
+ start(processor: (item: T) => Promise<void>): Promise<void>;
71
+ /**
72
+ * 处理队列
73
+ */
74
+ private processItems;
75
+ /**
76
+ * 清空队列
77
+ */
78
+ clear(): void;
79
+ /**
80
+ * 获取队列长度
81
+ */
82
+ get length(): number;
83
+ }
84
+
85
+ export { Queue, batch, debounce, memoize, once, retry, throttle, timeout };
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 性能工具函数
3
+ */
4
+ /**
5
+ * 防抖函数
6
+ * @param fn - 要防抖的函数
7
+ * @param delay - 延迟时间(毫秒)
8
+ * @returns 防抖后的函数
9
+ */
10
+ declare function debounce<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
11
+ /**
12
+ * 节流函数
13
+ * @param fn - 要节流的函数
14
+ * @param delay - 延迟时间(毫秒)
15
+ * @returns 节流后的函数
16
+ */
17
+ declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, delay: number): (...args: Parameters<T>) => void;
18
+ /**
19
+ * 函数记忆化
20
+ * @param fn - 要记忆化的函数
21
+ * @param keyFn - 缓存键生成函数,可选
22
+ * @returns 记忆化后的函数
23
+ */
24
+ declare function memoize<T extends (...args: unknown[]) => unknown>(fn: T, keyFn?: (...args: Parameters<T>) => string): T;
25
+ /**
26
+ * 只执行一次的函数
27
+ * @param fn - 要执行的函数
28
+ * @returns 包装后的函数
29
+ */
30
+ declare function once<T extends (...args: unknown[]) => unknown>(fn: T): T;
31
+ /**
32
+ * 重试机制
33
+ * @param fn - 要重试的函数
34
+ * @param retryCount - 重试次数,默认为 3
35
+ * @param retryDelay - 重试延迟(毫秒),默认为 1000
36
+ * @returns Promise<T>
37
+ */
38
+ declare function retry<T>(fn: () => Promise<T>, retryCount?: number, retryDelay?: number): Promise<T>;
39
+ /**
40
+ * 超时控制
41
+ * @param fn - 要执行的函数
42
+ * @param timeout - 超时时间(毫秒)
43
+ * @returns Promise<T>
44
+ */
45
+ declare function timeout<T>(fn: () => Promise<T>, timeout: number): Promise<T>;
46
+ /**
47
+ * 批量处理
48
+ * @param items - 要处理的项数组
49
+ * @param fn - 处理函数
50
+ * @param batchSize - 每批大小,默认为 10
51
+ * @returns Promise<T[]>
52
+ */
53
+ declare function batch<T, R>(items: T[], fn: (item: T) => Promise<R>, batchSize?: number): Promise<R[]>;
54
+ /**
55
+ * 队列处理
56
+ */
57
+ declare class Queue<T> {
58
+ private items;
59
+ private processing;
60
+ private processor?;
61
+ /**
62
+ * 添加项到队列
63
+ * @param item - 要添加的项
64
+ */
65
+ enqueue(item: T): void;
66
+ /**
67
+ * 设置处理函数并开始处理
68
+ * @param processor - 处理函数
69
+ */
70
+ start(processor: (item: T) => Promise<void>): Promise<void>;
71
+ /**
72
+ * 处理队列
73
+ */
74
+ private processItems;
75
+ /**
76
+ * 清空队列
77
+ */
78
+ clear(): void;
79
+ /**
80
+ * 获取队列长度
81
+ */
82
+ get length(): number;
83
+ }
84
+
85
+ export { Queue, batch, debounce, memoize, once, retry, throttle, timeout };
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ var chunkJQZBPAPO_js = require('./chunk-JQZBPAPO.js');
4
+
5
+
6
+
7
+ Object.defineProperty(exports, "Queue", {
8
+ enumerable: true,
9
+ get: function () { return chunkJQZBPAPO_js.Queue; }
10
+ });
11
+ Object.defineProperty(exports, "batch", {
12
+ enumerable: true,
13
+ get: function () { return chunkJQZBPAPO_js.batch; }
14
+ });
15
+ Object.defineProperty(exports, "debounce", {
16
+ enumerable: true,
17
+ get: function () { return chunkJQZBPAPO_js.debounce; }
18
+ });
19
+ Object.defineProperty(exports, "memoize", {
20
+ enumerable: true,
21
+ get: function () { return chunkJQZBPAPO_js.memoize; }
22
+ });
23
+ Object.defineProperty(exports, "once", {
24
+ enumerable: true,
25
+ get: function () { return chunkJQZBPAPO_js.once; }
26
+ });
27
+ Object.defineProperty(exports, "retry", {
28
+ enumerable: true,
29
+ get: function () { return chunkJQZBPAPO_js.retry; }
30
+ });
31
+ Object.defineProperty(exports, "throttle", {
32
+ enumerable: true,
33
+ get: function () { return chunkJQZBPAPO_js.throttle; }
34
+ });
35
+ Object.defineProperty(exports, "timeout", {
36
+ enumerable: true,
37
+ get: function () { return chunkJQZBPAPO_js.timeout; }
38
+ });
39
+ //# sourceMappingURL=performance.js.map
40
+ //# sourceMappingURL=performance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"performance.js"}
@@ -0,0 +1,3 @@
1
+ export { Queue, batch, debounce, memoize, once, retry, throttle, timeout } from './chunk-LBHBNPNJ.mjs';
2
+ //# sourceMappingURL=performance.mjs.map
3
+ //# sourceMappingURL=performance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"performance.mjs"}
@@ -0,0 +1,176 @@
1
+ import { RSAKeyPair } from './crypto.mjs';
2
+
3
+ /**
4
+ * 存储工具函数
5
+ */
6
+
7
+ /**
8
+ * 存储配置选项
9
+ */
10
+ interface StorageOptions {
11
+ /** RSA公钥(用于加密) */
12
+ publicKey?: CryptoKey;
13
+ /** RSA私钥(用于解密) */
14
+ privateKey?: CryptoKey;
15
+ /** 是否启用加密,默认为 true */
16
+ encrypt?: boolean;
17
+ }
18
+ /**
19
+ * 设置全局RSA密钥对
20
+ * @param keyPair - RSA密钥对
21
+ */
22
+ declare function setStorageKeyPair(keyPair: RSAKeyPair): void;
23
+ /**
24
+ * 获取全局密钥对
25
+ * @returns 全局密钥对或null
26
+ */
27
+ declare function getStorageKeyPair(): RSAKeyPair | null;
28
+ /**
29
+ * localStorage封装(支持过期时间和RSA加密)
30
+ */
31
+ declare const localStorage: {
32
+ /**
33
+ * 设置值
34
+ * @param key - 键
35
+ * @param value - 值
36
+ * @param options - 选项(过期时间、密钥等)
37
+ * @returns Promise<void>
38
+ */
39
+ set<T>(key: string, value: T, options?: {
40
+ expiry?: number;
41
+ publicKey?: CryptoKey;
42
+ }): Promise<void>;
43
+ /**
44
+ * 获取值
45
+ * @param key - 键
46
+ * @param options - 选项(默认值、私钥等)
47
+ * @returns Promise<T | undefined> 值或默认值
48
+ */
49
+ get<T>(key: string, options?: {
50
+ defaultValue?: T;
51
+ privateKey?: CryptoKey;
52
+ }): Promise<T | undefined>;
53
+ /**
54
+ * 移除值
55
+ * @param key - 键
56
+ */
57
+ remove(key: string): void;
58
+ /**
59
+ * 清空所有值
60
+ */
61
+ clear(): void;
62
+ /**
63
+ * 获取所有键
64
+ * @returns 键数组
65
+ */
66
+ keys(): string[];
67
+ };
68
+ /**
69
+ * sessionStorage封装(支持RSA加密)
70
+ */
71
+ declare const sessionStorage: {
72
+ /**
73
+ * 设置值
74
+ * @param key - 键
75
+ * @param value - 值
76
+ * @param options - 选项(公钥等)
77
+ * @returns Promise<void>
78
+ */
79
+ set<T>(key: string, value: T, options?: {
80
+ publicKey?: CryptoKey;
81
+ }): Promise<void>;
82
+ /**
83
+ * 获取值
84
+ * @param key - 键
85
+ * @param options - 选项(默认值、私钥等)
86
+ * @returns Promise<T | undefined> 值或默认值
87
+ */
88
+ get<T>(key: string, options?: {
89
+ defaultValue?: T;
90
+ privateKey?: CryptoKey;
91
+ }): Promise<T | undefined>;
92
+ /**
93
+ * 移除值
94
+ * @param key - 键
95
+ */
96
+ remove(key: string): void;
97
+ /**
98
+ * 清空所有值
99
+ */
100
+ clear(): void;
101
+ };
102
+ /**
103
+ * Cookie操作封装
104
+ */
105
+ declare const cookie: {
106
+ /**
107
+ * 设置Cookie
108
+ * @param key - 键
109
+ * @param value - 值
110
+ * @param options - Cookie选项
111
+ */
112
+ set(key: string, value: string, options?: {
113
+ expires?: number | Date;
114
+ path?: string;
115
+ domain?: string;
116
+ secure?: boolean;
117
+ sameSite?: "strict" | "lax" | "none";
118
+ }): void;
119
+ /**
120
+ * 获取Cookie
121
+ * @param key - 键
122
+ * @returns Cookie值
123
+ */
124
+ get(key: string): string | undefined;
125
+ /**
126
+ * 移除Cookie
127
+ * @param key - 键
128
+ * @param options - Cookie选项
129
+ */
130
+ remove(key: string, options?: {
131
+ path?: string;
132
+ domain?: string;
133
+ }): void;
134
+ /**
135
+ * 获取所有Cookie
136
+ * @returns Cookie对象
137
+ */
138
+ getAll(): Record<string, string>;
139
+ };
140
+ /**
141
+ * 统一存储接口(自动选择存储方式,支持RSA加密)
142
+ */
143
+ declare const storage: {
144
+ /**
145
+ * 设置值(优先使用localStorage,失败则使用sessionStorage)
146
+ * @param key - 键
147
+ * @param value - 值
148
+ * @param options - 选项(过期时间、公钥等)
149
+ * @returns Promise<void>
150
+ */
151
+ set<T>(key: string, value: T, options?: {
152
+ expiry?: number;
153
+ publicKey?: CryptoKey;
154
+ }): Promise<void>;
155
+ /**
156
+ * 获取值
157
+ * @param key - 键
158
+ * @param options - 选项(默认值、私钥等)
159
+ * @returns Promise<T | undefined> 值或默认值
160
+ */
161
+ get<T>(key: string, options?: {
162
+ defaultValue?: T;
163
+ privateKey?: CryptoKey;
164
+ }): Promise<T | undefined>;
165
+ /**
166
+ * 移除值
167
+ * @param key - 键
168
+ */
169
+ remove(key: string): void;
170
+ /**
171
+ * 清空所有值
172
+ */
173
+ clear(): void;
174
+ };
175
+
176
+ export { type StorageOptions, cookie, getStorageKeyPair, localStorage, sessionStorage, setStorageKeyPair, storage };