Skip to content

Commit

Permalink
fix: use NodeJS.EventEmitter for event emitter type
Browse files Browse the repository at this point in the history
  • Loading branch information
Deivu committed Dec 22, 2024
1 parent e93bb74 commit aa9ce2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/concurrency/AsyncQueue.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { EventEmitter, once } from 'events';
import { EventEmitter, once } from 'node:events';

export declare interface AsyncQueueWaitOptions {
signal?: AbortSignal | undefined;
}

export class AsyncQueue {
private readonly queue: EventEmitter[];
private readonly queue: NodeJS.EventEmitter[];
constructor() {
this.queue = [];
}
Expand All @@ -15,10 +15,10 @@ export class AsyncQueue {
}

public wait({ signal }: AsyncQueueWaitOptions): Promise<void[]> {
// @ts-expect-error: this is ok

const next = this.remaining ? once(this.queue[this.remaining - 1], 'resolve', { signal }) : Promise.resolve([]);

const emitter = new EventEmitter();
const emitter = new EventEmitter() as NodeJS.EventEmitter;

this.queue.push(emitter);

Expand All @@ -35,7 +35,7 @@ export class AsyncQueue {

public shift(): void {
const emitter = this.queue.shift();
// @ts-expect-error: emit exists in event emitter

if (typeof emitter !== 'undefined') emitter.emit('resolve');
}
}

0 comments on commit aa9ce2f

Please sign in to comment.