From cec00f6895ba49dc0164bd92e0d4fad64da0d03d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Wed, 24 Jan 2024 11:24:16 +0100 Subject: [PATCH] fix: allow typing job options in peer queue Allows specifying the job option type as a generic. --- packages/utils/src/peer-queue.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/utils/src/peer-queue.ts b/packages/utils/src/peer-queue.ts index 9357927277..6a7c707668 100644 --- a/packages/utils/src/peer-queue.ts +++ b/packages/utils/src/peer-queue.ts @@ -4,19 +4,19 @@ import { Queue, type QueueAddOptions } from './queue/index.js' import type { Job } from './queue/job.js' import type { PeerId } from '@libp2p/interface' -export interface PeerQueueOptions extends QueueAddOptions { +export interface PeerQueueJobOptions extends QueueAddOptions { peerId: PeerId } /** * Extends Queue to add support for querying queued jobs by peer id */ -export class PeerQueue extends Queue { +export class PeerQueue extends Queue { has (peerId: PeerId): boolean { return this.find(peerId) != null } - find (peerId: PeerId): Job | undefined { + find (peerId: PeerId): Job | undefined { return this.queue.find(job => { return peerId.equals(job.options.peerId) })