Skip to content

Commit 74fb567

Browse files
authored
fix: allow typing job options in peer queue (#2372)
Allows specifying the job option type as a generic.
1 parent dbc92ab commit 74fb567

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/utils/src/peer-queue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import { Queue, type QueueAddOptions } from './queue/index.js'
44
import type { Job } from './queue/job.js'
55
import type { PeerId } from '@libp2p/interface'
66

7-
export interface PeerQueueOptions extends QueueAddOptions {
7+
export interface PeerQueueJobOptions extends QueueAddOptions {
88
peerId: PeerId
99
}
1010

1111
/**
1212
* Extends Queue to add support for querying queued jobs by peer id
1313
*/
14-
export class PeerQueue<JobReturnType = void> extends Queue<JobReturnType, PeerQueueOptions> {
14+
export class PeerQueue<JobReturnType = void, JobOptions extends PeerQueueJobOptions = PeerQueueJobOptions> extends Queue<JobReturnType, JobOptions> {
1515
has (peerId: PeerId): boolean {
1616
return this.find(peerId) != null
1717
}
1818

19-
find (peerId: PeerId): Job<PeerQueueOptions, JobReturnType> | undefined {
19+
find (peerId: PeerId): Job<JobOptions, JobReturnType> | undefined {
2020
return this.queue.find(job => {
2121
return peerId.equals(job.options.peerId)
2222
})

0 commit comments

Comments
 (0)