MCPcopy
hub / github.com/mksglu/context-mode / onData

Function onData

tests/core/server.test.ts:977–994  ·  view source on GitHub ↗
(d: Buffer)

Source from the content-addressed store, hash-verified

975 return new Promise((resolve) => {
976 let buffer = "";
977 const onData = (d: Buffer) => {
978 buffer += d.toString();
979 let idx: number;
980 while ((idx = buffer.indexOf("\n")) >= 0) {
981 const line = buffer.slice(0, idx).trim();
982 buffer = buffer.slice(idx + 1);
983 if (!line) continue;
984 try {
985 const parsed = JSON.parse(line) as DoctorJsonRpcResponse;
986 if (parsed.id === id) {
987 proc.stdout!.off("data", onData);
988 clearTimeout(timer);
989 resolve(parsed);
990 return;
991 }
992 } catch { /* ignore */ }
993 }
994 };
995 const timer = setTimeout(() => {
996 proc.stdout!.off("data", onData);
997 resolve(undefined);

Callers

nothing calls this directly

Calls 3

toStringMethod · 0.45
trimMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected