@alibarbar/common 1.0.9 → 1.0.10

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 (176) hide show
  1. package/dist/{chunk-O3O67R4I.js → algorithm.cjs} +0 -2
  2. package/dist/algorithm.js +130 -44
  3. package/dist/{chunk-LOAZSPGQ.js → array.cjs} +0 -2
  4. package/dist/array.js +135 -84
  5. package/dist/{chunk-Y364QIQH.js → color.cjs} +0 -2
  6. package/dist/color.js +127 -40
  7. package/dist/{chunk-DYBSRI7V.js → crypto.cjs} +0 -2
  8. package/dist/crypto.js +172 -60
  9. package/dist/{chunk-BHCRFURU.js → data-structure.cjs} +0 -2
  10. package/dist/data-structure.js +481 -32
  11. package/dist/{chunk-I3L42475.js → date.cjs} +0 -2
  12. package/dist/date.js +125 -72
  13. package/dist/{chunk-JK2SE3I2.js → dom.cjs} +0 -2
  14. package/dist/dom.js +84 -56
  15. package/dist/{chunk-7V5UQXIO.js → file.cjs} +0 -2
  16. package/dist/file.js +79 -32
  17. package/dist/{chunk-OX5PLOWB.js → i18n.cjs} +0 -2
  18. package/dist/i18n.js +78 -40
  19. package/dist/index.cjs +4132 -0
  20. package/dist/index.d.mts +3 -159
  21. package/dist/index.d.ts +3 -159
  22. package/dist/index.js +3364 -17427
  23. package/dist/{chunk-4RGXV4SJ.js → network.cjs} +0 -2
  24. package/dist/network.js +97 -28
  25. package/dist/{chunk-3FRYJPHG.js → number.cjs} +0 -2
  26. package/dist/number.js +77 -56
  27. package/dist/{chunk-27UDDVLZ.js → object.cjs} +0 -2
  28. package/dist/object.js +237 -80
  29. package/dist/{chunk-JQZBPAPO.js → performance.cjs} +0 -2
  30. package/dist/performance.js +145 -40
  31. package/dist/services.cjs +291 -0
  32. package/dist/services.d.mts +161 -0
  33. package/dist/services.d.ts +161 -0
  34. package/dist/services.js +281 -0
  35. package/dist/{chunk-WZDOPUJW.js → storage.cjs} +216 -17
  36. package/dist/storage.js +550 -31
  37. package/dist/{chunk-D7CS5EKF.js → string.cjs} +0 -2
  38. package/dist/string.js +91 -68
  39. package/dist/{chunk-56W6YECK.js → tracking.cjs} +0 -2
  40. package/dist/tracking.js +359 -52
  41. package/dist/{chunk-ZDMFMUDR.js → transform.cjs} +0 -2
  42. package/dist/transform.js +299 -32
  43. package/dist/{chunk-NJARVI6X.mjs → upload.cjs} +41 -14
  44. package/dist/upload.js +402 -20
  45. package/dist/{chunk-KGFTD255.js → url.cjs} +0 -2
  46. package/dist/url.js +91 -44
  47. package/dist/{chunk-TQN37HIN.js → validation.cjs} +0 -2
  48. package/dist/validation.js +77 -60
  49. package/package.json +7 -2
  50. package/dist/algorithm.js.map +0 -1
  51. package/dist/algorithm.mjs +0 -4
  52. package/dist/algorithm.mjs.map +0 -1
  53. package/dist/array.js.map +0 -1
  54. package/dist/array.mjs +0 -4
  55. package/dist/array.mjs.map +0 -1
  56. package/dist/chunk-27UDDVLZ.js.map +0 -1
  57. package/dist/chunk-2R2QWFJC.mjs +0 -138
  58. package/dist/chunk-2R2QWFJC.mjs.map +0 -1
  59. package/dist/chunk-3FRYJPHG.js.map +0 -1
  60. package/dist/chunk-4RGXV4SJ.js.map +0 -1
  61. package/dist/chunk-56W6YECK.js.map +0 -1
  62. package/dist/chunk-5BGSUGTI.mjs +0 -128
  63. package/dist/chunk-5BGSUGTI.mjs.map +0 -1
  64. package/dist/chunk-7E6GELHJ.mjs +0 -302
  65. package/dist/chunk-7E6GELHJ.mjs.map +0 -1
  66. package/dist/chunk-7V5UQXIO.js.map +0 -1
  67. package/dist/chunk-A4SWQXX7.mjs +0 -484
  68. package/dist/chunk-A4SWQXX7.mjs.map +0 -1
  69. package/dist/chunk-BHCRFURU.js.map +0 -1
  70. package/dist/chunk-CDSGEAOK.mjs +0 -80
  71. package/dist/chunk-CDSGEAOK.mjs.map +0 -1
  72. package/dist/chunk-D7CS5EKF.js.map +0 -1
  73. package/dist/chunk-DYBSRI7V.js.map +0 -1
  74. package/dist/chunk-FEBKPX5A.js +0 -386
  75. package/dist/chunk-FEBKPX5A.js.map +0 -1
  76. package/dist/chunk-FJ6ZGZIA.mjs +0 -39
  77. package/dist/chunk-FJ6ZGZIA.mjs.map +0 -1
  78. package/dist/chunk-HLDFI7R2.mjs +0 -175
  79. package/dist/chunk-HLDFI7R2.mjs.map +0 -1
  80. package/dist/chunk-I3L42475.js.map +0 -1
  81. package/dist/chunk-JBLX27WD.mjs +0 -240
  82. package/dist/chunk-JBLX27WD.mjs.map +0 -1
  83. package/dist/chunk-JHZ7M2MR.mjs +0 -133
  84. package/dist/chunk-JHZ7M2MR.mjs.map +0 -1
  85. package/dist/chunk-JK2SE3I2.js.map +0 -1
  86. package/dist/chunk-JQZBPAPO.js.map +0 -1
  87. package/dist/chunk-JXYGC2C5.mjs +0 -100
  88. package/dist/chunk-JXYGC2C5.mjs.map +0 -1
  89. package/dist/chunk-KGFTD255.js.map +0 -1
  90. package/dist/chunk-LBHBNPNJ.mjs +0 -148
  91. package/dist/chunk-LBHBNPNJ.mjs.map +0 -1
  92. package/dist/chunk-LF4CILQS.mjs +0 -87
  93. package/dist/chunk-LF4CILQS.mjs.map +0 -1
  94. package/dist/chunk-LOAZSPGQ.js.map +0 -1
  95. package/dist/chunk-NJARVI6X.mjs.map +0 -1
  96. package/dist/chunk-NSSDYX2U.mjs +0 -80
  97. package/dist/chunk-NSSDYX2U.mjs.map +0 -1
  98. package/dist/chunk-O3O67R4I.js.map +0 -1
  99. package/dist/chunk-OIXQ3E6W.mjs +0 -354
  100. package/dist/chunk-OIXQ3E6W.mjs.map +0 -1
  101. package/dist/chunk-OX5PLOWB.js.map +0 -1
  102. package/dist/chunk-PJ7UCTX4.mjs +0 -362
  103. package/dist/chunk-PJ7UCTX4.mjs.map +0 -1
  104. package/dist/chunk-PR4QN5HX.js +0 -44
  105. package/dist/chunk-PR4QN5HX.js.map +0 -1
  106. package/dist/chunk-QIBE7GVN.mjs +0 -81
  107. package/dist/chunk-QIBE7GVN.mjs.map +0 -1
  108. package/dist/chunk-QIOC54LQ.mjs +0 -130
  109. package/dist/chunk-QIOC54LQ.mjs.map +0 -1
  110. package/dist/chunk-TQN37HIN.js.map +0 -1
  111. package/dist/chunk-WZDOPUJW.js.map +0 -1
  112. package/dist/chunk-XJTZDXSR.mjs +0 -94
  113. package/dist/chunk-XJTZDXSR.mjs.map +0 -1
  114. package/dist/chunk-Y364QIQH.js.map +0 -1
  115. package/dist/chunk-YXM6Q4JS.mjs +0 -94
  116. package/dist/chunk-YXM6Q4JS.mjs.map +0 -1
  117. package/dist/chunk-ZDMFMUDR.js.map +0 -1
  118. package/dist/chunk-ZVJ6NQUM.mjs +0 -82
  119. package/dist/chunk-ZVJ6NQUM.mjs.map +0 -1
  120. package/dist/color.js.map +0 -1
  121. package/dist/color.mjs +0 -4
  122. package/dist/color.mjs.map +0 -1
  123. package/dist/crypto.js.map +0 -1
  124. package/dist/crypto.mjs +0 -4
  125. package/dist/crypto.mjs.map +0 -1
  126. package/dist/data-structure.js.map +0 -1
  127. package/dist/data-structure.mjs +0 -4
  128. package/dist/data-structure.mjs.map +0 -1
  129. package/dist/date.js.map +0 -1
  130. package/dist/date.mjs +0 -4
  131. package/dist/date.mjs.map +0 -1
  132. package/dist/dom.js.map +0 -1
  133. package/dist/dom.mjs +0 -4
  134. package/dist/dom.mjs.map +0 -1
  135. package/dist/file.js.map +0 -1
  136. package/dist/file.mjs +0 -4
  137. package/dist/file.mjs.map +0 -1
  138. package/dist/i18n.js.map +0 -1
  139. package/dist/i18n.mjs +0 -4
  140. package/dist/i18n.mjs.map +0 -1
  141. package/dist/index.js.map +0 -1
  142. package/dist/index.mjs +0 -17155
  143. package/dist/index.mjs.map +0 -1
  144. package/dist/network.js.map +0 -1
  145. package/dist/network.mjs +0 -4
  146. package/dist/network.mjs.map +0 -1
  147. package/dist/number.js.map +0 -1
  148. package/dist/number.mjs +0 -4
  149. package/dist/number.mjs.map +0 -1
  150. package/dist/object.js.map +0 -1
  151. package/dist/object.mjs +0 -4
  152. package/dist/object.mjs.map +0 -1
  153. package/dist/performance.js.map +0 -1
  154. package/dist/performance.mjs +0 -4
  155. package/dist/performance.mjs.map +0 -1
  156. package/dist/storage.js.map +0 -1
  157. package/dist/storage.mjs +0 -5
  158. package/dist/storage.mjs.map +0 -1
  159. package/dist/string.js.map +0 -1
  160. package/dist/string.mjs +0 -4
  161. package/dist/string.mjs.map +0 -1
  162. package/dist/tracking.js.map +0 -1
  163. package/dist/tracking.mjs +0 -4
  164. package/dist/tracking.mjs.map +0 -1
  165. package/dist/transform.js.map +0 -1
  166. package/dist/transform.mjs +0 -4
  167. package/dist/transform.mjs.map +0 -1
  168. package/dist/upload.js.map +0 -1
  169. package/dist/upload.mjs +0 -5
  170. package/dist/upload.mjs.map +0 -1
  171. package/dist/url.js.map +0 -1
  172. package/dist/url.mjs +0 -4
  173. package/dist/url.mjs.map +0 -1
  174. package/dist/validation.js.map +0 -1
  175. package/dist/validation.mjs +0 -4
  176. package/dist/validation.mjs.map +0 -1
