123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- declare module "readline" {
- import * as events from "events";
- import * as stream from "stream";
-
- interface Key {
- sequence?: string;
- name?: string;
- ctrl?: boolean;
- meta?: boolean;
- shift?: boolean;
- }
-
- class Interface extends events.EventEmitter {
- readonly terminal: boolean;
-
- /**
- * NOTE: According to the documentation:
- *
- * > Instances of the `readline.Interface` class are constructed using the
- * > `readline.createInterface()` method.
- *
- * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
- */
- protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
- /**
- * NOTE: According to the documentation:
- *
- * > Instances of the `readline.Interface` class are constructed using the
- * > `readline.createInterface()` method.
- *
- * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
- */
- protected constructor(options: ReadLineOptions);
-
- setPrompt(prompt: string): void;
- prompt(preserveCursor?: boolean): void;
- question(query: string, callback: (answer: string) => void): void;
- pause(): this;
- resume(): this;
- close(): void;
- write(data: string | Buffer, key?: Key): void;
-
- /**
- * events.EventEmitter
- * 1. close
- * 2. line
- * 3. pause
- * 4. resume
- * 5. SIGCONT
- * 6. SIGINT
- * 7. SIGTSTP
- */
-
- addListener(event: string, listener: (...args: any[]) => void): this;
- addListener(event: "close", listener: () => void): this;
- addListener(event: "line", listener: (input: string) => void): this;
- addListener(event: "pause", listener: () => void): this;
- addListener(event: "resume", listener: () => void): this;
- addListener(event: "SIGCONT", listener: () => void): this;
- addListener(event: "SIGINT", listener: () => void): this;
- addListener(event: "SIGTSTP", listener: () => void): this;
-
- emit(event: string | symbol, ...args: any[]): boolean;
- emit(event: "close"): boolean;
- emit(event: "line", input: string): boolean;
- emit(event: "pause"): boolean;
- emit(event: "resume"): boolean;
- emit(event: "SIGCONT"): boolean;
- emit(event: "SIGINT"): boolean;
- emit(event: "SIGTSTP"): boolean;
-
- on(event: string, listener: (...args: any[]) => void): this;
- on(event: "close", listener: () => void): this;
- on(event: "line", listener: (input: string) => void): this;
- on(event: "pause", listener: () => void): this;
- on(event: "resume", listener: () => void): this;
- on(event: "SIGCONT", listener: () => void): this;
- on(event: "SIGINT", listener: () => void): this;
- on(event: "SIGTSTP", listener: () => void): this;
-
- once(event: string, listener: (...args: any[]) => void): this;
- once(event: "close", listener: () => void): this;
- once(event: "line", listener: (input: string) => void): this;
- once(event: "pause", listener: () => void): this;
- once(event: "resume", listener: () => void): this;
- once(event: "SIGCONT", listener: () => void): this;
- once(event: "SIGINT", listener: () => void): this;
- once(event: "SIGTSTP", listener: () => void): this;
-
- prependListener(event: string, listener: (...args: any[]) => void): this;
- prependListener(event: "close", listener: () => void): this;
- prependListener(event: "line", listener: (input: string) => void): this;
- prependListener(event: "pause", listener: () => void): this;
- prependListener(event: "resume", listener: () => void): this;
- prependListener(event: "SIGCONT", listener: () => void): this;
- prependListener(event: "SIGINT", listener: () => void): this;
- prependListener(event: "SIGTSTP", listener: () => void): this;
-
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
- prependOnceListener(event: "close", listener: () => void): this;
- prependOnceListener(event: "line", listener: (input: string) => void): this;
- prependOnceListener(event: "pause", listener: () => void): this;
- prependOnceListener(event: "resume", listener: () => void): this;
- prependOnceListener(event: "SIGCONT", listener: () => void): this;
- prependOnceListener(event: "SIGINT", listener: () => void): this;
- prependOnceListener(event: "SIGTSTP", listener: () => void): this;
- [Symbol.asyncIterator](): AsyncIterableIterator<string>;
- }
-
- type ReadLine = Interface; // type forwarded for backwards compatiblity
-
- type Completer = (line: string) => CompleterResult;
- type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => any;
-
- type CompleterResult = [string[], string];
-
- interface ReadLineOptions {
- input: NodeJS.ReadableStream;
- output?: NodeJS.WritableStream;
- completer?: Completer | AsyncCompleter;
- terminal?: boolean;
- historySize?: number;
- prompt?: string;
- crlfDelay?: number;
- removeHistoryDuplicates?: boolean;
- }
-
- function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
- function createInterface(options: ReadLineOptions): Interface;
-
- function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number): void;
- function emitKeypressEvents(stream: NodeJS.ReadableStream, interface?: Interface): void;
- function moveCursor(stream: NodeJS.WritableStream, dx: number | string, dy: number | string): void;
- function clearLine(stream: NodeJS.WritableStream, dir: number): void;
- function clearScreenDown(stream: NodeJS.WritableStream): void;
- }
|