UNPKG

1.11 kBTypeScriptView Raw
1// Modified from the node.js definitions.
2// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/readline.d.ts
3
4import * as readline from "readline";
5export * from "readline";
6export { Completer as SyncCompleter } from "readline";
7
8export class Interface extends readline.Interface {
9 question(query: string, callback: (answer: string) => void): void;
10 question(query: string): Promise<string>;
11}
12
13// type forwarded for backwards compatibility
14export type ReadLine = Interface;
15
16export type AsyncCompleter =
17 | ((line: string, callback: (err?: null | Error, result?: readline.CompleterResult) => void) => void)
18 | ((line: string) => Promise<readline.CompleterResult>);
19export type Completer = AsyncCompleter | readline.Completer;
20
21export interface ReadLineOptions extends readline.ReadLineOptions {
22 completer?: Completer | undefined;
23}
24
25export function createInterface(
26 input: NodeJS.ReadableStream,
27 output?: NodeJS.WritableStream,
28 completer?: Completer,
29 terminal?: boolean,
30): Interface;
31export function createInterface(options: ReadLineOptions): Interface;
32
\No newline at end of file