@@ -1,33 +1,482 @@
1
- 'use strict';
1
+ // src/data/data-structure.ts
2
+ var Stack = class {
3
+ constructor() {
4
+ this.items = [];
5
+ }
6
+ /**
7
+ * 入栈
8
+ */
9
+ push(item) {
10
+ this.items.push(item);
11
+ }
12
+ /**
13
+ * 出栈
14
+ */
15
+ pop() {
16
+ return this.items.pop();
17
+ }
18
+ /**
19
+ * 查看栈顶元素
20
+ */
21
+ peek() {
22
+ return this.items[this.items.length - 1];
23
+ }
24
+ /**
25
+ * 判断栈是否为空
26
+ */
27
+ isEmpty() {
28
+ return this.items.length === 0;
29
+ }
30
+ /**
31
+ * 获取栈的大小
32
+ */
33
+ size() {
34
+ return this.items.length;
35
+ }
36
+ /**
37
+ * 清空栈
38
+ */
39
+ clear() {
40
+ this.items = [];
41
+ }
42
+ /**
43
+ * 转换为数组
44
+ */
45
+ toArray() {
46
+ return [...this.items];
47
+ }
48
+ };
49
+ var DataQueue = class {
50
+ constructor() {
51
+ this.items = [];
52
+ }
53
+ /**
54
+ * 入队
55
+ */
56
+ enqueue(item) {
57
+ this.items.push(item);
58
+ }
59
+ /**
60
+ * 出队
61
+ */
62
+ dequeue() {
63
+ return this.items.shift();
64
+ }
65
+ /**
66
+ * 查看队首元素
67
+ */
68
+ front() {
69
+ return this.items[0];
70
+ }
71
+ /**
72
+ * 判断队列是否为空
73
+ */
74
+ isEmpty() {
75
+ return this.items.length === 0;
76
+ }
77
+ /**
78
+ * 获取队列的大小
79
+ */
80
+ size() {
81
+ return this.items.length;
82
+ }
83
+ /**
84
+ * 清空队列
85
+ */
86
+ clear() {
87
+ this.items = [];
88
+ }
89
+ /**
90
+ * 转换为数组
91
+ */
92
+ toArray() {
93
+ return [...this.items];
94
+ }
95
+ };
96
+ var ListNode = class {
97
+ constructor(value) {
98
+ this.next = null;
99
+ this.value = value;
100
+ }
101
+ };
102
+ var LinkedList = class {
103
+ constructor() {
104
+ this.head = null;
105
+ this.length = 0;
106
+ }
107
+ /**
108
+ * 在链表末尾添加元素
109
+ */
110
+ append(value) {
111
+ const newNode = new ListNode(value);
112
+ if (!this.head) {
113
+ this.head = newNode;
114
+ } else {
115
+ let current = this.head;
116
+ while (current.next) {
117
+ current = current.next;
118
+ }
119
+ current.next = newNode;
120
+ }
121
+ this.length++;
122
+ }
123
+ /**
124
+ * 在指定位置插入元素
125
+ */
126
+ insert(index, value) {
127
+ if (index < 0 || index > this.length) {
128
+ return false;
129
+ }
130
+ const newNode = new ListNode(value);
131
+ if (index === 0) {
132
+ newNode.next = this.head;
133
+ this.head = newNode;
134
+ } else {
135
+ let current = this.head;
136
+ for (let i = 0; i < index - 1; i++) {
137
+ current = current.next;
138
+ }
139
+ newNode.next = current.next;
140
+ current.next = newNode;
141
+ }
142
+ this.length++;
143
+ return true;
144
+ }
145
+ /**
146
+ * 删除指定位置的元素
147
+ */
148
+ removeAt(index) {
149
+ if (index < 0 || index >= this.length || !this.head) {
150
+ return null;
151
+ }
152
+ let current = this.head;
153
+ if (index === 0) {
154
+ this.head = current.next;
155
+ this.length--;
156
+ return current.value;
157
+ }
158
+ for (let i = 0; i < index - 1; i++) {
159
+ current = current.next;
160
+ }
161
+ const removed = current.next;
162
+ current.next = removed.next;
163
+ this.length--;
164
+ return removed.value;
165
+ }
166
+ /**
167
+ * 查找元素索引
168
+ */
169
+ indexOf(value) {
170
+ let current = this.head;
171
+ let index = 0;
172
+ while (current) {
173
+ if (current.value === value) {
174
+ return index;
175
+ }
176
+ current = current.next;
177
+ index++;
178
+ }
179
+ return -1;
180
+ }
181
+ /**
182
+ * 获取指定位置的元素
183
+ */
184
+ get(index) {
185
+ if (index < 0 || index >= this.length || !this.head) {
186
+ return null;
187
+ }
188
+ let current = this.head;
189
+ for (let i = 0; i < index; i++) {
190
+ current = current.next;
191
+ }
192
+ return current.value;
193
+ }
194
+ /**
195
+ * 判断链表是否为空
196
+ */
197
+ isEmpty() {
198
+ return this.length === 0;
199
+ }
200
+ /**
201
+ * 获取链表长度
202
+ */
203
+ size() {
204
+ return this.length;
205
+ }
206
+ /**
207
+ * 转换为数组
208
+ */
209
+ toArray() {
210
+ const result = [];
211
+ let current = this.head;
212
+ while (current) {
213
+ result.push(current.value);
214
+ current = current.next;
215
+ }
216
+ return result;
217
+ }
218
+ };
219
+ var TreeNode = class {
220
+ constructor(value) {
221
+ this.left = null;
222
+ this.right = null;
223
+ this.value = value;
224
+ }
225
+ };
226
+ var BinaryTree = class {
227
+ constructor() {
228
+ this.root = null;
229
+ }
230
+ /**
231
+ * 插入节点
232
+ */
233
+ insert(value) {
234
+ const newNode = new TreeNode(value);
235
+ if (!this.root) {
236
+ this.root = newNode;
237
+ return;
238
+ }
239
+ this.insertNode(this.root, newNode);
240
+ }
241
+ insertNode(node, newNode) {
242
+ if (newNode.value <= node.value) {
243
+ if (!node.left) {
244
+ node.left = newNode;
245
+ } else {
246
+ this.insertNode(node.left, newNode);
247
+ }
248
+ } else {
249
+ if (!node.right) {
250
+ node.right = newNode;
251
+ } else {
252
+ this.insertNode(node.right, newNode);
253
+ }
254
+ }
255
+ }
256
+ /**
257
+ * 查找节点
258
+ */
259
+ search(value) {
260
+ return this.searchNode(this.root, value);
261
+ }
262
+ searchNode(node, value) {
263
+ if (!node) {
264
+ return false;
265
+ }
266
+ if (value === node.value) {
267
+ return true;
268
+ }
269
+ if (value < node.value) {
270
+ return this.searchNode(node.left, value);
271
+ }
272
+ return this.searchNode(node.right, value);
273
+ }
274
+ /**
275
+ * 中序遍历
276
+ */
277
+ inOrder() {
278
+ const result = [];
279
+ this.inOrderTraverse(this.root, result);
280
+ return result;
281
+ }
282
+ inOrderTraverse(node, result) {
283
+ if (node) {
284
+ this.inOrderTraverse(node.left, result);
285
+ result.push(node.value);
286
+ this.inOrderTraverse(node.right, result);
287
+ }
288
+ }
289
+ /**
290
+ * 前序遍历
291
+ */
292
+ preOrder() {
293
+ const result = [];
294
+ this.preOrderTraverse(this.root, result);
295
+ return result;
296
+ }
297
+ preOrderTraverse(node, result) {
298
+ if (node) {
299
+ result.push(node.value);
300
+ this.preOrderTraverse(node.left, result);
301
+ this.preOrderTraverse(node.right, result);
302
+ }
303
+ }
304
+ /**
305
+ * 后序遍历
306
+ */
307
+ postOrder() {
308
+ const result = [];
309
+ this.postOrderTraverse(this.root, result);
310
+ return result;
311
+ }
312
+ postOrderTraverse(node, result) {
313
+ if (node) {
314
+ this.postOrderTraverse(node.left, result);
315
+ this.postOrderTraverse(node.right, result);
316
+ result.push(node.value);
317
+ }
318
+ }
319
+ };
320
+ var Graph = class {
321
+ constructor() {
322
+ this.vertices = /* @__PURE__ */ new Map();
323
+ }
324
+ /**
325
+ * 添加顶点
326
+ */
327
+ addVertex(vertex) {
328
+ if (!this.vertices.has(vertex)) {
329
+ this.vertices.set(vertex, []);
330
+ }
331
+ }
332
+ /**
333
+ * 添加边(无向图)
334
+ */
335
+ addEdge(vertex1, vertex2) {
336
+ if (!this.vertices.has(vertex1)) {
337
+ this.addVertex(vertex1);
338
+ }
339
+ if (!this.vertices.has(vertex2)) {
340
+ this.addVertex(vertex2);
341
+ }
342
+ const neighbors1 = this.vertices.get(vertex1);
343
+ const neighbors2 = this.vertices.get(vertex2);
344
+ if (!neighbors1.includes(vertex2)) {
345
+ neighbors1.push(vertex2);
346
+ }
347
+ if (!neighbors2.includes(vertex1)) {
348
+ neighbors2.push(vertex1);
349
+ }
350
+ }
351
+ /**
352
+ * 获取顶点的邻居
353
+ */
354
+ getNeighbors(vertex) {
355
+ return this.vertices.get(vertex) || [];
356
+ }
357
+ /**
358
+ * 深度优先搜索
359
+ */
360
+ dfs(start, callback) {
361
+ const visited = /* @__PURE__ */ new Set();
362
+ const result = [];
363
+ const dfsVisit = (vertex) => {
364
+ visited.add(vertex);
365
+ result.push(vertex);
366
+ if (callback) {
367
+ callback(vertex);
368
+ }
369
+ const neighbors = this.getNeighbors(vertex);
370
+ for (const neighbor of neighbors) {
371
+ if (!visited.has(neighbor)) {
372
+ dfsVisit(neighbor);
373
+ }
374
+ }
375
+ };
376
+ dfsVisit(start);
377
+ return result;
378
+ }
379
+ /**
380
+ * 广度优先搜索
381
+ */
382
+ bfs(start, callback) {
383
+ const visited = /* @__PURE__ */ new Set();
384
+ const queue = [start];
385
+ const result = [];
386
+ visited.add(start);
387
+ while (queue.length > 0) {
388
+ const vertex = queue.shift();
389
+ result.push(vertex);
390
+ if (callback) {
391
+ callback(vertex);
392
+ }
393
+ const neighbors = this.getNeighbors(vertex);
394
+ for (const neighbor of neighbors) {
395
+ if (!visited.has(neighbor)) {
396
+ visited.add(neighbor);
397
+ queue.push(neighbor);
398
+ }
399
+ }
400
+ }
401
+ return result;
402
+ }
403
+ /**
404
+ * 获取所有顶点
405
+ */
406
+ getVertices() {
407
+ return Array.from(this.vertices.keys());
408
+ }
409
+ };
410
+ var LRUCache = class {
411
+ constructor(capacity) {
412
+ if (capacity <= 0) {
413
+ throw new Error("Capacity must be greater than 0");
414
+ }
415
+ this.capacity = capacity;
416
+ this.cache = /* @__PURE__ */ new Map();
417
+ }
418
+ /**
419
+ * 获取值
420
+ */
421
+ get(key) {
422
+ if (!this.cache.has(key)) {
423
+ return void 0;
424
+ }
425
+ const value = this.cache.get(key);
426
+ this.cache.delete(key);
427
+ this.cache.set(key, value);
428
+ return value;
429
+ }
430
+ /**
431
+ * 设置值
432
+ */
433
+ set(key, value) {
434
+ if (this.cache.has(key)) {
435
+ this.cache.delete(key);
436
+ } else if (this.cache.size >= this.capacity) {
437
+ const firstKey = this.cache.keys().next().value;
438
+ if (firstKey !== void 0) {
439
+ this.cache.delete(firstKey);
440
+ }
441
+ }
442
+ this.cache.set(key, value);
443
+ }
444
+ /**
445
+ * 删除键
446
+ */
447
+ delete(key) {
448
+ return this.cache.delete(key);
449
+ }
450
+ /**
451
+ * 清空缓存
452
+ */
453
+ clear() {
454
+ this.cache.clear();
455
+ }
456
+ /**
457
+ * 判断是否包含键
458
+ */
459
+ has(key) {
460
+ return this.cache.has(key);
461
+ }
462
+ /**
463
+ * 获取缓存大小
464
+ */
465
+ size() {
466
+ return this.cache.size;
467
+ }
468
+ /**
469
+ * 获取所有键
470
+ */
471
+ keys() {
472
+ return Array.from(this.cache.keys()).filter((key) => key !== void 0);
473
+ }
474
+ /**
475
+ * 获取所有值
476
+ */
477
+ values() {
478
+ return Array.from(this.cache.values());
479
+ }
480
+ };
2
481
 
