MCPcopy Create free account
hub / github.com/bombshell-dev/clack / clear

Function clear

packages/core/src/utils/index.ts:52–68  ·  view source on GitHub ↗
(data: Buffer, { name, sequence }: Key)

Source from the content-addressed store, hash-verified

50 }
51
52 const clear = (data: Buffer, { name, sequence }: Key) => {
53 const str = String(data);
54 if (isActionKey([str, name, sequence], 'cancel')) {
55 if (hideCursor) output.write(cursor.show);
56 process.exit(0);
57 return;
58 }
59 if (!overwrite) return;
60 const dx = name === 'return' ? 0 : -1;
61 const dy = name === 'return' ? -1 : 0;
62
63 readline.moveCursor(output, dx, dy, () => {
64 readline.clearLine(output, 1, () => {
65 input.once('keypress', clear);
66 });
67 });
68 };
69 if (hideCursor) output.write(cursor.hide);
70 input.once('keypress', clear);
71

Callers

nothing calls this directly

Calls 2

isActionKeyFunction · 0.85
onceMethod · 0.80

Tested by

no test coverage detected