MCPcopy Create free account
hub / github.com/antvis/AVA / onData

Function onData

src/cli/feishu.ts:29–52  ·  view source on GitHub ↗
(chunk: Buffer)

Source from the content-addressed store, hash-verified

27 return new Promise<string>((resolve) => {
28 let value = '';
29 const onData = (chunk: Buffer) => {
30 const key = chunk.toString();
31 if (key === '\u0003') {
32 input.setRawMode(false);
33 process.exit(130);
34 }
35 if (key === '\r' || key === '\n') {
36 input.setRawMode(false);
37 input.pause();
38 input.off('data', onData);
39 process.stderr.write('\n');
40 resolve(value);
41 return;
42 }
43 if (key === '\u007f' || key === '\b') {
44 if (!value) return;
45 value = value.slice(0, -1);
46 if (echo) process.stderr.write('\b \b');
47 return;
48 } else {
49 value += key;
50 if (echo) process.stderr.write(key);
51 }
52 };
53 input.on('data', onData);
54 });
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected