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

Function peekForStdinData

source code/utils/process.ts:52–70  ·  view source on GitHub ↗
(
  stream: NodeJS.EventEmitter,
  ms: number,
)

Source from the content-addressed store, hash-verified

50// Returns true on timeout, false on end. Used by -p mode to distinguish a
51// real pipe producer from an inherited-but-idle parent stdin.
52export function peekForStdinData(
53 stream: NodeJS.EventEmitter,
54 ms: number,
55): Promise<boolean> {
56 return new Promise<boolean>(resolve => {
57 const done = (timedOut: boolean) => {
58 clearTimeout(peek)
59 stream.off('end', onEnd)
60 stream.off('data', onFirstData)
61 void resolve(timedOut)
62 }
63 const onEnd = () => done(false)
64 const onFirstData = () => clearTimeout(peek)
65 // eslint-disable-next-line no-restricted-syntax -- not a sleep: races timeout against stream end/data events
66 const peek = setTimeout(done, ms, true)
67 stream.once('end', onEnd)
68 stream.once('data', onFirstData)
69 })
70}

Callers 1

getInputPromptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected