source: trip-planner-front/node_modules/@types/node/readline.d.ts@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 6.9 KB
Line 
1declare module 'readline' {
2 import EventEmitter = require('events');
3
4 interface Key {
5 sequence?: string | undefined;
6 name?: string | undefined;
7 ctrl?: boolean | undefined;
8 meta?: boolean | undefined;
9 shift?: boolean | undefined;
10 }
11
12 class Interface extends EventEmitter {
13 readonly terminal: boolean;
14
15 // Need direct access to line/cursor data, for use in external processes
16 // see: https://github.com/nodejs/node/issues/30347
17 /** The current input data */
18 readonly line: string;
19 /** The current cursor position in the input line */
20 readonly cursor: number;
21
22 /**
23 * NOTE: According to the documentation:
24 *
25 * > Instances of the `readline.Interface` class are constructed using the
26 * > `readline.createInterface()` method.
27 *
28 * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
29 */
30 protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
31 /**
32 * NOTE: According to the documentation:
33 *
34 * > Instances of the `readline.Interface` class are constructed using the
35 * > `readline.createInterface()` method.
36 *
37 * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
38 */
39 protected constructor(options: ReadLineOptions);
40
41 setPrompt(prompt: string): void;
42 prompt(preserveCursor?: boolean): void;
43 question(query: string, callback: (answer: string) => void): void;
44 pause(): this;
45 resume(): this;
46 close(): void;
47 write(data: string | Buffer, key?: Key): void;
48
49 /**
50 * events.EventEmitter
51 * 1. close
52 * 2. line
53 * 3. pause
54 * 4. resume
55 * 5. SIGCONT
56 * 6. SIGINT
57 * 7. SIGTSTP
58 */
59
60 addListener(event: string, listener: (...args: any[]) => void): this;
61 addListener(event: "close", listener: () => void): this;
62 addListener(event: "line", listener: (input: string) => void): this;
63 addListener(event: "pause", listener: () => void): this;
64 addListener(event: "resume", listener: () => void): this;
65 addListener(event: "SIGCONT", listener: () => void): this;
66 addListener(event: "SIGINT", listener: () => void): this;
67 addListener(event: "SIGTSTP", listener: () => void): this;
68
69 emit(event: string | symbol, ...args: any[]): boolean;
70 emit(event: "close"): boolean;
71 emit(event: "line", input: string): boolean;
72 emit(event: "pause"): boolean;
73 emit(event: "resume"): boolean;
74 emit(event: "SIGCONT"): boolean;
75 emit(event: "SIGINT"): boolean;
76 emit(event: "SIGTSTP"): boolean;
77
78 on(event: string, listener: (...args: any[]) => void): this;
79 on(event: "close", listener: () => void): this;
80 on(event: "line", listener: (input: string) => void): this;
81 on(event: "pause", listener: () => void): this;
82 on(event: "resume", listener: () => void): this;
83 on(event: "SIGCONT", listener: () => void): this;
84 on(event: "SIGINT", listener: () => void): this;
85 on(event: "SIGTSTP", listener: () => void): this;
86
87 once(event: string, listener: (...args: any[]) => void): this;
88 once(event: "close", listener: () => void): this;
89 once(event: "line", listener: (input: string) => void): this;
90 once(event: "pause", listener: () => void): this;
91 once(event: "resume", listener: () => void): this;
92 once(event: "SIGCONT", listener: () => void): this;
93 once(event: "SIGINT", listener: () => void): this;
94 once(event: "SIGTSTP", listener: () => void): this;
95
96 prependListener(event: string, listener: (...args: any[]) => void): this;
97 prependListener(event: "close", listener: () => void): this;
98 prependListener(event: "line", listener: (input: string) => void): this;
99 prependListener(event: "pause", listener: () => void): this;
100 prependListener(event: "resume", listener: () => void): this;
101 prependListener(event: "SIGCONT", listener: () => void): this;
102 prependListener(event: "SIGINT", listener: () => void): this;
103 prependListener(event: "SIGTSTP", listener: () => void): this;
104
105 prependOnceListener(event: string, listener: (...args: any[]) => void): this;
106 prependOnceListener(event: "close", listener: () => void): this;
107 prependOnceListener(event: "line", listener: (input: string) => void): this;
108 prependOnceListener(event: "pause", listener: () => void): this;
109 prependOnceListener(event: "resume", listener: () => void): this;
110 prependOnceListener(event: "SIGCONT", listener: () => void): this;
111 prependOnceListener(event: "SIGINT", listener: () => void): this;
112 prependOnceListener(event: "SIGTSTP", listener: () => void): this;
113 [Symbol.asyncIterator](): AsyncIterableIterator<string>;
114 }
115
116 type ReadLine = Interface; // type forwarded for backwards compatiblity
117
118 type Completer = (line: string) => CompleterResult;
119 type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => any;
120
121 type CompleterResult = [string[], string];
122
123 interface ReadLineOptions {
124 input: NodeJS.ReadableStream;
125 output?: NodeJS.WritableStream | undefined;
126 completer?: Completer | AsyncCompleter | undefined;
127 terminal?: boolean | undefined;
128 historySize?: number | undefined;
129 prompt?: string | undefined;
130 crlfDelay?: number | undefined;
131 removeHistoryDuplicates?: boolean | undefined;
132 escapeCodeTimeout?: number | undefined;
133 }
134
135 function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
136 function createInterface(options: ReadLineOptions): Interface;
137 function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
138
139 type Direction = -1 | 0 | 1;
140
141 /**
142 * Clears the current line of this WriteStream in a direction identified by `dir`.
143 */
144 function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
145 /**
146 * Clears this `WriteStream` from the current cursor down.
147 */
148 function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
149 /**
150 * Moves this WriteStream's cursor to the specified position.
151 */
152 function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
153 /**
154 * Moves this WriteStream's cursor relative to its current position.
155 */
156 function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
157}
Note: See TracBrowser for help on using the repository browser.