Ghost System Test - Async Queue Handler
A test snippet for verifying the ghost interaction system with notifications
Language: typescript
Author: Umut Bayraktar (@umut)
3 stars · 28 views
A test snippet for verifying the ghost interaction system with notifications
Language: typescript
Author: Umut Bayraktar (@umut)
3 stars · 28 views
class AsyncQueue<T> {
private queue: T[] = [];
private processing = false;
async enqueue(item: T, processor: (item: T) => Promise<void>) {
this.queue.push(item);
await this.processQueue(processor);
}
}
private async processQueue(processor: (item: T) => Promise<void>) {
this.processing = true;
while (this.queue.length > 0) {
await processor(item);
}
this.processing = false;
}
}
export { AsyncQueue };A test snippet for verifying the ghost interaction system with notifications