()
| 152 | }; |
| 153 | |
| 154 | const cleanup = (): void => { |
| 155 | try { stdin.removeListener('keypress', onKey); } catch { /* ignore */ } |
| 156 | try { if (stdin.isTTY) (stdin as any).setRawMode(false); } catch { /* ignore */ } |
| 157 | stdout.write('\x1b[?25h'); // restore cursor |
| 158 | try { stdin.pause(); } catch { /* ignore */ } |
| 159 | }; |
| 160 | |
| 161 | let numBuf = ''; |
| 162 | let numTimer: ReturnType<typeof setTimeout> | undefined; |