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

Function peek

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

Source from the content-addressed store, hash-verified

219 * Accepts an optional `filter` — only commands passing the predicate are considered.
220 */
221export function peek(
222 filter?: (cmd: QueuedCommand) => boolean,
223): QueuedCommand | undefined {
224 if (commandQueue.length === 0) {
225 return undefined
226 }
227 let bestIdx = -1
228 let bestPriority = Infinity
229 for (let i = 0; i < commandQueue.length; i++) {
230 const cmd = commandQueue[i]!
231 if (filter && !filter(cmd)) continue
232 const priority = PRIORITY_ORDER[cmd.priority ?? 'next']
233 if (priority < bestPriority) {
234 bestIdx = i
235 bestPriority = priority
236 }
237 }
238 if (bestIdx === -1) return undefined
239 return commandQueue[bestIdx]
240}
241
242/**
243 * Remove and return all commands matching a predicate, preserving priority order.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected