m06_task3.js 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. package/.idea/.name +1 -0
  2. package/.idea/inspectionProfiles/Project_Default.xml +10 -0
  3. package/.idea/jsLibraryMappings.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/node_lab_6.iml +12 -0
  6. package/06_task2.html +73 -0
  7. package/06_task2.js +52 -0
  8. package/06_task3.js +3 -0
  9. package/06_task4.js +3 -0
  10. package/m06_task3.js +28 -0
  11. package/package/index.js +28 -0
  12. package/package/node_modules/.package-lock.json +31 -0
  13. package/package/node_modules/@types/node/LICENSE +21 -0
  14. package/package/node_modules/@types/node/README.md +16 -0
  15. package/package/node_modules/@types/node/assert/strict.d.ts +8 -0
  16. package/package/node_modules/@types/node/assert.d.ts +961 -0
  17. package/package/node_modules/@types/node/async_hooks.d.ts +501 -0
  18. package/package/node_modules/@types/node/buffer.d.ts +2258 -0
  19. package/package/node_modules/@types/node/child_process.d.ts +1369 -0
  20. package/package/node_modules/@types/node/cluster.d.ts +410 -0
  21. package/package/node_modules/@types/node/console.d.ts +412 -0
  22. package/package/node_modules/@types/node/constants.d.ts +18 -0
  23. package/package/node_modules/@types/node/crypto.d.ts +3964 -0
  24. package/package/node_modules/@types/node/dgram.d.ts +545 -0
  25. package/package/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
  26. package/package/node_modules/@types/node/dns/promises.d.ts +370 -0
  27. package/package/node_modules/@types/node/dns.d.ts +659 -0
  28. package/package/node_modules/@types/node/dom-events.d.ts +126 -0
  29. package/package/node_modules/@types/node/domain.d.ts +170 -0
  30. package/package/node_modules/@types/node/events.d.ts +678 -0
  31. package/package/node_modules/@types/node/fs/promises.d.ts +1138 -0
  32. package/package/node_modules/@types/node/fs.d.ts +3872 -0
  33. package/package/node_modules/@types/node/globals.d.ts +300 -0
  34. package/package/node_modules/@types/node/globals.global.d.ts +1 -0
  35. package/package/node_modules/@types/node/http.d.ts +1614 -0
  36. package/package/node_modules/@types/node/http2.d.ts +2134 -0
  37. package/package/node_modules/@types/node/https.d.ts +541 -0
  38. package/package/node_modules/@types/node/index.d.ts +133 -0
  39. package/package/node_modules/@types/node/inspector.d.ts +2741 -0
  40. package/package/node_modules/@types/node/module.d.ts +114 -0
  41. package/package/node_modules/@types/node/net.d.ts +869 -0
  42. package/package/node_modules/@types/node/os.d.ts +466 -0
  43. package/package/node_modules/@types/node/package.json +232 -0
  44. package/package/node_modules/@types/node/path.d.ts +191 -0
  45. package/package/node_modules/@types/node/perf_hooks.d.ts +625 -0
  46. package/package/node_modules/@types/node/process.d.ts +1482 -0
  47. package/package/node_modules/@types/node/punycode.d.ts +117 -0
  48. package/package/node_modules/@types/node/querystring.d.ts +131 -0
  49. package/package/node_modules/@types/node/readline/promises.d.ts +143 -0
  50. package/package/node_modules/@types/node/readline.d.ts +653 -0
  51. package/package/node_modules/@types/node/repl.d.ts +424 -0
  52. package/package/node_modules/@types/node/stream/consumers.d.ts +12 -0
  53. package/package/node_modules/@types/node/stream/promises.d.ts +42 -0
  54. package/package/node_modules/@types/node/stream/web.d.ts +330 -0
  55. package/package/node_modules/@types/node/stream.d.ts +1340 -0
  56. package/package/node_modules/@types/node/string_decoder.d.ts +67 -0
  57. package/package/node_modules/@types/node/test.d.ts +314 -0
  58. package/package/node_modules/@types/node/timers/promises.d.ts +68 -0
  59. package/package/node_modules/@types/node/timers.d.ts +94 -0
  60. package/package/node_modules/@types/node/tls.d.ts +1028 -0
  61. package/package/node_modules/@types/node/trace_events.d.ts +171 -0
  62. package/package/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  63. package/package/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
  64. package/package/node_modules/@types/node/ts4.8/async_hooks.d.ts +501 -0
  65. package/package/node_modules/@types/node/ts4.8/buffer.d.ts +2259 -0
  66. package/package/node_modules/@types/node/ts4.8/child_process.d.ts +1369 -0
  67. package/package/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
  68. package/package/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  69. package/package/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  70. package/package/node_modules/@types/node/ts4.8/crypto.d.ts +3964 -0
  71. package/package/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
  72. package/package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +153 -0
  73. package/package/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
  74. package/package/node_modules/@types/node/ts4.8/dns.d.ts +659 -0
  75. package/package/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
  76. package/package/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  77. package/package/node_modules/@types/node/ts4.8/events.d.ts +678 -0
  78. package/package/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
  79. package/package/node_modules/@types/node/ts4.8/fs.d.ts +3872 -0
  80. package/package/node_modules/@types/node/ts4.8/globals.d.ts +294 -0
  81. package/package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  82. package/package/node_modules/@types/node/ts4.8/http.d.ts +1614 -0
  83. package/package/node_modules/@types/node/ts4.8/http2.d.ts +2134 -0
  84. package/package/node_modules/@types/node/ts4.8/https.d.ts +541 -0
  85. package/package/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  86. package/package/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
  87. package/package/node_modules/@types/node/ts4.8/module.d.ts +114 -0
  88. package/package/node_modules/@types/node/ts4.8/net.d.ts +869 -0
  89. package/package/node_modules/@types/node/ts4.8/os.d.ts +466 -0
  90. package/package/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  91. package/package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
  92. package/package/node_modules/@types/node/ts4.8/process.d.ts +1482 -0
  93. package/package/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  94. package/package/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
  95. package/package/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
  96. package/package/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
  97. package/package/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
  98. package/package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  99. package/package/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
  100. package/package/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
  101. package/package/node_modules/@types/node/ts4.8/stream.d.ts +1340 -0
  102. package/package/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  103. package/package/node_modules/@types/node/ts4.8/test.d.ts +314 -0
  104. package/package/node_modules/@types/node/ts4.8/timers/promises.d.ts +68 -0
  105. package/package/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
  106. package/package/node_modules/@types/node/ts4.8/tls.d.ts +1028 -0
  107. package/package/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
  108. package/package/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
  109. package/package/node_modules/@types/node/ts4.8/url.d.ts +897 -0
  110. package/package/node_modules/@types/node/ts4.8/util.d.ts +1850 -0
  111. package/package/node_modules/@types/node/ts4.8/v8.d.ts +396 -0
  112. package/package/node_modules/@types/node/ts4.8/vm.d.ts +509 -0
  113. package/package/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  114. package/package/node_modules/@types/node/ts4.8/worker_threads.d.ts +689 -0
  115. package/package/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  116. package/package/node_modules/@types/node/tty.d.ts +206 -0
  117. package/package/node_modules/@types/node/url.d.ts +897 -0
  118. package/package/node_modules/@types/node/util.d.ts +1850 -0
  119. package/package/node_modules/@types/node/v8.d.ts +396 -0
  120. package/package/node_modules/@types/node/vm.d.ts +509 -0
  121. package/package/node_modules/@types/node/wasi.d.ts +158 -0
  122. package/package/node_modules/@types/node/worker_threads.d.ts +689 -0
  123. package/package/node_modules/@types/node/zlib.d.ts +517 -0
  124. package/package/node_modules/@types/nodemailer/LICENSE +21 -0
  125. package/package/node_modules/@types/nodemailer/README.md +16 -0
  126. package/package/node_modules/@types/nodemailer/index.d.ts +83 -0
  127. package/package/node_modules/@types/nodemailer/lib/addressparser/index.d.ts +31 -0
  128. package/package/node_modules/@types/nodemailer/lib/base64/index.d.ts +22 -0
  129. package/package/node_modules/@types/nodemailer/lib/dkim/index.d.ts +45 -0
  130. package/package/node_modules/@types/nodemailer/lib/dkim/message-parser.d.ts +75 -0
  131. package/package/node_modules/@types/nodemailer/lib/dkim/relaxed-body.d.ts +75 -0
  132. package/package/node_modules/@types/nodemailer/lib/dkim/sign.d.ts +11 -0
  133. package/package/node_modules/@types/nodemailer/lib/fetch/cookies.d.ts +54 -0
  134. package/package/node_modules/@types/nodemailer/lib/fetch/index.d.ts +38 -0
  135. package/package/node_modules/@types/nodemailer/lib/json-transport/index.d.ts +50 -0
  136. package/package/node_modules/@types/nodemailer/lib/mail-composer/index.d.ts +25 -0
  137. package/package/node_modules/@types/nodemailer/lib/mailer/index.d.ts +230 -0
  138. package/package/node_modules/@types/nodemailer/lib/mailer/mail-message.d.ts +28 -0
  139. package/package/node_modules/@types/nodemailer/lib/mime-funcs/index.d.ts +87 -0
  140. package/package/node_modules/@types/nodemailer/lib/mime-funcs/mime-types.d.ts +2 -0
  141. package/package/node_modules/@types/nodemailer/lib/mime-node/index.d.ts +137 -0
  142. package/package/node_modules/@types/nodemailer/lib/mime-node/last-newline.d.ts +9 -0
  143. package/package/node_modules/@types/nodemailer/lib/qp/index.d.ts +23 -0
  144. package/package/node_modules/@types/nodemailer/lib/sendmail-transport/index.d.ts +53 -0
  145. package/package/node_modules/@types/nodemailer/lib/sendmail-transport/le-unix.d.ts +7 -0
  146. package/package/node_modules/@types/nodemailer/lib/sendmail-transport/le-windows.d.ts +7 -0
  147. package/package/node_modules/@types/nodemailer/lib/ses-transport/index.d.ts +136 -0
  148. package/package/node_modules/@types/nodemailer/lib/shared/index.d.ts +51 -0
  149. package/package/node_modules/@types/nodemailer/lib/smtp-connection/data-stream.d.ts +11 -0
  150. package/package/node_modules/@types/nodemailer/lib/smtp-connection/http-proxy-client.d.ts +11 -0
  151. package/package/node_modules/@types/nodemailer/lib/smtp-connection/index.d.ts +254 -0
  152. package/package/node_modules/@types/nodemailer/lib/smtp-pool/index.d.ts +90 -0
  153. package/package/node_modules/@types/nodemailer/lib/smtp-pool/pool-resource.d.ts +66 -0
  154. package/package/node_modules/@types/nodemailer/lib/smtp-transport/index.d.ts +115 -0
  155. package/package/node_modules/@types/nodemailer/lib/stream-transport/index.d.ts +56 -0
  156. package/package/node_modules/@types/nodemailer/lib/well-known/index.d.ts +6 -0
  157. package/package/node_modules/@types/nodemailer/lib/xoauth2/index.d.ts +110 -0
  158. package/package/node_modules/@types/nodemailer/package.json +37 -0
  159. package/package/node_modules/nodemailer/.gitattributes +6 -0
  160. package/package/node_modules/nodemailer/.prettierrc.js +8 -0
  161. package/package/node_modules/nodemailer/CHANGELOG.md +715 -0
  162. package/package/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
  163. package/package/node_modules/nodemailer/CONTRIBUTING.md +67 -0
  164. package/package/node_modules/nodemailer/LICENSE +16 -0
  165. package/package/node_modules/nodemailer/README.md +93 -0
  166. package/package/node_modules/nodemailer/SECURITY.txt +22 -0
  167. package/package/node_modules/nodemailer/lib/addressparser/index.js +313 -0
  168. package/package/node_modules/nodemailer/lib/base64/index.js +142 -0
  169. package/package/node_modules/nodemailer/lib/dkim/index.js +251 -0
  170. package/package/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
  171. package/package/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
  172. package/package/node_modules/nodemailer/lib/dkim/sign.js +117 -0
  173. package/package/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
  174. package/package/node_modules/nodemailer/lib/fetch/index.js +269 -0
  175. package/package/node_modules/nodemailer/lib/json-transport/index.js +82 -0
  176. package/package/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
  177. package/package/node_modules/nodemailer/lib/mailer/index.js +427 -0
  178. package/package/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
  179. package/package/node_modules/nodemailer/lib/mime-funcs/index.js +619 -0
  180. package/package/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
  181. package/package/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
  182. package/package/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
  183. package/package/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
  184. package/package/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
  185. package/package/node_modules/nodemailer/lib/nodemailer.js +143 -0
  186. package/package/node_modules/nodemailer/lib/qp/index.js +219 -0
  187. package/package/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
  188. package/package/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
  189. package/package/node_modules/nodemailer/lib/shared/index.js +639 -0
  190. package/package/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
  191. package/package/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
  192. package/package/node_modules/nodemailer/lib/smtp-connection/index.js +1786 -0
  193. package/package/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
  194. package/package/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
  195. package/package/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
  196. package/package/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
  197. package/package/node_modules/nodemailer/lib/well-known/index.js +47 -0
  198. package/package/node_modules/nodemailer/lib/well-known/services.json +286 -0
  199. package/package/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
  200. package/package/node_modules/nodemailer/package.json +46 -0
  201. package/package/node_modules/nodemailer/postinstall.js +101 -0
  202. package/package/package-lock.json +60 -0
  203. package/package/package.json +6 -0
  204. package/package.json +19 -0
@@ -0,0 +1,653 @@
1
+ /**
2
+ * The `readline` module provides an interface for reading data from a `Readable` stream (such as `process.stdin`) one line at a time.
3
+ *
4
+ * To use the promise-based APIs:
5
+ *
6
+ * ```js
7
+ * import * as readline from 'node:readline/promises';
8
+ * ```
9
+ *
10
+ * To use the callback and sync APIs:
11
+ *
12
+ * ```js
13
+ * import * as readline from 'node:readline';
14
+ * ```
15
+ *
16
+ * The following simple example illustrates the basic use of the `readline` module.
17
+ *
18
+ * ```js
19
+ * import * as readline from 'node:readline/promises';
20
+ * import { stdin as input, stdout as output } from 'node:process';
21
+ *
22
+ * const rl = readline.createInterface({ input, output });
23
+ *
24
+ * const answer = await rl.question('What do you think of Node.js? ');
25
+ *
26
+ * console.log(`Thank you for your valuable feedback: ${answer}`);
27
+ *
28
+ * rl.close();
29
+ * ```
30
+ *
31
+ * Once this code is invoked, the Node.js application will not terminate until the`readline.Interface` is closed because the interface waits for data to be
32
+ * received on the `input` stream.
33
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/readline.js)
34
+ */
35
+ declare module 'readline' {
36
+ import { Abortable, EventEmitter } from 'node:events';
37
+ import * as promises from 'node:readline/promises';
38
+
39
+ export { promises };
40
+ export interface Key {
41
+ sequence?: string | undefined;
42
+ name?: string | undefined;
43
+ ctrl?: boolean | undefined;
44
+ meta?: boolean | undefined;
45
+ shift?: boolean | undefined;
46
+ }
47
+ /**
48
+ * Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a
49
+ * single `input` `Readable` stream and a single `output` `Writable` stream.
50
+ * The `output` stream is used to print prompts for user input that arrives on,
51
+ * and is read from, the `input` stream.
52
+ * @since v0.1.104
53
+ */
54
+ export class Interface extends EventEmitter {
55
+ readonly terminal: boolean;
56
+ /**
57
+ * The current input data being processed by node.
58
+ *
59
+ * This can be used when collecting input from a TTY stream to retrieve the
60
+ * current value that has been processed thus far, prior to the `line` event
61
+ * being emitted. Once the `line` event has been emitted, this property will
62
+ * be an empty string.
63
+ *
64
+ * Be aware that modifying the value during the instance runtime may have
65
+ * unintended consequences if `rl.cursor` is not also controlled.
66
+ *
67
+ * **If not using a TTY stream for input, use the `'line'` event.**
68
+ *
69
+ * One possible use case would be as follows:
70
+ *
71
+ * ```js
72
+ * const values = ['lorem ipsum', 'dolor sit amet'];
73
+ * const rl = readline.createInterface(process.stdin);
74
+ * const showResults = debounce(() => {
75
+ * console.log(
76
+ * '\n',
77
+ * values.filter((val) => val.startsWith(rl.line)).join(' ')
78
+ * );
79
+ * }, 300);
80
+ * process.stdin.on('keypress', (c, k) => {
81
+ * showResults();
82
+ * });
83
+ * ```
84
+ * @since v0.1.98
85
+ */
86
+ readonly line: string;
87
+ /**
88
+ * The cursor position relative to `rl.line`.
89
+ *
90
+ * This will track where the current cursor lands in the input string, when
91
+ * reading input from a TTY stream. The position of cursor determines the
92
+ * portion of the input string that will be modified as input is processed,
93
+ * as well as the column where the terminal caret will be rendered.
94
+ * @since v0.1.98
95
+ */
96
+ readonly cursor: number;
97
+ /**
98
+ * NOTE: According to the documentation:
99
+ *
100
+ * > Instances of the `readline.Interface` class are constructed using the
101
+ * > `readline.createInterface()` method.
102
+ *
103
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
104
+ */
105
+ protected constructor(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean);
106
+ /**
107
+ * NOTE: According to the documentation:
108
+ *
109
+ * > Instances of the `readline.Interface` class are constructed using the
110
+ * > `readline.createInterface()` method.
111
+ *
112
+ * @see https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_class_interface
113
+ */
114
+ protected constructor(options: ReadLineOptions);
115
+ /**
116
+ * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
117
+ * @since v15.3.0
118
+ * @return the current prompt string
119
+ */
120
+ getPrompt(): string;
121
+ /**
122
+ * The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called.
123
+ * @since v0.1.98
124
+ */
125
+ setPrompt(prompt: string): void;
126
+ /**
127
+ * The `rl.prompt()` method writes the `readline.Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
128
+ * location at which to provide input.
129
+ *
130
+ * When called, `rl.prompt()` will resume the `input` stream if it has been
131
+ * paused.
132
+ *
133
+ * If the `readline.Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
134
+ * @since v0.1.98
135
+ * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`.
136
+ */
137
+ prompt(preserveCursor?: boolean): void;
138
+ /**
139
+ * The `rl.question()` method displays the `query` by writing it to the `output`,
140
+ * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument.
141
+ *
142
+ * When called, `rl.question()` will resume the `input` stream if it has been
143
+ * paused.
144
+ *
145
+ * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
146
+ *
147
+ * The `callback` function passed to `rl.question()` does not follow the typical
148
+ * pattern of accepting an `Error` object or `null` as the first argument.
149
+ * The `callback` is called with the provided answer as the only argument.
150
+ *
151
+ * Example usage:
152
+ *
153
+ * ```js
154
+ * rl.question('What is your favorite food? ', (answer) => {
155
+ * console.log(`Oh, so your favorite food is ${answer}`);
156
+ * });
157
+ * ```
158
+ *
159
+ * Using an `AbortController` to cancel a question.
160
+ *
161
+ * ```js
162
+ * const ac = new AbortController();
163
+ * const signal = ac.signal;
164
+ *
165
+ * rl.question('What is your favorite food? ', { signal }, (answer) => {
166
+ * console.log(`Oh, so your favorite food is ${answer}`);
167
+ * });
168
+ *
169
+ * signal.addEventListener('abort', () => {
170
+ * console.log('The food question timed out');
171
+ * }, { once: true });
172
+ *
173
+ * setTimeout(() => ac.abort(), 10000);
174
+ * ```
175
+ *
176
+ * If this method is invoked as it's util.promisify()ed version, it returns a
177
+ * Promise that fulfills with the answer. If the question is canceled using
178
+ * an `AbortController` it will reject with an `AbortError`.
179
+ *
180
+ * ```js
181
+ * const util = require('util');
182
+ * const question = util.promisify(rl.question).bind(rl);
183
+ *
184
+ * async function questionExample() {
185
+ * try {
186
+ * const answer = await question('What is you favorite food? ');
187
+ * console.log(`Oh, so your favorite food is ${answer}`);
188
+ * } catch (err) {
189
+ * console.error('Question rejected', err);
190
+ * }
191
+ * }
192
+ * questionExample();
193
+ * ```
194
+ * @since v0.3.3
195
+ * @param query A statement or query to write to `output`, prepended to the prompt.
196
+ * @param callback A callback function that is invoked with the user's input in response to the `query`.
197
+ */
198
+ question(query: string, callback: (answer: string) => void): void;
199
+ question(query: string, options: Abortable, callback: (answer: string) => void): void;
200
+ /**
201
+ * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
202
+ * later if necessary.
203
+ *
204
+ * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `readline.Interface` instance.
205
+ * @since v0.3.4
206
+ */
207
+ pause(): this;
208
+ /**
209
+ * The `rl.resume()` method resumes the `input` stream if it has been paused.
210
+ * @since v0.3.4
211
+ */
212
+ resume(): this;
213
+ /**
214
+ * The `rl.close()` method closes the `readline.Interface` instance and
215
+ * relinquishes control over the `input` and `output` streams. When called,
216
+ * the `'close'` event will be emitted.
217
+ *
218
+ * Calling `rl.close()` does not immediately stop other events (including `'line'`)
219
+ * from being emitted by the `readline.Interface` instance.
220
+ * @since v0.1.98
221
+ */
222
+ close(): void;
223
+ /**
224
+ * The `rl.write()` method will write either `data` or a key sequence identified
225
+ * by `key` to the `output`. The `key` argument is supported only if `output` is
226
+ * a `TTY` text terminal. See `TTY keybindings` for a list of key
227
+ * combinations.
228
+ *
229
+ * If `key` is specified, `data` is ignored.
230
+ *
231
+ * When called, `rl.write()` will resume the `input` stream if it has been
232
+ * paused.
233
+ *
234
+ * If the `readline.Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
235
+ *
236
+ * ```js
237
+ * rl.write('Delete this!');
238
+ * // Simulate Ctrl+U to delete the line written previously
239
+ * rl.write(null, { ctrl: true, name: 'u' });
240
+ * ```
241
+ *
242
+ * The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_.
243
+ * @since v0.1.98
244
+ */
245
+ write(data: string | Buffer, key?: Key): void;
246
+ write(data: undefined | null | string | Buffer, key: Key): void;
247
+ /**
248
+ * Returns the real position of the cursor in relation to the input
249
+ * prompt + string. Long input (wrapping) strings, as well as multiple
250
+ * line prompts are included in the calculations.
251
+ * @since v13.5.0, v12.16.0
252
+ */
253
+ getCursorPos(): CursorPos;
254
+ /**
255
+ * events.EventEmitter
256
+ * 1. close
257
+ * 2. line
258
+ * 3. pause
259
+ * 4. resume
260
+ * 5. SIGCONT
261
+ * 6. SIGINT
262
+ * 7. SIGTSTP
263
+ * 8. history
264
+ */
265
+ addListener(event: string, listener: (...args: any[]) => void): this;
266
+ addListener(event: 'close', listener: () => void): this;
267
+ addListener(event: 'line', listener: (input: string) => void): this;
268
+ addListener(event: 'pause', listener: () => void): this;
269
+ addListener(event: 'resume', listener: () => void): this;
270
+ addListener(event: 'SIGCONT', listener: () => void): this;
271
+ addListener(event: 'SIGINT', listener: () => void): this;
272
+ addListener(event: 'SIGTSTP', listener: () => void): this;
273
+ addListener(event: 'history', listener: (history: string[]) => void): this;
274
+ emit(event: string | symbol, ...args: any[]): boolean;
275
+ emit(event: 'close'): boolean;
276
+ emit(event: 'line', input: string): boolean;
277
+ emit(event: 'pause'): boolean;
278
+ emit(event: 'resume'): boolean;
279
+ emit(event: 'SIGCONT'): boolean;
280
+ emit(event: 'SIGINT'): boolean;
281
+ emit(event: 'SIGTSTP'): boolean;
282
+ emit(event: 'history', history: string[]): boolean;
283
+ on(event: string, listener: (...args: any[]) => void): this;
284
+ on(event: 'close', listener: () => void): this;
285
+ on(event: 'line', listener: (input: string) => void): this;
286
+ on(event: 'pause', listener: () => void): this;
287
+ on(event: 'resume', listener: () => void): this;
288
+ on(event: 'SIGCONT', listener: () => void): this;
289
+ on(event: 'SIGINT', listener: () => void): this;
290
+ on(event: 'SIGTSTP', listener: () => void): this;
291
+ on(event: 'history', listener: (history: string[]) => void): this;
292
+ once(event: string, listener: (...args: any[]) => void): this;
293
+ once(event: 'close', listener: () => void): this;
294
+ once(event: 'line', listener: (input: string) => void): this;
295
+ once(event: 'pause', listener: () => void): this;
296
+ once(event: 'resume', listener: () => void): this;
297
+ once(event: 'SIGCONT', listener: () => void): this;
298
+ once(event: 'SIGINT', listener: () => void): this;
299
+ once(event: 'SIGTSTP', listener: () => void): this;
300
+ once(event: 'history', listener: (history: string[]) => void): this;
301
+ prependListener(event: string, listener: (...args: any[]) => void): this;
302
+ prependListener(event: 'close', listener: () => void): this;
303
+ prependListener(event: 'line', listener: (input: string) => void): this;
304
+ prependListener(event: 'pause', listener: () => void): this;
305
+ prependListener(event: 'resume', listener: () => void): this;
306
+ prependListener(event: 'SIGCONT', listener: () => void): this;
307
+ prependListener(event: 'SIGINT', listener: () => void): this;
308
+ prependListener(event: 'SIGTSTP', listener: () => void): this;
309
+ prependListener(event: 'history', listener: (history: string[]) => void): this;
310
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
311
+ prependOnceListener(event: 'close', listener: () => void): this;
312
+ prependOnceListener(event: 'line', listener: (input: string) => void): this;
313
+ prependOnceListener(event: 'pause', listener: () => void): this;
314
+ prependOnceListener(event: 'resume', listener: () => void): this;
315
+ prependOnceListener(event: 'SIGCONT', listener: () => void): this;
316
+ prependOnceListener(event: 'SIGINT', listener: () => void): this;
317
+ prependOnceListener(event: 'SIGTSTP', listener: () => void): this;
318
+ prependOnceListener(event: 'history', listener: (history: string[]) => void): this;
319
+ [Symbol.asyncIterator](): AsyncIterableIterator<string>;
320
+ }
321
+ export type ReadLine = Interface; // type forwarded for backwards compatibility
322
+ export type Completer = (line: string) => CompleterResult;
323
+ export type AsyncCompleter = (line: string, callback: (err?: null | Error, result?: CompleterResult) => void) => void;
324
+ export type CompleterResult = [string[], string];
325
+ export interface ReadLineOptions {
326
+ input: NodeJS.ReadableStream;
327
+ output?: NodeJS.WritableStream | undefined;
328
+ completer?: Completer | AsyncCompleter | undefined;
329
+ terminal?: boolean | undefined;
330
+ /**
331
+ * Initial list of history lines. This option makes sense
332
+ * only if `terminal` is set to `true` by the user or by an internal `output`
333
+ * check, otherwise the history caching mechanism is not initialized at all.
334
+ * @default []
335
+ */
336
+ history?: string[] | undefined;
337
+ historySize?: number | undefined;
338
+ prompt?: string | undefined;
339
+ crlfDelay?: number | undefined;
340
+ /**
341
+ * If `true`, when a new input line added
342
+ * to the history list duplicates an older one, this removes the older line
343
+ * from the list.
344
+ * @default false
345
+ */
346
+ removeHistoryDuplicates?: boolean | undefined;
347
+ escapeCodeTimeout?: number | undefined;
348
+ tabSize?: number | undefined;
349
+ }
350
+ /**
351
+ * The `readline.createInterface()` method creates a new `readline.Interface`instance.
352
+ *
353
+ * ```js
354
+ * const readline = require('readline');
355
+ * const rl = readline.createInterface({
356
+ * input: process.stdin,
357
+ * output: process.stdout
358
+ * });
359
+ * ```
360
+ *
361
+ * Once the `readline.Interface` instance is created, the most common case is to
362
+ * listen for the `'line'` event:
363
+ *
364
+ * ```js
365
+ * rl.on('line', (line) => {
366
+ * console.log(`Received: ${line}`);
367
+ * });
368
+ * ```
369
+ *
370
+ * If `terminal` is `true` for this instance then the `output` stream will get
371
+ * the best compatibility if it defines an `output.columns` property and emits
372
+ * a `'resize'` event on the `output` if or when the columns ever change
373
+ * (`process.stdout` does this automatically when it is a TTY).
374
+ *
375
+ * When creating a `readline.Interface` using `stdin` as input, the program
376
+ * will not terminate until it receives `EOF` (Ctrl+D on
377
+ * Linux/macOS, Ctrl+Z followed by Return on
378
+ * Windows).
379
+ * If you want your application to exit without waiting for user input, you can `unref()` the standard input stream:
380
+ *
381
+ * ```js
382
+ * process.stdin.unref();
383
+ * ```
384
+ * @since v0.1.98
385
+ */
386
+ export function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface;
387
+ export function createInterface(options: ReadLineOptions): Interface;
388
+ /**
389
+ * The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
390
+ *
391
+ * Optionally, `interface` specifies a `readline.Interface` instance for which
392
+ * autocompletion is disabled when copy-pasted input is detected.
393
+ *
394
+ * If the `stream` is a `TTY`, then it must be in raw mode.
395
+ *
396
+ * This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop
397
+ * the `input` from emitting `'keypress'` events.
398
+ *
399
+ * ```js
400
+ * readline.emitKeypressEvents(process.stdin);
401
+ * if (process.stdin.isTTY)
402
+ * process.stdin.setRawMode(true);
403
+ * ```
404
+ *
405
+ * ## Example: Tiny CLI
406
+ *
407
+ * The following example illustrates the use of `readline.Interface` class to
408
+ * implement a small command-line interface:
409
+ *
410
+ * ```js
411
+ * const readline = require('readline');
412
+ * const rl = readline.createInterface({
413
+ * input: process.stdin,
414
+ * output: process.stdout,
415
+ * prompt: 'OHAI> '
416
+ * });
417
+ *
418
+ * rl.prompt();
419
+ *
420
+ * rl.on('line', (line) => {
421
+ * switch (line.trim()) {
422
+ * case 'hello':
423
+ * console.log('world!');
424
+ * break;
425
+ * default:
426
+ * console.log(`Say what? I might have heard '${line.trim()}'`);
427
+ * break;
428
+ * }
429
+ * rl.prompt();
430
+ * }).on('close', () => {
431
+ * console.log('Have a great day!');
432
+ * process.exit(0);
433
+ * });
434
+ * ```
435
+ *
436
+ * ## Example: Read file stream line-by-Line
437
+ *
438
+ * A common use case for `readline` is to consume an input file one line at a
439
+ * time. The easiest way to do so is leveraging the `fs.ReadStream` API as
440
+ * well as a `for await...of` loop:
441
+ *
442
+ * ```js
443
+ * const fs = require('fs');
444
+ * const readline = require('readline');
445
+ *
446
+ * async function processLineByLine() {
447
+ * const fileStream = fs.createReadStream('input.txt');
448
+ *
449
+ * const rl = readline.createInterface({
450
+ * input: fileStream,
451
+ * crlfDelay: Infinity
452
+ * });
453
+ * // Note: we use the crlfDelay option to recognize all instances of CR LF
454
+ * // ('\r\n') in input.txt as a single line break.
455
+ *
456
+ * for await (const line of rl) {
457
+ * // Each line in input.txt will be successively available here as `line`.
458
+ * console.log(`Line from file: ${line}`);
459
+ * }
460
+ * }
461
+ *
462
+ * processLineByLine();
463
+ * ```
464
+ *
465
+ * Alternatively, one could use the `'line'` event:
466
+ *
467
+ * ```js
468
+ * const fs = require('fs');
469
+ * const readline = require('readline');
470
+ *
471
+ * const rl = readline.createInterface({
472
+ * input: fs.createReadStream('sample.txt'),
473
+ * crlfDelay: Infinity
474
+ * });
475
+ *
476
+ * rl.on('line', (line) => {
477
+ * console.log(`Line from file: ${line}`);
478
+ * });
479
+ * ```
480
+ *
481
+ * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
482
+ *
483
+ * ```js
484
+ * const { once } = require('events');
485
+ * const { createReadStream } = require('fs');
486
+ * const { createInterface } = require('readline');
487
+ *
488
+ * (async function processLineByLine() {
489
+ * try {
490
+ * const rl = createInterface({
491
+ * input: createReadStream('big-file.txt'),
492
+ * crlfDelay: Infinity
493
+ * });
494
+ *
495
+ * rl.on('line', (line) => {
496
+ * // Process the line.
497
+ * });
498
+ *
499
+ * await once(rl, 'close');
500
+ *
501
+ * console.log('File processed.');
502
+ * } catch (err) {
503
+ * console.error(err);
504
+ * }
505
+ * })();
506
+ * ```
507
+ * @since v0.7.7
508
+ */
509
+ export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
510
+ export type Direction = -1 | 0 | 1;
511
+ export interface CursorPos {
512
+ rows: number;
513
+ cols: number;
514
+ }
515
+ /**
516
+ * The `readline.clearLine()` method clears current line of given `TTY` stream
517
+ * in a specified direction identified by `dir`.
518
+ * @since v0.7.7
519
+ * @param callback Invoked once the operation completes.
520
+ * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
521
+ */
522
+ export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
523
+ /**
524
+ * The `readline.clearScreenDown()` method clears the given `TTY` stream from
525
+ * the current position of the cursor down.
526
+ * @since v0.7.7
527
+ * @param callback Invoked once the operation completes.
528
+ * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
529
+ */
530
+ export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
531
+ /**
532
+ * The `readline.cursorTo()` method moves cursor to the specified position in a
533
+ * given `TTY` `stream`.
534
+ * @since v0.7.7
535
+ * @param callback Invoked once the operation completes.
536
+ * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
537
+ */
538
+ export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
539
+ /**
540
+ * The `readline.moveCursor()` method moves the cursor _relative_ to its current
541
+ * position in a given `TTY` `stream`.
542
+ *
543
+ * ## Example: Tiny CLI
544
+ *
545
+ * The following example illustrates the use of `readline.Interface` class to
546
+ * implement a small command-line interface:
547
+ *
548
+ * ```js
549
+ * const readline = require('readline');
550
+ * const rl = readline.createInterface({
551
+ * input: process.stdin,
552
+ * output: process.stdout,
553
+ * prompt: 'OHAI> '
554
+ * });
555
+ *
556
+ * rl.prompt();
557
+ *
558
+ * rl.on('line', (line) => {
559
+ * switch (line.trim()) {
560
+ * case 'hello':
561
+ * console.log('world!');
562
+ * break;
563
+ * default:
564
+ * console.log(`Say what? I might have heard '${line.trim()}'`);
565
+ * break;
566
+ * }
567
+ * rl.prompt();
568
+ * }).on('close', () => {
569
+ * console.log('Have a great day!');
570
+ * process.exit(0);
571
+ * });
572
+ * ```
573
+ *
574
+ * ## Example: Read file stream line-by-Line
575
+ *
576
+ * A common use case for `readline` is to consume an input file one line at a
577
+ * time. The easiest way to do so is leveraging the `fs.ReadStream` API as
578
+ * well as a `for await...of` loop:
579
+ *
580
+ * ```js
581
+ * const fs = require('fs');
582
+ * const readline = require('readline');
583
+ *
584
+ * async function processLineByLine() {
585
+ * const fileStream = fs.createReadStream('input.txt');
586
+ *
587
+ * const rl = readline.createInterface({
588
+ * input: fileStream,
589
+ * crlfDelay: Infinity
590
+ * });
591
+ * // Note: we use the crlfDelay option to recognize all instances of CR LF
592
+ * // ('\r\n') in input.txt as a single line break.
593
+ *
594
+ * for await (const line of rl) {
595
+ * // Each line in input.txt will be successively available here as `line`.
596
+ * console.log(`Line from file: ${line}`);
597
+ * }
598
+ * }
599
+ *
600
+ * processLineByLine();
601
+ * ```
602
+ *
603
+ * Alternatively, one could use the `'line'` event:
604
+ *
605
+ * ```js
606
+ * const fs = require('fs');
607
+ * const readline = require('readline');
608
+ *
609
+ * const rl = readline.createInterface({
610
+ * input: fs.createReadStream('sample.txt'),
611
+ * crlfDelay: Infinity
612
+ * });
613
+ *
614
+ * rl.on('line', (line) => {
615
+ * console.log(`Line from file: ${line}`);
616
+ * });
617
+ * ```
618
+ *
619
+ * Currently, `for await...of` loop can be a bit slower. If `async` / `await`flow and speed are both essential, a mixed approach can be applied:
620
+ *
621
+ * ```js
622
+ * const { once } = require('events');
623
+ * const { createReadStream } = require('fs');
624
+ * const { createInterface } = require('readline');
625
+ *
626
+ * (async function processLineByLine() {
627
+ * try {
628
+ * const rl = createInterface({
629
+ * input: createReadStream('big-file.txt'),
630
+ * crlfDelay: Infinity
631
+ * });
632
+ *
633
+ * rl.on('line', (line) => {
634
+ * // Process the line.
635
+ * });
636
+ *
637
+ * await once(rl, 'close');
638
+ *
639
+ * console.log('File processed.');
640
+ * } catch (err) {
641
+ * console.error(err);
642
+ * }
643
+ * })();
644
+ * ```
645
+ * @since v0.7.7
646
+ * @param callback Invoked once the operation completes.
647
+ * @return `false` if `stream` wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
648
+ */
649
+ export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
650
+ }
651
+ declare module 'node:readline' {
652
+ export * from 'readline';
653
+ }