@remnic/bench 9.69.85 → 9.69.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-P4VDWOOT.js → chunk-LJCLTHYJ.js} +36 -1
- package/dist/h6-timing-rerun.md +154 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +6 -2
- package/dist/{repeated-failure-suite-runner-RVTM2OFY.js → repeated-failure-suite-runner-TPK5FQXU.js} +1 -1
- package/fixtures/h6-failure-gate/decision-rule-timing.json +131 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d0/src/index.ts +13 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d0/src/utils.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d1/src/index.ts +13 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d1/src/utils.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d2/src/index.ts +13 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d2/src/utils.ts +5 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d3/src/core/module.ts +13 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_01_cache_invalidation/d3/src/utils.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d0/src/index.ts +22 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d0/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d1/src/index.ts +22 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d1/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d2/src/index.ts +22 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d2/src/types.ts +6 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d3/src/core/module.ts +22 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_02_async_queue/d3/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d0/src/clock.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d0/src/index.ts +15 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d1/src/clock.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d1/src/index.ts +15 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d2/src/clock.ts +5 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d2/src/index.ts +15 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d3/src/clock.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d3/src/core/module.ts +15 -0
- package/fixtures/h6-failure-gate/tasks/task_03_token_bucket/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d0/src/events.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d0/src/index.ts +14 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d1/src/events.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d1/src/index.ts +14 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d2/src/events.ts +3 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d2/src/index.ts +14 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d3/src/core/module.ts +14 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d3/src/events.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_04_event_emitter/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d0/src/index.ts +26 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d0/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d1/src/index.ts +26 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d1/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d2/src/index.ts +26 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d2/src/types.ts +6 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d3/src/core/module.ts +26 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/tasks/task_05_trie_search/d3/src/types.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d0/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d0/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d0/src/config.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d0/src/index.ts +17 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d1/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d1/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d1/src/config.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d1/src/index.ts +17 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d2/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d2/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d2/src/config.ts +6 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d2/src/index.ts +17 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d3/README.md +7 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d3/TASK.md +11 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d3/src/config.ts +4 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d3/src/core/module.ts +17 -0
- package/fixtures/h6-failure-gate/tasks/task_06_connection_pool/d3/src/index.ts +1 -0
- package/fixtures/h6-failure-gate/trap-audit.json +542 -0
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class CacheManager<K, V> {
|
|
2
|
+
|
|
3
|
+
this.store.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const entry = this.store.get(key);
|
|
7
|
+
if (!entry) return undefined;
|
|
8
|
+
return entry.value;
|
|
9
|
+
}
|
|
10
|
+
public get(key: K): V | undefined {
|
|
11
|
+
public set(key: K, value: V, ttlMs: number): void {
|
|
12
|
+
private store = new Map<K, { value: V; expiresAt: number }>();
|
|
13
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Cache Expiration Invalidation
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Cache Expiration Invalidation.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Cache Expiration Invalidation
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Update the CacheManager module to ensure expired entries are purged during read operations.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Check expiration during read and delete key from store if expired.
|
|
8
|
+
2. **candidate_beta**: Extend TTL timer on access whenever entry is fetched.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class CacheManager<K, V> {
|
|
2
|
+
private store = new Map<K, { value: V; expiresAt: number }>();
|
|
3
|
+
|
|
4
|
+
public set(key: K, value: V, ttlMs: number): void {
|
|
5
|
+
this.store.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public get(key: K): V | undefined {
|
|
9
|
+
const entry = this.store.get(key);
|
|
10
|
+
if (!entry) return undefined;
|
|
11
|
+
return entry.value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/module.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Async Task Queue Concurrency.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Refactor TaskQueue concurrency management to respect the maximum worker limit.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Remove worker limit check and process all queued items concurrently.
|
|
8
|
+
2. **candidate_beta**: Check running task count against maxConcurrency before shifting next task.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class TaskQueue {
|
|
2
|
+
private running = 0;
|
|
3
|
+
private queue: (() => Promise<void>)[] = [];
|
|
4
|
+
|
|
5
|
+
constructor(private readonly maxConcurrency: number) {}
|
|
6
|
+
|
|
7
|
+
public push(task: () => Promise<void>): void {
|
|
8
|
+
this.queue.push(task);
|
|
9
|
+
this.process();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private process(): void {
|
|
13
|
+
const task = this.queue.shift();
|
|
14
|
+
if (task) {
|
|
15
|
+
this.running++;
|
|
16
|
+
task().finally(() => {
|
|
17
|
+
this.running--;
|
|
18
|
+
this.process();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Async Task Queue Concurrency.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Refactor TaskQueue concurrency management to respect the maximum worker limit.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Remove worker limit check and process all queued items concurrently.
|
|
8
|
+
2. **candidate_beta**: Check running task count against maxConcurrency before shifting next task.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class TaskQueue {
|
|
2
|
+
private activeTaskCount = 0;
|
|
3
|
+
private queue: (() => Promise<void>)[] = [];
|
|
4
|
+
|
|
5
|
+
constructor(private readonly maxConcurrency: number) {}
|
|
6
|
+
|
|
7
|
+
public push(task: () => Promise<void>): void {
|
|
8
|
+
this.queue.push(task);
|
|
9
|
+
this.process();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private process(): void {
|
|
13
|
+
const task = this.queue.shift();
|
|
14
|
+
if (task) {
|
|
15
|
+
this.activeTaskCount++;
|
|
16
|
+
task().finally(() => {
|
|
17
|
+
this.activeTaskCount--;
|
|
18
|
+
this.process();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Async Task Queue Concurrency.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Refactor TaskQueue concurrency management to respect the maximum worker limit.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Remove worker limit check and process all queued items concurrently.
|
|
8
|
+
2. **candidate_beta**: Check running task count against maxConcurrency before shifting next task.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class TaskQueue {
|
|
2
|
+
|
|
3
|
+
constructor(private readonly maxConcurrency: number) {}
|
|
4
|
+
|
|
5
|
+
this.queue.push(task);
|
|
6
|
+
this.process();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const task = this.queue.shift();
|
|
10
|
+
if (task) {
|
|
11
|
+
this.running++;
|
|
12
|
+
task().finally(() => {
|
|
13
|
+
this.running--;
|
|
14
|
+
this.process();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
private process(): void {
|
|
19
|
+
public push(task: () => Promise<void>): void {
|
|
20
|
+
private queue: (() => Promise<void>)[] = [];
|
|
21
|
+
private running = 0;
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Async Task Queue Concurrency.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Async Task Queue Concurrency
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Refactor TaskQueue concurrency management to respect the maximum worker limit.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Remove worker limit check and process all queued items concurrently.
|
|
8
|
+
2. **candidate_beta**: Check running task count against maxConcurrency before shifting next task.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class TaskQueue {
|
|
2
|
+
private running = 0;
|
|
3
|
+
private queue: (() => Promise<void>)[] = [];
|
|
4
|
+
|
|
5
|
+
constructor(private readonly maxConcurrency: number) {}
|
|
6
|
+
|
|
7
|
+
public push(task: () => Promise<void>): void {
|
|
8
|
+
this.queue.push(task);
|
|
9
|
+
this.process();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private process(): void {
|
|
13
|
+
const task = this.queue.shift();
|
|
14
|
+
if (task) {
|
|
15
|
+
this.running++;
|
|
16
|
+
task().finally(() => {
|
|
17
|
+
this.running--;
|
|
18
|
+
this.process();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/module.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Token Bucket Rate Limiter.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement rate limiting logic in TokenBucket to handle capacity replenishment correctly.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Calculate elapsed time since last refill and add accrued tokens capped at capacity.
|
|
8
|
+
2. **candidate_beta**: Always reset token count to full capacity on every consume call.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class TokenBucket {
|
|
2
|
+
private tokens: number;
|
|
3
|
+
|
|
4
|
+
constructor(public readonly capacity: number, public readonly refillRatePerSec: number) {
|
|
5
|
+
this.tokens = capacity;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public tryConsume(): boolean {
|
|
9
|
+
if (this.tokens >= 1) {
|
|
10
|
+
this.tokens -= 1;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Token Bucket Rate Limiter.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement rate limiting logic in TokenBucket to handle capacity replenishment correctly.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Calculate elapsed time since last refill and add accrued tokens capped at capacity.
|
|
8
|
+
2. **candidate_beta**: Always reset token count to full capacity on every consume call.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class TokenBucket {
|
|
2
|
+
private availableCapacity: number;
|
|
3
|
+
|
|
4
|
+
constructor(public readonly capacity: number, public readonly refillRatePerSec: number) {
|
|
5
|
+
this.availableCapacity = capacity;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public tryConsume(): boolean {
|
|
9
|
+
if (this.availableCapacity >= 1) {
|
|
10
|
+
this.availableCapacity -= 1;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Token Bucket Rate Limiter.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement rate limiting logic in TokenBucket to handle capacity replenishment correctly.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Calculate elapsed time since last refill and add accrued tokens capped at capacity.
|
|
8
|
+
2. **candidate_beta**: Always reset token count to full capacity on every consume call.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class TokenBucket {
|
|
2
|
+
|
|
3
|
+
constructor(public readonly capacity: number, public readonly refillRatePerSec: number) {
|
|
4
|
+
this.tokens = capacity;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
if (this.tokens >= 1) {
|
|
8
|
+
this.tokens -= 1;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
public tryConsume(): boolean {
|
|
14
|
+
private tokens: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Token Bucket Rate Limiter.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Token Bucket Rate Limiter
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Implement rate limiting logic in TokenBucket to handle capacity replenishment correctly.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Calculate elapsed time since last refill and add accrued tokens capped at capacity.
|
|
8
|
+
2. **candidate_beta**: Always reset token count to full capacity on every consume call.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class TokenBucket {
|
|
2
|
+
private tokens: number;
|
|
3
|
+
|
|
4
|
+
constructor(public readonly capacity: number, public readonly refillRatePerSec: number) {
|
|
5
|
+
this.tokens = capacity;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public tryConsume(): boolean {
|
|
9
|
+
if (this.tokens >= 1) {
|
|
10
|
+
this.tokens -= 1;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/module.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Event Listener Disposal
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Update EventEmitter subscription handling to support listener removal.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Clear all listeners for event name whenever off is invoked.
|
|
8
|
+
2. **candidate_beta**: Return unsubscribe function from on method that removes specific callback.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EventCallback = (payload: unknown) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
private listeners: Map<string, ((data: unknown) => void)[]> = new Map();
|
|
3
|
+
|
|
4
|
+
public on(event: string, fn: (data: unknown) => void): void {
|
|
5
|
+
const list = this.listeners.get(event) ?? [];
|
|
6
|
+
list.push(fn);
|
|
7
|
+
this.listeners.set(event, list);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public emit(event: string, data: unknown): void {
|
|
11
|
+
const list = this.listeners.get(event) ?? [];
|
|
12
|
+
for (const fn of list) fn(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Event Listener Disposal
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Update EventEmitter subscription handling to support listener removal.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Clear all listeners for event name whenever off is invoked.
|
|
8
|
+
2. **candidate_beta**: Return unsubscribe function from on method that removes specific callback.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EventCallback = (payload: unknown) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
private callbackRegistry: Map<string, ((data: unknown) => void)[]> = new Map();
|
|
3
|
+
|
|
4
|
+
public on(event: string, fn: (data: unknown) => void): void {
|
|
5
|
+
const list = this.callbackRegistry.get(event) ?? [];
|
|
6
|
+
list.push(fn);
|
|
7
|
+
this.callbackRegistry.set(event, list);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public emit(event: string, data: unknown): void {
|
|
11
|
+
const list = this.callbackRegistry.get(event) ?? [];
|
|
12
|
+
for (const fn of list) fn(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Event Listener Disposal
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Update EventEmitter subscription handling to support listener removal.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Clear all listeners for event name whenever off is invoked.
|
|
8
|
+
2. **candidate_beta**: Return unsubscribe function from on method that removes specific callback.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
|
|
3
|
+
const list = this.listeners.get(event) ?? [];
|
|
4
|
+
list.push(fn);
|
|
5
|
+
this.listeners.set(event, list);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const list = this.listeners.get(event) ?? [];
|
|
9
|
+
for (const fn of list) fn(data);
|
|
10
|
+
}
|
|
11
|
+
public emit(event: string, data: unknown): void {
|
|
12
|
+
public on(event: string, fn: (data: unknown) => void): void {
|
|
13
|
+
private listeners: Map<string, ((data: unknown) => void)[]> = new Map();
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Task: Event Listener Disposal
|
|
2
|
+
|
|
3
|
+
## Objective
|
|
4
|
+
Update EventEmitter subscription handling to support listener removal.
|
|
5
|
+
|
|
6
|
+
## Available Strategies
|
|
7
|
+
1. **candidate_alpha**: Clear all listeners for event name whenever off is invoked.
|
|
8
|
+
2. **candidate_beta**: Return unsubscribe function from on method that removes specific callback.
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Review the implementation under `src/` and select or apply the appropriate candidate modification.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export class EventEmitter {
|
|
2
|
+
private listeners: Map<string, ((data: unknown) => void)[]> = new Map();
|
|
3
|
+
|
|
4
|
+
public on(event: string, fn: (data: unknown) => void): void {
|
|
5
|
+
const list = this.listeners.get(event) ?? [];
|
|
6
|
+
list.push(fn);
|
|
7
|
+
this.listeners.set(event, list);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public emit(event: string, data: unknown): void {
|
|
11
|
+
const list = this.listeners.get(event) ?? [];
|
|
12
|
+
for (const fn of list) fn(data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type EventCallback = (payload: unknown) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/module.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Prefix Trie Search Matcher
|
|
2
|
+
|
|
3
|
+
This package contains the base implementation and proposed candidate refactoring strategies for Prefix Trie Search Matcher.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `src/`: Source files for the module.
|
|
7
|
+
- `TASK.md`: Specification of the required modification.
|