3
- var chunkBHCRFURU_js = require('./chunk-BHCRFURU.js');
4
- require('./chunk-PR4QN5HX.js');
5
-
6
-
7
-
8
- Object.defineProperty(exports, "BinaryTree", {
9
- enumerable: true,
10
- get: function () { return chunkBHCRFURU_js.BinaryTree; }
11
- });
12
- Object.defineProperty(exports, "DataQueue", {
13
- enumerable: true,
14
- get: function () { return chunkBHCRFURU_js.DataQueue; }
15
- });
16
- Object.defineProperty(exports, "Graph", {
17
- enumerable: true,
18
- get: function () { return chunkBHCRFURU_js.Graph; }
19
- });
20
- Object.defineProperty(exports, "LRUCache", {
21
- enumerable: true,
22
- get: function () { return chunkBHCRFURU_js.LRUCache; }
23
- });
24
- Object.defineProperty(exports, "LinkedList", {
25
- enumerable: true,
26
- get: function () { return chunkBHCRFURU_js.LinkedList; }
27
- });
28
- Object.defineProperty(exports, "Stack", {
29
- enumerable: true,
30
- get: function () { return chunkBHCRFURU_js.Stack; }
31
- });
32
- //# sourceMappingURL=data-structure.js.map
33
- //# sourceMappingURL=data-structure.js.map
482
+ export { BinaryTree, DataQueue, Graph, LRUCache, LinkedList, Stack };
@@ -141,5 +141,3 @@ exports.isWeekday = isWeekday;
141
141
  exports.isWeekend = isWeekend;
