MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / dequeue

Function dequeue

source code/utils/messageQueueManager.ts:169–195  ·  view source on GitHub ↗
(
  filter?: (cmd: QueuedCommand) => boolean,
)

Source from the content-addressed store, hash-verified

167 * the existing while-loop patterns.
168 */
169export function dequeue(
170 filter?: (cmd: QueuedCommand) => boolean,
171): QueuedCommand | undefined {
172 if (commandQueue.length === 0) {
173 return undefined
174 }
175
176 // Find the first command with the highest priority (respecting filter)
177 let bestIdx = -1
178 let bestPriority = Infinity
179 for (let i = 0; i < commandQueue.length; i++) {
180 const cmd = commandQueue[i]!
181 if (filter && !filter(cmd)) continue
182 const priority = PRIORITY_ORDER[cmd.priority ?? 'next']
183 if (priority < bestPriority) {
184 bestIdx = i
185 bestPriority = priority
186 }
187 }
188
189 if (bestIdx === -1) return undefined
190
191 const [dequeued] = commandQueue.splice(bestIdx, 1)
192 notifySubscribers()
193 logOperation('dequeue')
194 return dequeued
195}
196
197/**
198 * Remove and return all commands from the queue.

Callers 3

processQueueIfReadyFunction · 0.85
drainCommandQueueFunction · 0.85

Calls 2

notifySubscribersFunction · 0.85
logOperationFunction · 0.85

Tested by

no test coverage detected