@taicode/common-base 3.0.1 → 3.1.1

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 (87) hide show
  1. package/output/batching-buffer/batching-buffer.test.js +1 -1
  2. package/output/batching-buffer/index.d.ts +2 -2
  3. package/output/batching-buffer/index.d.ts.map +1 -1
  4. package/output/batching-buffer/index.js +1 -1
  5. package/output/catch/catch.test.js +1 -1
  6. package/output/catch/index.d.ts +1 -1
  7. package/output/catch/index.d.ts.map +1 -1
  8. package/output/catch/index.js +1 -1
  9. package/output/color/color.d.ts.map +1 -1
  10. package/output/color/color.js +0 -1
  11. package/output/color/color.test.js +1 -1
  12. package/output/color/index.d.ts +1 -1
  13. package/output/color/index.d.ts.map +1 -1
  14. package/output/color/index.js +1 -1
  15. package/output/debounce/debounce.test.js +1 -1
  16. package/output/debounce/index.d.ts +1 -1
  17. package/output/debounce/index.d.ts.map +1 -1
  18. package/output/debounce/index.js +1 -1
  19. package/output/disposer/disposer.d.ts +4 -2
  20. package/output/disposer/disposer.d.ts.map +1 -1
  21. package/output/disposer/disposer.js +7 -5
  22. package/output/disposer/disposer.test.js +73 -49
  23. package/output/disposer/index.d.ts +1 -1
  24. package/output/disposer/index.d.ts.map +1 -1
  25. package/output/disposer/index.js +1 -1
  26. package/output/error/error.test.js +1 -1
  27. package/output/error/index.d.ts +2 -2
  28. package/output/error/index.d.ts.map +1 -1
  29. package/output/error/index.js +1 -1
  30. package/output/event-emitter/event-emitter.test.js +1 -1
  31. package/output/event-emitter/index.d.ts +1 -1
  32. package/output/event-emitter/index.d.ts.map +1 -1
  33. package/output/event-emitter/index.js +1 -1
  34. package/output/flow-queue/flow-queue.d.ts.map +1 -1
  35. package/output/flow-queue/flow-queue.js +4 -5
  36. package/output/flow-queue/flow-queue.test.js +7 -6
  37. package/output/flow-queue/index.d.ts +2 -2
  38. package/output/flow-queue/index.d.ts.map +1 -1
  39. package/output/flow-queue/index.js +1 -1
  40. package/output/index.d.ts +17 -17
  41. package/output/index.d.ts.map +1 -1
  42. package/output/index.js +17 -17
  43. package/output/logger/formatter.js +1 -1
  44. package/output/logger/formatter.test.js +3 -3
  45. package/output/logger/index.d.ts +3 -3
  46. package/output/logger/index.d.ts.map +1 -1
  47. package/output/logger/index.js +3 -3
  48. package/output/logger/logger.d.ts +2 -2
  49. package/output/logger/logger.d.ts.map +1 -1
  50. package/output/logger/logger.js +1 -1
  51. package/output/logger/logger.test.js +4 -4
  52. package/output/logger/transport.d.ts +1 -1
  53. package/output/logger/transport.d.ts.map +1 -1
  54. package/output/logger/transport.js +1 -1
  55. package/output/logger/transport.test.js +2 -2
  56. package/output/lru-cache/index.d.ts +1 -1
  57. package/output/lru-cache/index.d.ts.map +1 -1
  58. package/output/lru-cache/index.js +1 -1
  59. package/output/lru-cache/lru-cache.test.js +1 -1
  60. package/output/number/index.d.ts +1 -1
  61. package/output/number/index.d.ts.map +1 -1
  62. package/output/number/index.js +1 -1
  63. package/output/number/number.test.js +1 -1
  64. package/output/object/index.d.ts +1 -1
  65. package/output/object/index.d.ts.map +1 -1
  66. package/output/object/index.js +1 -1
  67. package/output/object/object.test.js +1 -1
  68. package/output/ring-cache/index.d.ts +1 -1
  69. package/output/ring-cache/index.d.ts.map +1 -1
  70. package/output/ring-cache/index.js +1 -1
  71. package/output/ring-cache/ring-cache.test.js +5 -4
  72. package/output/service/index.d.ts +1 -1
  73. package/output/service/index.d.ts.map +1 -1
  74. package/output/service/index.js +1 -1
  75. package/output/string/index.d.ts +1 -1
  76. package/output/string/index.d.ts.map +1 -1
  77. package/output/string/index.js +1 -1
  78. package/output/string/string.test.js +1 -1
  79. package/output/throttle/index.d.ts +1 -1
  80. package/output/throttle/index.d.ts.map +1 -1
  81. package/output/throttle/index.js +1 -1
  82. package/output/throttle/throttle.test.js +1 -1
  83. package/output/ttl-cache/index.d.ts +1 -1
  84. package/output/ttl-cache/index.d.ts.map +1 -1
  85. package/output/ttl-cache/index.js +1 -1
  86. package/output/ttl-cache/ttl-cache.test.js +1 -1
  87. package/package.json +10 -8
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { BatchingBuffer } from './batching-buffer';
2
+ import { BatchingBuffer } from './batching-buffer.js';
3
3
  describe('BatchingBuffer', () => {
4
4
  let batchProcessor;
5
5
  let itemProcessor;
@@ -1,3 +1,3 @@
1
- export { BatchingBuffer } from './batching-buffer';
2
- export type { BatchingBufferOptions } from './batching-buffer';
1
+ export { BatchingBuffer } from './batching-buffer.js';
2
+ export type { BatchingBufferOptions } from './batching-buffer.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/batching-buffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,YAAY,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/batching-buffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,YAAY,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -1 +1 @@
1
- export { BatchingBuffer } from './batching-buffer';
1
+ export { BatchingBuffer } from './batching-buffer.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { catchIt } from './catch';
2
+ import { catchIt } from './catch.js';
3
3
  describe('catchIt', () => {
4
4
  it('同步函数返回值应为 value,error 为 undefined,isError 为 false', async () => {
5
5
  const result = await catchIt(() => 123);
@@ -1,2 +1,2 @@
1
- export * from './catch';
1
+ export * from './catch.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/catch/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/catch/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -1 +1 @@
1
- export * from './catch';
1
+ export * from './catch.js';
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../source/color/color.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAcvC,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,IAMpC,QAAQ,SAAS,EAAE,QAAO,MAAY,YAO/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAO/E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAgBrE,OAAO,MAAM,KAAG,MAAM,CAgB/B;AAED,YAAY,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../source/color/color.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;AAcvC,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,IAMpC,QAAQ,SAAS,EAAE,QAAO,MAAY,YAM/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAO/E;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,IAgBrE,OAAO,MAAM,KAAG,MAAM,CAgB/B;AAED,YAAY,EAAE,SAAS,EAAE,CAAA"}
@@ -14,7 +14,6 @@ export function getRandomColor(seed) {
14
14
  const lightness = 45; // 明度(0-100)
15
15
  return (offset, range = 360) => {
16
16
  const normalizedOffset = normalizeSeed(offset);
17
- console.log('normalizedOffset', offset, normalizedOffset);
18
17
  const finalHue = (hue + normalizedOffset) % range;
19
18
  return `hsl(${finalHue}, ${saturation}%, ${lightness}%)`;
20
19
  };
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { getRandomColor, getRandomColors, interpolateColors } from './color';
2
+ import { getRandomColor, getRandomColors, interpolateColors } from './color.js';
3
3
  describe('getRandomColor 函数', () => {
4
4
  // Mock console.log to avoid noise in tests
5
5
  beforeEach(() => {
@@ -1,2 +1,2 @@
1
- export * from './color';
1
+ export * from './color.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/color/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
@@ -1 +1 @@
1
- export * from './color';
1
+ export * from './color.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { debounce, debounceFn } from './debounce';
2
+ import { debounce, debounceFn } from './debounce.js';
3
3
  describe('debounce', () => {
4
4
  beforeEach(() => {
5
5
  vi.useFakeTimers();
@@ -1,2 +1,2 @@
1
- export * from './debounce';
1
+ export * from './debounce.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/debounce/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/debounce/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -1 +1 @@
1
- export * from './debounce';
1
+ export * from './debounce.js';
@@ -1,6 +1,8 @@
1
+ type CleanupFunction = () => unknown | Promise<unknown>;
1
2
  export declare class Disposer {
2
3
  private cleanupFunctions;
3
- addDisposer(cleanupFn: () => unknown): void;
4
- dispose(): void;
4
+ addDisposer(cleanupFn: CleanupFunction): void;
5
+ dispose(): Promise<void>;
5
6
  }
7
+ export {};
6
8
  //# sourceMappingURL=disposer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"disposer.d.ts","sourceRoot":"","sources":["../../source/disposer/disposer.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,gBAAgB,CAAyB;IAGjD,WAAW,CAAC,SAAS,EAAE,MAAM,OAAO,GAAG,IAAI;IAK3C,OAAO,IAAI,IAAI;CAUhB"}
1
+ {"version":3,"file":"disposer.d.ts","sourceRoot":"","sources":["../../source/disposer/disposer.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEvD,qBAAa,QAAQ;IACnB,OAAO,CAAC,gBAAgB,CAAwB;IAGhD,WAAW,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI;IAKvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAY/B"}
@@ -1,3 +1,4 @@
1
+ import { logger } from '../logger/index.js';
1
2
  export class Disposer {
2
3
  cleanupFunctions = [];
3
4
  // 添加清理函数
@@ -5,15 +6,16 @@ export class Disposer {
5
6
  this.cleanupFunctions.push(cleanupFn);
6
7
  }
7
8
  // 执行所有清理函数
8
- dispose() {
9
- for (const cleanupFn of this.cleanupFunctions) {
9
+ async dispose() {
10
+ const cleanupFunctions = this.cleanupFunctions;
11
+ this.cleanupFunctions = [];
12
+ for (const cleanupFn of cleanupFunctions) {
10
13
  try {
11
- cleanupFn();
14
+ await cleanupFn();
12
15
  }
13
16
  catch (error) {
14
- console.error('Error during cleanup:', error);
17
+ logger.error('Error during cleanup:', error);
15
18
  }
16
19
  }
17
- this.cleanupFunctions = []; // 清空清理函数列表
18
20
  }
19
21
  }
@@ -1,5 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { Disposer } from './disposer';
2
+ import { Disposer } from './disposer.js';
3
+ import { logger } from '../logger/index.js';
3
4
  describe('Disposer', () => {
4
5
  let disposer;
5
6
  beforeEach(() => {
@@ -12,19 +13,19 @@ describe('Disposer', () => {
12
13
  disposer.addDisposer(cleanupFn);
13
14
  }).not.toThrow();
14
15
  });
15
- it('应该能够添加多个清理函数', () => {
16
+ it('应该能够添加多个清理函数', async () => {
16
17
  const cleanupFn1 = vi.fn();
17
18
  const cleanupFn2 = vi.fn();
18
19
  const cleanupFn3 = vi.fn();
19
20
  disposer.addDisposer(cleanupFn1);
20
21
  disposer.addDisposer(cleanupFn2);
21
22
  disposer.addDisposer(cleanupFn3);
22
- disposer.dispose();
23
+ await disposer.dispose();
23
24
  expect(cleanupFn1).toHaveBeenCalledOnce();
24
25
  expect(cleanupFn2).toHaveBeenCalledOnce();
25
26
  expect(cleanupFn3).toHaveBeenCalledOnce();
26
27
  });
27
- it('应该能够添加返回不同类型的清理函数', () => {
28
+ it('应该能够添加返回不同类型的清理函数', async () => {
28
29
  const voidFn = vi.fn(() => { });
29
30
  const stringFn = vi.fn(() => 'cleanup result');
30
31
  const numberFn = vi.fn(() => 42);
@@ -33,7 +34,7 @@ describe('Disposer', () => {
33
34
  disposer.addDisposer(stringFn);
34
35
  disposer.addDisposer(numberFn);
35
36
  disposer.addDisposer(promiseFn);
36
- disposer.dispose();
37
+ await disposer.dispose();
37
38
  expect(voidFn).toHaveBeenCalled();
38
39
  expect(stringFn).toHaveBeenCalled();
39
40
  expect(numberFn).toHaveBeenCalled();
@@ -41,111 +42,124 @@ describe('Disposer', () => {
41
42
  });
42
43
  });
43
44
  describe('dispose', () => {
44
- it('应该执行所有清理函数', () => {
45
+ it('应该执行所有清理函数', async () => {
45
46
  const cleanupFn1 = vi.fn();
46
47
  const cleanupFn2 = vi.fn();
47
48
  const cleanupFn3 = vi.fn();
48
49
  disposer.addDisposer(cleanupFn1);
49
50
  disposer.addDisposer(cleanupFn2);
50
51
  disposer.addDisposer(cleanupFn3);
51
- disposer.dispose();
52
+ await disposer.dispose();
52
53
  expect(cleanupFn1).toHaveBeenCalledOnce();
53
54
  expect(cleanupFn2).toHaveBeenCalledOnce();
54
55
  expect(cleanupFn3).toHaveBeenCalledOnce();
55
56
  });
56
- it('应该按添加顺序执行清理函数', () => {
57
+ it('应该按添加顺序执行清理函数', async () => {
57
58
  const executionOrder = [];
58
59
  disposer.addDisposer(() => executionOrder.push(1));
59
60
  disposer.addDisposer(() => executionOrder.push(2));
60
61
  disposer.addDisposer(() => executionOrder.push(3));
61
- disposer.dispose();
62
+ await disposer.dispose();
62
63
  expect(executionOrder).toEqual([1, 2, 3]);
63
64
  });
64
- it('应该处理清理函数中的错误', () => {
65
+ it('应该按添加顺序执行异步清理函数', async () => {
66
+ const executionOrder = [];
67
+ disposer.addDisposer(async () => {
68
+ await Promise.resolve();
69
+ executionOrder.push(1);
70
+ });
71
+ disposer.addDisposer(async () => {
72
+ await Promise.resolve();
73
+ executionOrder.push(2);
74
+ });
75
+ disposer.addDisposer(async () => {
76
+ await Promise.resolve();
77
+ executionOrder.push(3);
78
+ });
79
+ await disposer.dispose();
80
+ expect(executionOrder).toEqual([1, 2, 3]);
81
+ });
82
+ it('应该处理清理函数中的错误', async () => {
65
83
  const workingFn1 = vi.fn();
66
84
  const errorFn = vi.fn(() => {
67
85
  throw new Error('Cleanup error');
68
86
  });
69
87
  const workingFn2 = vi.fn();
70
- // 模拟 console.error
71
- const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
88
+ // 模拟 logger.error
89
+ const loggerErrorSpy = vi.spyOn(logger, 'error').mockImplementation(() => { });
72
90
  disposer.addDisposer(workingFn1);
73
91
  disposer.addDisposer(errorFn);
74
92
  disposer.addDisposer(workingFn2);
75
93
  // dispose 不应该抛出错误
76
- expect(() => {
77
- disposer.dispose();
78
- }).not.toThrow();
94
+ await expect(disposer.dispose()).resolves.toBeUndefined();
79
95
  // 所有函数都应该被调用
80
96
  expect(workingFn1).toHaveBeenCalled();
81
97
  expect(errorFn).toHaveBeenCalled();
82
98
  expect(workingFn2).toHaveBeenCalled();
83
99
  // 错误应该被记录
84
- expect(consoleSpy).toHaveBeenCalledWith('Error during cleanup:', expect.any(Error));
85
- consoleSpy.mockRestore();
100
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Error during cleanup:', expect.any(Error));
101
+ loggerErrorSpy.mockRestore();
86
102
  });
87
- it('应该在执行后清空清理函数列表', () => {
103
+ it('应该在执行后清空清理函数列表', async () => {
88
104
  const cleanupFn = vi.fn();
89
105
  disposer.addDisposer(cleanupFn);
90
- disposer.dispose();
106
+ await disposer.dispose();
91
107
  expect(cleanupFn).toHaveBeenCalledOnce();
92
108
  // 再次调用 dispose 不应该执行任何函数
93
- disposer.dispose();
109
+ await disposer.dispose();
94
110
  expect(cleanupFn).toHaveBeenCalledOnce();
95
111
  });
96
- it('应该能够在清空后重新添加清理函数', () => {
112
+ it('应该能够在清空后重新添加清理函数', async () => {
97
113
  const firstCleanup = vi.fn();
98
114
  const secondCleanup = vi.fn();
99
115
  disposer.addDisposer(firstCleanup);
100
- disposer.dispose();
116
+ await disposer.dispose();
101
117
  disposer.addDisposer(secondCleanup);
102
- disposer.dispose();
118
+ await disposer.dispose();
103
119
  expect(firstCleanup).toHaveBeenCalledOnce();
104
120
  expect(secondCleanup).toHaveBeenCalledOnce();
105
121
  });
106
- it('应该在没有清理函数时安全执行', () => {
107
- expect(() => {
108
- disposer.dispose();
109
- }).not.toThrow();
122
+ it('应该在没有清理函数时安全执行', async () => {
123
+ await expect(disposer.dispose()).resolves.toBeUndefined();
110
124
  });
111
- it('应该能够多次调用 dispose', () => {
125
+ it('应该能够多次调用 dispose', async () => {
112
126
  const cleanupFn = vi.fn();
113
127
  disposer.addDisposer(cleanupFn);
114
- disposer.dispose();
115
- disposer.dispose();
116
- disposer.dispose();
128
+ await disposer.dispose();
129
+ await disposer.dispose();
130
+ await disposer.dispose();
117
131
  expect(cleanupFn).toHaveBeenCalledOnce();
118
132
  });
119
133
  });
120
134
  describe('实际使用场景', () => {
121
- it('应该能够清理事件监听器', () => {
135
+ it('应该能够清理事件监听器', async () => {
122
136
  const removeEventListener = vi.fn();
123
137
  const unsubscribe = vi.fn();
124
138
  disposer.addDisposer(removeEventListener);
125
139
  disposer.addDisposer(unsubscribe);
126
- disposer.dispose();
140
+ await disposer.dispose();
127
141
  expect(removeEventListener).toHaveBeenCalled();
128
142
  expect(unsubscribe).toHaveBeenCalled();
129
143
  });
130
- it('应该能够清理定时器', () => {
144
+ it('应该能够清理定时器', async () => {
131
145
  const clearTimeout = vi.fn();
132
146
  const clearInterval = vi.fn();
133
147
  disposer.addDisposer(() => clearTimeout(123));
134
148
  disposer.addDisposer(() => clearInterval(456));
135
- disposer.dispose();
149
+ await disposer.dispose();
136
150
  expect(clearTimeout).toHaveBeenCalledWith(123);
137
151
  expect(clearInterval).toHaveBeenCalledWith(456);
138
152
  });
139
- it('应该能够清理资源连接', () => {
153
+ it('应该能够清理资源连接', async () => {
140
154
  const closeConnection = vi.fn();
141
155
  const releaseResource = vi.fn();
142
156
  disposer.addDisposer(() => closeConnection());
143
157
  disposer.addDisposer(() => releaseResource());
144
- disposer.dispose();
158
+ await disposer.dispose();
145
159
  expect(closeConnection).toHaveBeenCalled();
146
160
  expect(releaseResource).toHaveBeenCalled();
147
161
  });
148
- it('应该与 EventEmitter 配合使用', () => {
162
+ it('应该与 EventEmitter 配合使用', async () => {
149
163
  // 模拟 EventEmitter 的使用
150
164
  const mockEventEmitter = {
151
165
  on: vi.fn().mockReturnValue(vi.fn()), // 返回 off 函数
@@ -156,25 +170,25 @@ describe('Disposer', () => {
156
170
  disposer.addDisposer(offFunction1);
157
171
  disposer.addDisposer(offFunction2);
158
172
  disposer.addDisposer(() => mockEventEmitter.cleanup());
159
- disposer.dispose();
173
+ await disposer.dispose();
160
174
  expect(offFunction1).toHaveBeenCalled();
161
175
  expect(offFunction2).toHaveBeenCalled();
162
176
  expect(mockEventEmitter.cleanup).toHaveBeenCalled();
163
177
  });
164
178
  });
165
179
  describe('错误处理', () => {
166
- it('应该捕获并记录同步错误', () => {
167
- const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
180
+ it('应该捕获并记录同步错误', async () => {
181
+ const loggerErrorSpy = vi.spyOn(logger, 'error').mockImplementation(() => { });
168
182
  const error = new Error('Sync error');
169
183
  disposer.addDisposer(() => {
170
184
  throw error;
171
185
  });
172
- disposer.dispose();
173
- expect(consoleSpy).toHaveBeenCalledWith('Error during cleanup:', error);
174
- consoleSpy.mockRestore();
186
+ await disposer.dispose();
187
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Error during cleanup:', error);
188
+ loggerErrorSpy.mockRestore();
175
189
  });
176
- it('应该处理不同类型的错误', () => {
177
- const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
190
+ it('应该处理不同类型的错误', async () => {
191
+ const loggerErrorSpy = vi.spyOn(logger, 'error').mockImplementation(() => { });
178
192
  disposer.addDisposer(() => {
179
193
  throw new TypeError('Type error');
180
194
  });
@@ -184,9 +198,19 @@ describe('Disposer', () => {
184
198
  disposer.addDisposer(() => {
185
199
  throw { message: 'Object error' };
186
200
  });
187
- disposer.dispose();
188
- expect(consoleSpy).toHaveBeenCalledTimes(3);
189
- consoleSpy.mockRestore();
201
+ await disposer.dispose();
202
+ expect(loggerErrorSpy).toHaveBeenCalledTimes(3);
203
+ loggerErrorSpy.mockRestore();
204
+ });
205
+ it('应该捕获并记录异步错误', async () => {
206
+ const loggerErrorSpy = vi.spyOn(logger, 'error').mockImplementation(() => { });
207
+ const asyncError = new Error('Async error');
208
+ disposer.addDisposer(async () => {
209
+ throw asyncError;
210
+ });
211
+ await disposer.dispose();
212
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Error during cleanup:', asyncError);
213
+ loggerErrorSpy.mockRestore();
190
214
  });
191
215
  });
192
216
  });
@@ -1,2 +1,2 @@
1
- export * from './disposer';
1
+ export * from './disposer.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/disposer/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/disposer/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -1 +1 @@
1
- export * from './disposer';
1
+ export * from './disposer.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { UserError, SystemError } from './error';
2
+ import { UserError, SystemError } from './error.js';
3
3
  describe('UserError', () => {
4
4
  describe('constructor', () => {
5
5
  it('应该正确创建UserError实例', () => {
@@ -1,3 +1,3 @@
1
- export { UserError, SystemError } from './error';
2
- export type { ErrorContext } from './error';
1
+ export { UserError, SystemError } from './error.js';
2
+ export type { ErrorContext } from './error.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACZ,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,YAAY,EACb,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACZ,MAAM,YAAY,CAAA;AAEnB,YAAY,EACV,YAAY,EACb,MAAM,YAAY,CAAA"}
@@ -1 +1 @@
1
- export { UserError, SystemError } from './error';
1
+ export { UserError, SystemError } from './error.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { EventEmitter } from './event-emitter';
2
+ import { EventEmitter } from './event-emitter.js';
3
3
  describe('EventEmitter', () => {
4
4
  let emitter;
5
5
  beforeEach(() => {
@@ -1,2 +1,2 @@
1
- export * from './event-emitter';
1
+ export * from './event-emitter.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/event-emitter/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/event-emitter/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -1 +1 @@
1
- export * from './event-emitter';
1
+ export * from './event-emitter.js';
@@ -1 +1 @@
1
- {"version":3,"file":"flow-queue.d.ts","sourceRoot":"","sources":["../../source/flow-queue/flow-queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AAQH,KAAK,cAAc,GAAG,EAAE,CAAA;AACxB,KAAK,eAAe,GAAG,EAAE,CAAA;AACzB,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAA;AACtD,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAA;AAEjJ;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAC9B,WAAW,GACX,aAAa,GACb,OAAO,GACP,QAAQ,GACR,QAAQ,CAAA;AAGZ,KAAK,wBAAwB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAGD,KAAK,6BAA6B,GAAG,wBAAwB,GAAG;IAC9D,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB,CAAA;AAGD,KAAK,yB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CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAMxD;;OAEG;IACH,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,UAAU,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAO7B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBhC;;;;;;;;;;;;;OAaG;IACH,MAAM,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAYzB;;;;;;;;;;;;;;;OAeG;IACH,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IAsBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,IAAI,MAAM;CA+BhB"}
@@ -78,7 +78,8 @@
78
78
  * - **并发控制**:支持配置并发处理数量,默认为 1
79
79
  * - **链式调用**:支持流畅的链式 API 调用
80
80
  */
81
- import { catchIt } from '../catch';
81
+ import { catchIt } from '../catch/index.js';
82
+ import { logger } from '../logger/index.js';
82
83
  function delay(arg0) {
83
84
  return new Promise(resolve => setTimeout(() => resolve(), arg0));
84
85
  }
@@ -365,7 +366,7 @@ export class FlowQueue {
365
366
  }
366
367
  }
367
368
  catch (error) {
368
- console.error('Error in processFlow:', error);
369
+ logger.error('Error in processFlow:', error);
369
370
  }
370
371
  finally {
371
372
  // 减少正在处理的任务计数
@@ -381,7 +382,7 @@ export class FlowQueue {
381
382
  for (const callback of this.onGenerates.values()) {
382
383
  const result = await catchIt(() => callback(output));
383
384
  if (result.isError()) {
384
- console.error('Error in onGenerate callback:', result.error);
385
+ logger.error('Error in onGenerate callback:', result.error);
385
386
  }
386
387
  }
387
388
  }
@@ -527,13 +528,11 @@ export class FlowQueue {
527
528
  }
528
529
  // 如果已经标记为输入关闭且没有待处理的输入和正在处理的任务,立即返回 resolved Promise
529
530
  if (this.isInputClosed && this.pendingInputs.length === 0 && this.processingCount === 0) {
530
- console.log('所有输入已处理完毕');
531
531
  return Promise.resolve();
532
532
  }
533
533
  // 创建新的 Promise
534
534
  this.completionPromise = new Promise((resolve) => {
535
535
  this.completionResolve = () => {
536
- console.log('所有输入已处理完毕');
537
536
  resolve();
538
537
  };
539
538
  });
@@ -1,5 +1,6 @@
1
- import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { FlowQueue } from './flow-queue';
1
+ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
+ import { FlowQueue } from './flow-queue.js';
3
+ import { logger } from '../logger/index.js';
3
4
  describe('FlowQueue', () => {
4
5
  let flowQueue;
5
6
  let mockProcessor;
@@ -158,8 +159,8 @@ describe('FlowQueue', () => {
158
159
  throw new Error('Callback error');
159
160
  });
160
161
  const normalCallback = vi.fn();
161
- // Mock console.error 来验证错误被正确记录
162
- const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
162
+ // Mock logger.error 来验证错误被正确记录
163
+ const loggerErrorSpy = vi.spyOn(logger, 'error').mockImplementation(() => { });
163
164
  mockProcessor = vi.fn().mockResolvedValue(expectedOutput);
164
165
  flowQueue = new FlowQueue({ retry: { maxRetries: 3 } }, mockProcessor);
165
166
  flowQueue.onGenerate(faultyCallback);
@@ -168,8 +169,8 @@ describe('FlowQueue', () => {
168
169
  await new Promise(resolve => setTimeout(resolve, 50));
169
170
  expect(faultyCallback).toHaveBeenCalled();
170
171
  expect(normalCallback).toHaveBeenCalledWith(expectedOutput);
171
- expect(consoleErrorSpy).toHaveBeenCalledWith('Error in onGenerate callback:', expect.any(Error));
172
- consoleErrorSpy.mockRestore();
172
+ expect(loggerErrorSpy).toHaveBeenCalledWith('Error in onGenerate callback:', expect.any(Error));
173
+ loggerErrorSpy.mockRestore();
173
174
  });
174
175
  it('失败的处理不应该触发回调', async () => {
175
176
  const testInput = { id: 1, data: 'test' };
@@ -1,3 +1,3 @@
1
- export { FlowQueue } from './flow-queue';
2
- export type { FlowQueueOptions, FlowQueueProcessor, FlowQueueRetryStrategy, FlowQueueRetryConfig, FlowQueueDelayConfig, FlowQueueOnGenerate } from './flow-queue';
1
+ export { FlowQueue } from './flow-queue.js';
2
+ export type { FlowQueueOptions, FlowQueueProcessor, FlowQueueRetryStrategy, FlowQueueRetryConfig, FlowQueueDelayConfig, FlowQueueOnGenerate } from './flow-queue.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/flow-queue/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/flow-queue/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iBAAiB,CAAA"}
@@ -1,3 +1,3 @@
1
1
  // Flow Queue 模块入口
2
2
  // 提供流式处理队列功能,支持重试、延迟等高级特性
3
- export { FlowQueue } from './flow-queue';
3
+ export { FlowQueue } from './flow-queue.js';
package/output/index.d.ts CHANGED
@@ -1,18 +1,18 @@
1
- export * from './disposer';
2
- export * from './event-emitter';
3
- export * from './logger';
4
- export * from './error';
5
- export * from './service';
6
- export * from './ttl-cache';
7
- export * from './lru-cache';
8
- export * from './ring-cache';
9
- export * from './batching-buffer';
10
- export * from './string';
11
- export * from './color';
12
- export * from './object';
13
- export * from './number';
14
- export * from './catch';
15
- export * from './debounce';
16
- export * from './throttle';
17
- export * from './flow-queue';
1
+ export * from './disposer/index.js';
2
+ export * from './event-emitter/index.js';
3
+ export * from './logger/index.js';
4
+ export * from './error/index.js';
5
+ export * from './service/index.js';
6
+ export * from './ttl-cache/index.js';
7
+ export * from './lru-cache/index.js';
8
+ export * from './ring-cache/index.js';
9
+ export * from './batching-buffer/index.js';
10
+ export * from './string/index.js';
11
+ export * from './color/index.js';
12
+ export * from './object/index.js';
13
+ export * from './number/index.js';
14
+ export * from './catch/index.js';
15
+ export * from './debounce/index.js';
16
+ export * from './throttle/index.js';
17
+ export * from './flow-queue/index.js';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAG1B,cAAc,iBAAiB,CAAA;AAG/B,cAAc,UAAU,CAAA;AAGxB,cAAc,SAAS,CAAA;AAGvB,cAAc,WAAW,CAAA;AAGzB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAG5B,cAAc,mBAAmB,CAAA;AAGjC,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AAGvB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAE1B,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAA;AAGnC,cAAc,0BAA0B,CAAA;AAGxC,cAAc,mBAAmB,CAAA;AAGjC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,oBAAoB,CAAA;AAGlC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AAGrC,cAAc,4BAA4B,CAAA;AAG1C,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AAEnC,cAAc,uBAAuB,CAAA"}
package/output/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  // === 资源管理 ===
2
- export * from './disposer';
2
+ export * from './disposer/index.js';
3
3
  // === 事件系统 ===
4
- export * from './event-emitter';
4
+ export * from './event-emitter/index.js';
5
5
  // === 日志系统 ===
6
- export * from './logger';
6
+ export * from './logger/index.js';
7
7
  // === 错误处理 ===
8
- export * from './error';
8
+ export * from './error/index.js';
9
9
  // === 服务管理 ===
10
- export * from './service';
10
+ export * from './service/index.js';
11
11
  // === 缓存系统 ===
12
- export * from './ttl-cache';
13
- export * from './lru-cache';
14
- export * from './ring-cache';
12
+ export * from './ttl-cache/index.js';
13
+ export * from './lru-cache/index.js';
14
+ export * from './ring-cache/index.js';
15
15
  // === 数据管理 ===
16
- export * from './batching-buffer';
16
+ export * from './batching-buffer/index.js';
17
17
  // === 基础工具 ===
18
- export * from './string';
19
- export * from './color';
20
- export * from './object';
21
- export * from './number';
22
- export * from './catch';
18
+ export * from './string/index.js';
19
+ export * from './color/index.js';
20
+ export * from './object/index.js';
21
+ export * from './number/index.js';
22
+ export * from './catch/index.js';
23
23
  // === 函数增强 ===
24
- export * from './debounce';
25
- export * from './throttle';
26
- export * from './flow-queue';
24
+ export * from './debounce/index.js';
25
+ export * from './throttle/index.js';
26
+ export * from './flow-queue/index.js';
@@ -2,7 +2,7 @@
2
2
  * 格式化器配置模块
3
3
  * 提供各种类型数据的格式化功能
4
4
  */
5
- import { UserError, SystemError } from '../error';
5
+ import { UserError, SystemError } from '../error/index.js';
6
6
  /**
7
7
  * 日志格式化器
8
8
  * 负责根据配置格式化各种类型的参数
@@ -1,6 +1,6 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { DefaultLogFormatter } from './formatter';
3
- import { UserError, SystemError } from '../error';
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { DefaultLogFormatter } from './formatter.js';
3
+ import { UserError, SystemError } from '../error/index.js';
4
4
  describe('DefaultLogFormatter', () => {
5
5
  let formatter;
6
6
  beforeEach(() => {
@@ -1,4 +1,4 @@
1
- export * from './logger';
2
- export * from './formatter';
3
- export * from './transport';
1
+ export * from './logger.js';
2
+ export * from './formatter.js';
3
+ export * from './transport.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/logger/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -1,3 +1,3 @@
1
- export * from './logger';
2
- export * from './formatter';
3
- export * from './transport';
1
+ export * from './logger.js';
2
+ export * from './formatter.js';
3
+ export * from './transport.js';
@@ -1,5 +1,5 @@
1
- import { LogTransport } from './transport';
2
- import { LogFormatter } from './formatter';
1
+ import type { LogTransport } from './transport.js';
2
+ import { type LogFormatter } from './formatter.js';
3
3
  export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
4
4
  export interface LoggerOptions {
5
5
  level?: LogLevel;
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../source/logger/logger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAa,MAAM,aAAa,CAAA;AACrD,OAAO,EAAuB,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/D,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,C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E;IAOnB,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAOnB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAOpB,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;IAOpB,MAAM;IAIN;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI;IAI3C;;OAEG;IACH,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI5C;;OAEG;IACH,aAAa,IAAI,SAAS,YAAY,EAAE;IAIxC;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtC;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM;IAkB/E;;OAEG;IACH,IAAI,KAAK,IAAI,QAAQ,CAEpB;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAE3B;CACF;AAED,eAAO,MAAM,MAAM,QAAe,CAAA"}
@@ -1,4 +1,4 @@
1
- import { defaultLogFormatter } from './formatter';
1
+ import { defaultLogFormatter } from './formatter.js';
2
2
  export class Logger {
3
3
  _level;
4
4
  formatter;
@@ -1,8 +1,8 @@
1
1
  import { describe, it, expect, vi } from 'vitest';
2
- import { Logger } from './logger';
3
- import { DefaultLogFormatter } from './formatter';
4
- import { UserError, SystemError } from '../error';
5
- import { MemoryTransport } from './transport'; // 测试向后兼容性
2
+ import { Logger } from './logger.js';
3
+ import { DefaultLogFormatter } from './formatter.js';
4
+ import { UserError, SystemError } from '../error/index.js';
5
+ import { MemoryTransport } from './transport.js'; // 测试向后兼容性
6
6
  describe('Logger', () => {
7
7
  it('应该默认记录 info 及以上级别', () => {
8
8
  const print = vi.fn();
@@ -2,7 +2,7 @@
2
2
  * LogTransport 抽象接口和实现
3
3
  * LogTransport 负责处理和存储结构化的日志数据
4
4
  */
5
- import type { LogLevel } from './logger';
5
+ import type { LogLevel } from './logger.js';
6
6
  /**
7
7
  * 日志记录接口
8
8
  * 包含完整的结构化日志信息
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../source/logger/transport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAGxC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW;IACX,KAAK,EAAE,QAAQ,CAAA;IACf,UAAU;IACV,SAAS,EAAE,IAAI,CAAA;IACf,aAAa;IACb,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,eAAe;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB,aAAa;IACb,KAAK,CAAC,EAAE,QAAQ,CAAA;IAEhB,WAAW;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;OAGG;IACH,GAAG,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C;;OAEG;IACH,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,aAAa;IACb,KAAK,CAAC,EAAE,QAAQ,CAAA;IAChB,WAAW;IACX,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,YAAY;IACZ,EAAE,EAAE,MAAM,CAAA;CACX;AAED;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,YAAY;IAClD,SAAgB,IAAI,EAAE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AI;IAQnC;;OAEG;IACI,UAAU,IAAI,SAAS,cAAc,EAAE;IAO9C;;OAEG;IACI,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,cAAc,EAAE;IAQ3D;;OAEG;IACI,qBAAqB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,cAAc,EAAE;IAQtE;;;OAGG;IACI,aAAa,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,OAAO,GAAG,cAAc,EAAE;IAItF;;;OAGG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,EAAE;IAsB5D;;OAEG;IACI,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,EAAE;IAOxD;;OAEG;IACI,QAAQ,IAAI;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,OAAO,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QACjC,eAAe,CAAC,EAAE,IAAI,CAAA;QACtB,eAAe,CAAC,EAAE,IAAI,CAAA;KACvB;IA4BD;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;OAEG;IACI,KAAK,IAAI,IAAI;CAGrB"}
@@ -1,4 +1,4 @@
1
- import { RingCache } from '../ring-cache';
1
+ import { RingCache } from '../ring-cache/index.js';
2
2
  /**
3
3
  * 内存 LogTransport 实现
4
4
  * 将结构化日志数据存储在内存中,支持查询和分析
@@ -1,5 +1,5 @@
1
- import { describe, it, expect, beforeEach } from 'vitest';
2
- import { MemoryTransport } from './transport';
1
+ import { describe, it, expect, beforeEach, vi } from 'vitest';
2
+ import { MemoryTransport } from './transport.js';
3
3
  // 创建一个测试用的 Transport 实现
4
4
  class TestTransport {
5
5
  name;
@@ -1,2 +1,2 @@
1
- export { LruCache } from './lru-cache';
1
+ export { LruCache } from './lru-cache.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/lru-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/lru-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1 +1 @@
1
- export { LruCache } from './lru-cache';
1
+ export { LruCache } from './lru-cache.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { LruCache } from './lru-cache';
2
+ import { LruCache } from './lru-cache.js';
3
3
  describe('LruCache', () => {
4
4
  describe('构造函数', () => {
5
5
  it('应该创建默认容量为100的缓存', () => {
@@ -1,2 +1,2 @@
1
- export * from './number';
1
+ export * from './number.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +1 @@
1
- export * from './number';
1
+ export * from './number.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { bigintToNumber } from './number';
2
+ import { bigintToNumber } from './number.js';
3
3
  describe('bigintToNumber 函数', () => {
4
4
  it('应该将小的 bigint 转换为 number', () => {
5
5
  const result = bigintToNumber(123n);
@@ -1,2 +1,2 @@
1
- export * from './object';
1
+ export * from './object.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/object/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +1 @@
1
- export * from './object';
1
+ export * from './object.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect } from 'vitest';
2
- import { objectMerge } from './object';
2
+ import { objectMerge } from './object.js';
3
3
  describe('merge 函数', () => {
4
4
  it('应该合并两个简单对象', () => {
5
5
  const target = { a: 1 };
@@ -2,5 +2,5 @@
2
2
  * Ring Cache 模块
3
3
  * 专门用于日志场景的FIFO环形缓存
4
4
  */
5
- export * from './ring-cache';
5
+ export * from './ring-cache.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/ring-cache/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,cAAc,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/ring-cache/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,iBAAiB,CAAA"}
@@ -2,4 +2,4 @@
2
2
  * Ring Cache 模块
3
3
  * 专门用于日志场景的FIFO环形缓存
4
4
  */
5
- export * from './ring-cache';
5
+ export * from './ring-cache.js';
@@ -2,7 +2,7 @@
2
2
  * RingCache 测试文件
3
3
  */
4
4
  import { describe, it, expect, beforeEach } from 'vitest';
5
- import { RingCache } from './ring-cache';
5
+ import { RingCache } from './ring-cache.js';
6
6
  describe('RingCache', () => {
7
7
  let cache;
8
8
  beforeEach(() => {
@@ -77,9 +77,10 @@ describe('RingCache', () => {
77
77
  expect(results.map(e => e.data)).toEqual(['apple', 'apricot']);
78
78
  });
79
79
  it('应该支持时间范围搜索', () => {
80
- const now = new Date();
81
- const future = new Date(now.getTime() + 1000);
82
- const results = cache.getByTimeRange(now, future);
80
+ const entries = cache.getAll();
81
+ const start = new Date(entries[0].timestamp.getTime() - 1);
82
+ const end = new Date(entries[entries.length - 1].timestamp.getTime() + 1);
83
+ const results = cache.getByTimeRange(start, end);
83
84
  expect(results.length).toBe(3);
84
85
  });
85
86
  });
@@ -1,2 +1,2 @@
1
- export { Service } from './service';
1
+ export { Service } from './service.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -1 +1 @@
1
- export { Service } from './service';
1
+ export { Service } from './service.js';
@@ -1,2 +1,2 @@
1
- export * from './string';
1
+ export * from './string.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -1 +1 @@
1
- export * from './string';
1
+ export * from './string.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
- import { randomString } from './string';
2
+ import { randomString } from './string.js';
3
3
  describe('randomString 函数', () => {
4
4
  beforeEach(() => {
5
5
  // 重置随机数生成器的模拟
@@ -1,2 +1,2 @@
1
- export * from './throttle';
1
+ export * from './throttle.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/throttle/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/throttle/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -1 +1 @@
1
- export * from './throttle';
1
+ export * from './throttle.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
- import { throttle, throttleFn } from './throttle';
2
+ import { throttle, throttleFn } from './throttle.js';
3
3
  describe('throttle', () => {
4
4
  beforeEach(() => {
5
5
  vi.useFakeTimers();
@@ -1,2 +1,2 @@
1
- export { TtlCache, type TtlCacheOptions, type TtlCacheStats } from './ttl-cache';
1
+ export { TtlCache, type TtlCacheOptions, type TtlCacheStats } from './ttl-cache.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/ttl-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/ttl-cache/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1 +1 @@
1
- export { TtlCache } from './ttl-cache';
1
+ export { TtlCache } from './ttl-cache.js';
@@ -1,5 +1,5 @@
1
1
  import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
2
- import { TtlCache } from './ttl-cache';
2
+ import { TtlCache } from './ttl-cache.js';
3
3
  describe('TtlCache', () => {
4
4
  let cache;
5
5
  beforeEach(() => {
package/package.json CHANGED
@@ -1,34 +1,36 @@
1
1
  {
2
2
  "name": "@taicode/common-base",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "author": "Alain",
5
5
  "license": "ISC",
6
6
  "description": "",
7
+ "type": "module",
8
+ "engines": {
9
+ "node": ">=16.0.0"
10
+ },
7
11
  "main": "./output/index.js",
8
12
  "types": "./output/index.d.ts",
9
13
  "exports": {
10
14
  ".": {
11
15
  "types": "./output/index.d.ts",
12
- "import": "./output/index.js",
13
- "require": "./output/index.js"
16
+ "default": "./output/index.js"
14
17
  },
15
18
  "./*": {
16
19
  "types": "./output/*/index.d.ts",
17
- "import": "./output/*/index.js",
18
- "require": "./output/*/index.js"
20
+ "default": "./output/*/index.js"
19
21
  }
20
22
  },
21
23
  "scripts": {
22
24
  "test": "vitest run",
23
- "build": "tsc -p tsconfig.json",
25
+ "build": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json",
24
26
  "prepublishOnly": "npm run build",
25
- "dev": "tsc -p tsconfig.json --watch"
27
+ "dev": "node ../../node_modules/typescript/bin/tsc -p tsconfig.json --watch"
26
28
  },
27
29
  "files": [
28
30
  "output"
29
31
  ],
30
32
  "devDependencies": {
31
33
  "vitest": "^3.2.4",
32
- "mobx": "^6.0.0"
34
+ "mobx": "^6.15.0"
33
35
  }
34
36
  }