142
142
  exports.isYesterday = isYesterday;
143
143
  exports.startOfDay = startOfDay;
144
- //# sourceMappingURL=chunk-I3L42475.js.map
145
- //# sourceMappingURL=chunk-I3L42475.js.map
package/dist/date.js CHANGED
@@ -1,73 +1,126 @@
1
- 'use strict';
1
+ // src/core/date.ts
2
+ function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
3
+ const d = typeof date === "number" ? new Date(date) : date;
4
+ const year = d.getFullYear();
5
+ const month = String(d.getMonth() + 1).padStart(2, "0");
6
+ const day = String(d.getDate()).padStart(2, "0");
7
+ const hours = String(d.getHours()).padStart(2, "0");
8
+ const minutes = String(d.getMinutes()).padStart(2, "0");
9
+ const seconds = String(d.getSeconds()).padStart(2, "0");
10
+ return format.replace("YYYY", String(year)).replace("MM", month).replace("DD", day).replace("HH", hours).replace("mm", minutes).replace("ss", seconds);
11
+ }
12
+ function getRelativeTime(date) {
13
+ const now = /* @__PURE__ */ new Date();
14
+ const target = typeof date === "number" ? new Date(date) : date;
15
+ const diff = now.getTime() - target.getTime();
16
+ const seconds = Math.floor(diff / 1e3);
17
+ const minutes = Math.floor(seconds / 60);
18
+ const hours = Math.floor(minutes / 60);
19
+ const days = Math.floor(hours / 24);
20
+ const months = Math.floor(days / 30);
21
+ const years = Math.floor(days / 365);
22
+ if (years > 0) return `${years}\u5E74\u524D`;
23
+ if (months > 0) return `${months}\u4E2A\u6708\u524D`;
24
+ if (days > 0) return `${days}\u5929\u524D`;
25
+ if (hours > 0) return `${hours}\u5C0F\u65F6\u524D`;
26
+ if (minutes > 0) return `${minutes}\u5206\u949F\u524D`;
27
+ if (seconds > 0) return `${seconds}\u79D2\u524D`;
28
+ return "\u521A\u521A";
29
+ }
30
+ function isToday(date) {
31
+ const d = typeof date === "number" ? new Date(date) : date;
32
+ const today = /* @__PURE__ */ new Date();
33
+ return d.getDate() === today.getDate() && d.getMonth() === today.getMonth() && d.getFullYear() === today.getFullYear();
34
+ }
35
+ function isYesterday(date) {
36
+ const d = typeof date === "number" ? new Date(date) : date;
37
+ const yesterday = /* @__PURE__ */ new Date();
38
+ yesterday.setDate(yesterday.getDate() - 1);
39
+ return d.getDate() === yesterday.getDate() && d.getMonth() === yesterday.getMonth() && d.getFullYear() === yesterday.getFullYear();
40
+ }
41
+ function getTimeFromGMT(gmt) {
42
+ const now = /* @__PURE__ */ new Date();
43
+ const localOffset = now.getTimezoneOffset();
44
+ const gmtOffsetMinutes = gmt * 60;
45
+ const targetTime = new Date(now.getTime() + localOffset * 6e4 + gmtOffsetMinutes * 6e4);
46
+ const format = getDateFormatByGMT(gmt);
47
+ return formatDate(targetTime, format);
48
+ }
49
+ function getDateFormatByGMT(gmt) {
50
+ switch (gmt) {
51
+ case 0:
52
+ return "YYYY-MM-DD HH:mm:ss";
53
+ case 1:
54
+ case 2:
55
+ case 3:
56
+ return "YYYY-MM-DD HH:mm:ss";
57
+ case 8:
58
+ return "YYYY-MM-DD HH:mm:ss";
59
+ case 9:
60
+ return "YYYY-MM-DD HH:mm:ss";
61
+ case -5:
62
+ case -6:
63
+ case -7:
64
+ case -8:
65
+ return "MM/DD/YYYY HH:mm:ss";
66
+ default:
67
+ return "YYYY-MM-DD HH:mm:ss";
68
+ }
69
+ }
70
+ function addDays(date, days) {
71
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
72
+ d.setDate(d.getDate() + days);
73
+ return d;
74
+ }
75
+ function addMonths(date, months) {
76
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
77
+ d.setMonth(d.getMonth() + months);
78
+ return d;
79
+ }
80
+ function addYears(date, years) {
81
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
82
+ d.setFullYear(d.getFullYear() + years);
83
+ return d;
84
+ }
85
+ function diffDays(date1, date2) {
86
+ const d1 = typeof date1 === "number" ? new Date(date1) : date1;
87
+ const d2 = typeof date2 === "number" ? new Date(date2) : date2;
88
+ const diff = d1.getTime() - d2.getTime();
89
+ return Math.floor(diff / (1e3 * 60 * 60 * 24));
90
+ }
91
+ function startOfDay(date) {
92
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
93
+ d.setHours(0, 0, 0, 0);
94
+ return d;
95
+ }
96
+ function endOfDay(date) {
97
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
98
+ d.setHours(23, 59, 59, 999);
99
+ return d;
100
+ }
101
+ function isWeekend(date) {
102
+ const d = typeof date === "number" ? new Date(date) : date;
103
+ const day = d.getDay();
104
+ return day === 0 || day === 6;
105
+ }
106
+ function isWeekday(date) {
107
+ return !isWeekend(date);
108
+ }
109
+ function getWeekNumber(date) {
110
+ const d = typeof date === "number" ? new Date(date) : new Date(date);
111
+ const target = new Date(d.valueOf());
112
+ const dayNr = (d.getDay() + 6) % 7;
113
+ target.setDate(target.getDate() - dayNr + 3);
114
+ const firstThursday = target.valueOf();
115
+ target.setMonth(0, 1);
116
+ if (target.getDay() !== 4) {
117
+ target.setMonth(0, 1 + (4 - target.getDay() + 7) % 7);
118
+ }
119
+ return 1 + Math.ceil((firstThursday - target.valueOf()) / 6048e5);
120
+ }
121
+ function getQuarter(date) {
122
+ const d = typeof date === "number" ? new Date(date) : date;
123
+ return Math.floor(d.getMonth() / 3) + 1;
124
+ }
2
125
 
3
- var chunkI3L42475_js = require('./chunk-I3L42475.js');
4
- require('./chunk-PR4QN5HX.js');
5
-
6
-
7
-
8
- Object.defineProperty(exports, "addDays", {
9
- enumerable: true,
10
- get: function () { return chunkI3L42475_js.addDays; }
11
- });
12
- Object.defineProperty(exports, "addMonths", {
13
- enumerable: true,
14
- get: function () { return chunkI3L42475_js.addMonths; }
15
- });
16
- Object.defineProperty(exports, "addYears", {
17
- enumerable: true,
18
- get: function () { return chunkI3L42475_js.addYears; }
19
- });
20
- Object.defineProperty(exports, "diffDays", {
21
- enumerable: true,
22
- get: function () { return chunkI3L42475_js.diffDays; }
23
- });
24
- Object.defineProperty(exports, "endOfDay", {
25
- enumerable: true,
26
- get: function () { return chunkI3L42475_js.endOfDay; }
27
- });
28
- Object.defineProperty(exports, "formatDate", {
29
- enumerable: true,
30
- get: function () { return chunkI3L42475_js.formatDate; }
31
- });
32
- Object.defineProperty(exports, "getDateFormatByGMT", {
33
- enumerable: true,
34
- get: function () { return chunkI3L42475_js.getDateFormatByGMT; }
35
- });
36
- Object.defineProperty(exports, "getQuarter", {
37
- enumerable: true,
38
- get: function () { return chunkI3L42475_js.getQuarter; }
39
- });
40
- Object.defineProperty(exports, "getRelativeTime", {
41
- enumerable: true,
42
- get: function () { return chunkI3L42475_js.getRelativeTime; }
43
- });
44
- Object.defineProperty(exports, "getTimeFromGMT", {
45
- enumerable: true,
46
- get: function () { return chunkI3L42475_js.getTimeFromGMT; }
47
- });
48
- Object.defineProperty(exports, "getWeekNumber", {
49
- enumerable: true,
50
- get: function () { return chunkI3L42475_js.getWeekNumber; }
51
- });
52
- Object.defineProperty(exports, "isToday", {
53
- enumerable: true,
54
- get: function () { return chunkI3L42475_js.isToday; }
55
- });
56
- Object.defineProperty(exports, "isWeekday", {
57
- enumerable: true,
58
- get: function () { return chunkI3L42475_js.isWeekday; }
59
- });
60
- Object.defineProperty(exports, "isWeekend", {
61
- enumerable: true,
62
- get: function () { return chunkI3L42475_js.isWeekend; }
63
- });
64
- Object.defineProperty(exports, "isYesterday", {
65
- enumerable: true,
66
- get: function () { return chunkI3L42475_js.isYesterday; }
67
- });
68
- Object.defineProperty(exports, "startOfDay", {
69
- enumerable: true,
70
- get: function () { return chunkI3L42475_js.startOfDay; }
71
- });
72
- //# sourceMappingURL=date.js.map
73
- //# sourceMappingURL=date.js.map
126
+ export { addDays, addMonths, addYears, diffDays, endOfDay, formatDate, getDateFormatByGMT, getQuarter, getRelativeTime, getTimeFromGMT, getWeekNumber, isToday, isWeekday, isWeekend, isYesterday, startOfDay };
@@ -96,5 +96,3 @@ exports.removeClass = removeClass;
96
96
  exports.scrollTo = scrollTo;
97
97
  exports.setStyle = setStyle;
98
98
  exports.toggleClass = toggleClass;
99
- //# sourceMappingURL=chunk-JK2SE3I2.js.map
100
- //# sourceMappingURL=chunk-JK2SE3I2.js.map