@alanszp/core 11.0.0 → 12.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/app/appIdentifier.js +13 -3
  2. package/dist/app/appIdentifier.js.map +1 -1
  3. package/package.json +2 -5
  4. package/.gitignore +0 -3
  5. package/.npmignore +0 -3
  6. package/node_modules/@types/node/LICENSE +0 -21
  7. package/node_modules/@types/node/README.md +0 -15
  8. package/node_modules/@types/node/assert/strict.d.ts +0 -8
  9. package/node_modules/@types/node/assert.d.ts +0 -996
  10. package/node_modules/@types/node/async_hooks.d.ts +0 -539
  11. package/node_modules/@types/node/buffer.d.ts +0 -2362
  12. package/node_modules/@types/node/child_process.d.ts +0 -1540
  13. package/node_modules/@types/node/cluster.d.ts +0 -432
  14. package/node_modules/@types/node/console.d.ts +0 -415
  15. package/node_modules/@types/node/constants.d.ts +0 -19
  16. package/node_modules/@types/node/crypto.d.ts +0 -4487
  17. package/node_modules/@types/node/dgram.d.ts +0 -596
  18. package/node_modules/@types/node/diagnostics_channel.d.ts +0 -545
  19. package/node_modules/@types/node/dns/promises.d.ts +0 -425
  20. package/node_modules/@types/node/dns.d.ts +0 -809
  21. package/node_modules/@types/node/dom-events.d.ts +0 -122
  22. package/node_modules/@types/node/domain.d.ts +0 -170
  23. package/node_modules/@types/node/events.d.ts +0 -879
  24. package/node_modules/@types/node/fs/promises.d.ts +0 -1239
  25. package/node_modules/@types/node/fs.d.ts +0 -4311
  26. package/node_modules/@types/node/globals.d.ts +0 -411
  27. package/node_modules/@types/node/globals.global.d.ts +0 -1
  28. package/node_modules/@types/node/http.d.ts +0 -1887
  29. package/node_modules/@types/node/http2.d.ts +0 -2382
  30. package/node_modules/@types/node/https.d.ts +0 -550
  31. package/node_modules/@types/node/index.d.ts +0 -88
  32. package/node_modules/@types/node/inspector.d.ts +0 -2747
  33. package/node_modules/@types/node/module.d.ts +0 -315
  34. package/node_modules/@types/node/net.d.ts +0 -949
  35. package/node_modules/@types/node/os.d.ts +0 -478
  36. package/node_modules/@types/node/package.json +0 -229
  37. package/node_modules/@types/node/path.d.ts +0 -191
  38. package/node_modules/@types/node/perf_hooks.d.ts +0 -645
  39. package/node_modules/@types/node/process.d.ts +0 -1561
  40. package/node_modules/@types/node/punycode.d.ts +0 -117
  41. package/node_modules/@types/node/querystring.d.ts +0 -141
  42. package/node_modules/@types/node/readline/promises.d.ts +0 -150
  43. package/node_modules/@types/node/readline.d.ts +0 -539
  44. package/node_modules/@types/node/repl.d.ts +0 -430
  45. package/node_modules/@types/node/stream/consumers.d.ts +0 -12
  46. package/node_modules/@types/node/stream/promises.d.ts +0 -83
  47. package/node_modules/@types/node/stream/web.d.ts +0 -366
  48. package/node_modules/@types/node/stream.d.ts +0 -1701
  49. package/node_modules/@types/node/string_decoder.d.ts +0 -67
  50. package/node_modules/@types/node/test.d.ts +0 -1465
  51. package/node_modules/@types/node/timers/promises.d.ts +0 -93
  52. package/node_modules/@types/node/timers.d.ts +0 -240
  53. package/node_modules/@types/node/tls.d.ts +0 -1210
  54. package/node_modules/@types/node/trace_events.d.ts +0 -182
  55. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  56. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  57. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  58. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2362
  59. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  60. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  61. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  62. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  63. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4487
  64. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -596
  65. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -545
  66. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  67. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  68. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  69. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  70. package/node_modules/@types/node/ts4.8/events.d.ts +0 -879
  71. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1239
  72. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4311
  73. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -411
  74. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  75. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1887
  76. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  77. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  78. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  79. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  80. package/node_modules/@types/node/ts4.8/module.d.ts +0 -315
  81. package/node_modules/@types/node/ts4.8/net.d.ts +0 -949
  82. package/node_modules/@types/node/ts4.8/os.d.ts +0 -478
  83. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  84. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -645
  85. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1561
  86. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  87. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  88. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  89. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  90. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  91. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  92. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  93. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -366
  94. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  95. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  96. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1465
  97. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  98. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  99. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  100. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  101. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  102. package/node_modules/@types/node/ts4.8/url.d.ts +0 -927
  103. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2183
  104. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -764
  105. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -903
  106. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -179
  107. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  108. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  109. package/node_modules/@types/node/tty.d.ts +0 -208
  110. package/node_modules/@types/node/url.d.ts +0 -927
  111. package/node_modules/@types/node/util.d.ts +0 -2183
  112. package/node_modules/@types/node/v8.d.ts +0 -764
  113. package/node_modules/@types/node/vm.d.ts +0 -903
  114. package/node_modules/@types/node/wasi.d.ts +0 -179
  115. package/node_modules/@types/node/worker_threads.d.ts +0 -691
  116. package/node_modules/@types/node/zlib.d.ts +0 -517
  117. package/src/app/appIdentifier.ts +0 -5
  118. package/src/app/index.ts +0 -1
  119. package/src/assignKey.ts +0 -25
  120. package/src/editable/index.ts +0 -2
  121. package/src/editable/keepOrUpdate.ts +0 -42
  122. package/src/editable/types.ts +0 -11
  123. package/src/index.ts +0 -4
  124. package/src/lists/ListResult.ts +0 -16
  125. package/src/lists/Orderable.ts +0 -19
  126. package/src/lists/Paginable.ts +0 -25
  127. package/src/lists/index.ts +0 -3
@@ -1,539 +0,0 @@
1
- /**
2
- * The `node: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 `node: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/v20.2.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
- export { promises };
39
- export interface Key {
40
- sequence?: string | undefined;
41
- name?: string | undefined;
42
- ctrl?: boolean | undefined;
43
- meta?: boolean | undefined;
44
- shift?: boolean | undefined;
45
- }
46
- /**
47
- * Instances of the `readline.Interface` class are constructed using the`readline.createInterface()` method. Every instance is associated with a
48
- * single `input` `Readable` stream and a single `output` `Writable` stream.
49
- * The `output` stream is used to print prompts for user input that arrives on,
50
- * and is read from, the `input` stream.
51
- * @since v0.1.104
52
- */
53
- export class Interface extends EventEmitter {
54
- readonly terminal: boolean;
55
- /**
56
- * The current input data being processed by node.
57
- *
58
- * This can be used when collecting input from a TTY stream to retrieve the
59
- * current value that has been processed thus far, prior to the `line` event
60
- * being emitted. Once the `line` event has been emitted, this property will
61
- * be an empty string.
62
- *
63
- * Be aware that modifying the value during the instance runtime may have
64
- * unintended consequences if `rl.cursor` is not also controlled.
65
- *
66
- * **If not using a TTY stream for input, use the `'line'` event.**
67
- *
68
- * One possible use case would be as follows:
69
- *
70
- * ```js
71
- * const values = ['lorem ipsum', 'dolor sit amet'];
72
- * const rl = readline.createInterface(process.stdin);
73
- * const showResults = debounce(() => {
74
- * console.log(
75
- * '\n',
76
- * values.filter((val) => val.startsWith(rl.line)).join(' '),
77
- * );
78
- * }, 300);
79
- * process.stdin.on('keypress', (c, k) => {
80
- * showResults();
81
- * });
82
- * ```
83
- * @since v0.1.98
84
- */
85
- readonly line: string;
86
- /**
87
- * The cursor position relative to `rl.line`.
88
- *
89
- * This will track where the current cursor lands in the input string, when
90
- * reading input from a TTY stream. The position of cursor determines the
91
- * portion of the input string that will be modified as input is processed,
92
- * as well as the column where the terminal caret will be rendered.
93
- * @since v0.1.98
94
- */
95
- readonly cursor: number;
96
- /**
97
- * NOTE: According to the documentation:
98
- *
99
- * > Instances of the `readline.Interface` class are constructed using the
100
- * > `readline.createInterface()` method.
101
- *
102
- * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
103
- */
104
- protected constructor(
105
- input: NodeJS.ReadableStream,
106
- output?: NodeJS.WritableStream,
107
- completer?: Completer | AsyncCompleter,
108
- terminal?: boolean,
109
- );
110
- /**
111
- * NOTE: According to the documentation:
112
- *
113
- * > Instances of the `readline.Interface` class are constructed using the
114
- * > `readline.createInterface()` method.
115
- *
116
- * @see https://nodejs.org/dist/latest-v20.x/docs/api/readline.html#class-interfaceconstructor
117
- */
118
- protected constructor(options: ReadLineOptions);
119
- /**
120
- * The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
121
- * @since v15.3.0, v14.17.0
122
- * @return the current prompt string
123
- */
124
- getPrompt(): string;
125
- /**
126
- * The `rl.setPrompt()` method sets the prompt that will be written to `output`whenever `rl.prompt()` is called.
127
- * @since v0.1.98
128
- */
129
- setPrompt(prompt: string): void;
130
- /**
131
- * The `rl.prompt()` method writes the `Interface` instances configured`prompt` to a new line in `output` in order to provide a user with a new
132
- * location at which to provide input.
133
- *
134
- * When called, `rl.prompt()` will resume the `input` stream if it has been
135
- * paused.
136
- *
137
- * If the `Interface` was created with `output` set to `null` or`undefined` the prompt is not written.
138
- * @since v0.1.98
139
- * @param preserveCursor If `true`, prevents the cursor placement from being reset to `0`.
140
- */
141
- prompt(preserveCursor?: boolean): void;
142
- /**
143
- * The `rl.question()` method displays the `query` by writing it to the `output`,
144
- * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument.
145
- *
146
- * When called, `rl.question()` will resume the `input` stream if it has been
147
- * paused.
148
- *
149
- * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written.
150
- *
151
- * The `callback` function passed to `rl.question()` does not follow the typical
152
- * pattern of accepting an `Error` object or `null` as the first argument.
153
- * The `callback` is called with the provided answer as the only argument.
154
- *
155
- * An error will be thrown if calling `rl.question()` after `rl.close()`.
156
- *
157
- * Example usage:
158
- *
159
- * ```js
160
- * rl.question('What is your favorite food? ', (answer) => {
161
- * console.log(`Oh, so your favorite food is ${answer}`);
162
- * });
163
- * ```
164
- *
165
- * Using an `AbortController` to cancel a question.
166
- *
167
- * ```js
168
- * const ac = new AbortController();
169
- * const signal = ac.signal;
170
- *
171
- * rl.question('What is your favorite food? ', { signal }, (answer) => {
172
- * console.log(`Oh, so your favorite food is ${answer}`);
173
- * });
174
- *
175
- * signal.addEventListener('abort', () => {
176
- * console.log('The food question timed out');
177
- * }, { once: true });
178
- *
179
- * setTimeout(() => ac.abort(), 10000);
180
- * ```
181
- * @since v0.3.3
182
- * @param query A statement or query to write to `output`, prepended to the prompt.
183
- * @param callback A callback function that is invoked with the user's input in response to the `query`.
184
- */
185
- question(query: string, callback: (answer: string) => void): void;
186
- question(query: string, options: Abortable, callback: (answer: string) => void): void;
187
- /**
188
- * The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
189
- * later if necessary.
190
- *
191
- * Calling `rl.pause()` does not immediately pause other events (including`'line'`) from being emitted by the `Interface` instance.
192
- * @since v0.3.4
193
- */
194
- pause(): this;
195
- /**
196
- * The `rl.resume()` method resumes the `input` stream if it has been paused.
197
- * @since v0.3.4
198
- */
199
- resume(): this;
200
- /**
201
- * The `rl.close()` method closes the `Interface` instance and
202
- * relinquishes control over the `input` and `output` streams. When called,
203
- * the `'close'` event will be emitted.
204
- *
205
- * Calling `rl.close()` does not immediately stop other events (including `'line'`)
206
- * from being emitted by the `Interface` instance.
207
- * @since v0.1.98
208
- */
209
- close(): void;
210
- /**
211
- * The `rl.write()` method will write either `data` or a key sequence identified
212
- * by `key` to the `output`. The `key` argument is supported only if `output` is
213
- * a `TTY` text terminal. See `TTY keybindings` for a list of key
214
- * combinations.
215
- *
216
- * If `key` is specified, `data` is ignored.
217
- *
218
- * When called, `rl.write()` will resume the `input` stream if it has been
219
- * paused.
220
- *
221
- * If the `Interface` was created with `output` set to `null` or`undefined` the `data` and `key` are not written.
222
- *
223
- * ```js
224
- * rl.write('Delete this!');
225
- * // Simulate Ctrl+U to delete the line written previously
226
- * rl.write(null, { ctrl: true, name: 'u' });
227
- * ```
228
- *
229
- * The `rl.write()` method will write the data to the `readline` `Interface`'s`input`_as if it were provided by the user_.
230
- * @since v0.1.98
231
- */
232
- write(data: string | Buffer, key?: Key): void;
233
- write(data: undefined | null | string | Buffer, key: Key): void;
234
- /**
235
- * Returns the real position of the cursor in relation to the input
236
- * prompt + string. Long input (wrapping) strings, as well as multiple
237
- * line prompts are included in the calculations.
238
- * @since v13.5.0, v12.16.0
239
- */
240
- getCursorPos(): CursorPos;
241
- /**
242
- * events.EventEmitter
243
- * 1. close
244
- * 2. line
245
- * 3. pause
246
- * 4. resume
247
- * 5. SIGCONT
248
- * 6. SIGINT
249
- * 7. SIGTSTP
250
- * 8. history
251
- */
252
- addListener(event: string, listener: (...args: any[]) => void): this;
253
- addListener(event: "close", listener: () => void): this;
254
- addListener(event: "line", listener: (input: string) => void): this;
255
- addListener(event: "pause", listener: () => void): this;
256
- addListener(event: "resume", listener: () => void): this;
257
- addListener(event: "SIGCONT", listener: () => void): this;
258
- addListener(event: "SIGINT", listener: () => void): this;
259
- addListener(event: "SIGTSTP", listener: () => void): this;
260
- addListener(event: "history", listener: (history: string[]) => void): this;
261
- emit(event: string | symbol, ...args: any[]): boolean;
262
- emit(event: "close"): boolean;
263
- emit(event: "line", input: string): boolean;
264
- emit(event: "pause"): boolean;
265
- emit(event: "resume"): boolean;
266
- emit(event: "SIGCONT"): boolean;
267
- emit(event: "SIGINT"): boolean;
268
- emit(event: "SIGTSTP"): boolean;
269
- emit(event: "history", history: string[]): boolean;
270
- on(event: string, listener: (...args: any[]) => void): this;
271
- on(event: "close", listener: () => void): this;
272
- on(event: "line", listener: (input: string) => void): this;
273
- on(event: "pause", listener: () => void): this;
274
- on(event: "resume", listener: () => void): this;
275
- on(event: "SIGCONT", listener: () => void): this;
276
- on(event: "SIGINT", listener: () => void): this;
277
- on(event: "SIGTSTP", listener: () => void): this;
278
- on(event: "history", listener: (history: string[]) => void): this;
279
- once(event: string, listener: (...args: any[]) => void): this;
280
- once(event: "close", listener: () => void): this;
281
- once(event: "line", listener: (input: string) => void): this;
282
- once(event: "pause", listener: () => void): this;
283
- once(event: "resume", listener: () => void): this;
284
- once(event: "SIGCONT", listener: () => void): this;
285
- once(event: "SIGINT", listener: () => void): this;
286
- once(event: "SIGTSTP", listener: () => void): this;
287
- once(event: "history", listener: (history: string[]) => void): this;
288
- prependListener(event: string, listener: (...args: any[]) => void): this;
289
- prependListener(event: "close", listener: () => void): this;
290
- prependListener(event: "line", listener: (input: string) => void): this;
291
- prependListener(event: "pause", listener: () => void): this;
292
- prependListener(event: "resume", listener: () => void): this;
293
- prependListener(event: "SIGCONT", listener: () => void): this;
294
- prependListener(event: "SIGINT", listener: () => void): this;
295
- prependListener(event: "SIGTSTP", listener: () => void): this;
296
- prependListener(event: "history", listener: (history: string[]) => void): this;
297
- prependOnceListener(event: string, listener: (...args: any[]) => void): this;
298
- prependOnceListener(event: "close", listener: () => void): this;
299
- prependOnceListener(event: "line", listener: (input: string) => void): this;
300
- prependOnceListener(event: "pause", listener: () => void): this;
301
- prependOnceListener(event: "resume", listener: () => void): this;
302
- prependOnceListener(event: "SIGCONT", listener: () => void): this;
303
- prependOnceListener(event: "SIGINT", listener: () => void): this;
304
- prependOnceListener(event: "SIGTSTP", listener: () => void): this;
305
- prependOnceListener(event: "history", listener: (history: string[]) => void): this;
306
- [Symbol.asyncIterator](): AsyncIterableIterator<string>;
307
- }
308
- export type ReadLine = Interface; // type forwarded for backwards compatibility
309
- export type Completer = (line: string) => CompleterResult;
310
- export type AsyncCompleter = (
311
- line: string,
312
- callback: (err?: null | Error, result?: CompleterResult) => void,
313
- ) => void;
314
- export type CompleterResult = [string[], string];
315
- export interface ReadLineOptions {
316
- input: NodeJS.ReadableStream;
317
- output?: NodeJS.WritableStream | undefined;
318
- completer?: Completer | AsyncCompleter | undefined;
319
- terminal?: boolean | undefined;
320
- /**
321
- * Initial list of history lines. This option makes sense
322
- * only if `terminal` is set to `true` by the user or by an internal `output`
323
- * check, otherwise the history caching mechanism is not initialized at all.
324
- * @default []
325
- */
326
- history?: string[] | undefined;
327
- historySize?: number | undefined;
328
- prompt?: string | undefined;
329
- crlfDelay?: number | undefined;
330
- /**
331
- * If `true`, when a new input line added
332
- * to the history list duplicates an older one, this removes the older line
333
- * from the list.
334
- * @default false
335
- */
336
- removeHistoryDuplicates?: boolean | undefined;
337
- escapeCodeTimeout?: number | undefined;
338
- tabSize?: number | undefined;
339
- }
340
- /**
341
- * The `readline.createInterface()` method creates a new `readline.Interface`instance.
342
- *
343
- * ```js
344
- * const readline = require('node:readline');
345
- * const rl = readline.createInterface({
346
- * input: process.stdin,
347
- * output: process.stdout,
348
- * });
349
- * ```
350
- *
351
- * Once the `readline.Interface` instance is created, the most common case is to
352
- * listen for the `'line'` event:
353
- *
354
- * ```js
355
- * rl.on('line', (line) => {
356
- * console.log(`Received: ${line}`);
357
- * });
358
- * ```
359
- *
360
- * If `terminal` is `true` for this instance then the `output` stream will get
361
- * the best compatibility if it defines an `output.columns` property and emits
362
- * a `'resize'` event on the `output` if or when the columns ever change
363
- * (`process.stdout` does this automatically when it is a TTY).
364
- *
365
- * When creating a `readline.Interface` using `stdin` as input, the program
366
- * will not terminate until it receives an [EOF character](https://en.wikipedia.org/wiki/End-of-file#EOF_character). To exit without
367
- * waiting for user input, call `process.stdin.unref()`.
368
- * @since v0.1.98
369
- */
370
- export function createInterface(
371
- input: NodeJS.ReadableStream,
372
- output?: NodeJS.WritableStream,
373
- completer?: Completer | AsyncCompleter,
374
- terminal?: boolean,
375
- ): Interface;
376
- export function createInterface(options: ReadLineOptions): Interface;
377
- /**
378
- * The `readline.emitKeypressEvents()` method causes the given `Readable` stream to begin emitting `'keypress'` events corresponding to received input.
379
- *
380
- * Optionally, `interface` specifies a `readline.Interface` instance for which
381
- * autocompletion is disabled when copy-pasted input is detected.
382
- *
383
- * If the `stream` is a `TTY`, then it must be in raw mode.
384
- *
385
- * This is automatically called by any readline instance on its `input` if the`input` is a terminal. Closing the `readline` instance does not stop
386
- * the `input` from emitting `'keypress'` events.
387
- *
388
- * ```js
389
- * readline.emitKeypressEvents(process.stdin);
390
- * if (process.stdin.isTTY)
391
- * process.stdin.setRawMode(true);
392
- * ```
393
- *
394
- * ## Example: Tiny CLI
395
- *
396
- * The following example illustrates the use of `readline.Interface` class to
397
- * implement a small command-line interface:
398
- *
399
- * ```js
400
- * const readline = require('node:readline');
401
- * const rl = readline.createInterface({
402
- * input: process.stdin,
403
- * output: process.stdout,
404
- * prompt: 'OHAI> ',
405
- * });
406
- *
407
- * rl.prompt();
408
- *
409
- * rl.on('line', (line) => {
410
- * switch (line.trim()) {
411
- * case 'hello':
412
- * console.log('world!');
413
- * break;
414
- * default:
415
- * console.log(`Say what? I might have heard '${line.trim()}'`);
416
- * break;
417
- * }
418
- * rl.prompt();
419
- * }).on('close', () => {
420
- * console.log('Have a great day!');
421
- * process.exit(0);
422
- * });
423
- * ```
424
- *
425
- * ## Example: Read file stream line-by-Line
426
- *
427
- * A common use case for `readline` is to consume an input file one line at a
428
- * time. The easiest way to do so is leveraging the `fs.ReadStream` API as
429
- * well as a `for await...of` loop:
430
- *
431
- * ```js
432
- * const fs = require('node:fs');
433
- * const readline = require('node:readline');
434
- *
435
- * async function processLineByLine() {
436
- * const fileStream = fs.createReadStream('input.txt');
437
- *
438
- * const rl = readline.createInterface({
439
- * input: fileStream,
440
- * crlfDelay: Infinity,
441
- * });
442
- * // Note: we use the crlfDelay option to recognize all instances of CR LF
443
- * // ('\r\n') in input.txt as a single line break.
444
- *
445
- * for await (const line of rl) {
446
- * // Each line in input.txt will be successively available here as `line`.
447
- * console.log(`Line from file: ${line}`);
448
- * }
449
- * }
450
- *
451
- * processLineByLine();
452
- * ```
453
- *
454
- * Alternatively, one could use the `'line'` event:
455
- *
456
- * ```js
457
- * const fs = require('node:fs');
458
- * const readline = require('node:readline');
459
- *
460
- * const rl = readline.createInterface({
461
- * input: fs.createReadStream('sample.txt'),
462
- * crlfDelay: Infinity,
463
- * });
464
- *
465
- * rl.on('line', (line) => {
466
- * console.log(`Line from file: ${line}`);
467
- * });
468
- * ```
469
- *
470
- * 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:
471
- *
472
- * ```js
473
- * const { once } = require('node:events');
474
- * const { createReadStream } = require('node:fs');
475
- * const { createInterface } = require('node:readline');
476
- *
477
- * (async function processLineByLine() {
478
- * try {
479
- * const rl = createInterface({
480
- * input: createReadStream('big-file.txt'),
481
- * crlfDelay: Infinity,
482
- * });
483
- *
484
- * rl.on('line', (line) => {
485
- * // Process the line.
486
- * });
487
- *
488
- * await once(rl, 'close');
489
- *
490
- * console.log('File processed.');
491
- * } catch (err) {
492
- * console.error(err);
493
- * }
494
- * })();
495
- * ```
496
- * @since v0.7.7
497
- */
498
- export function emitKeypressEvents(stream: NodeJS.ReadableStream, readlineInterface?: Interface): void;
499
- export type Direction = -1 | 0 | 1;
500
- export interface CursorPos {
501
- rows: number;
502
- cols: number;
503
- }
504
- /**
505
- * The `readline.clearLine()` method clears current line of given `TTY` stream
506
- * in a specified direction identified by `dir`.
507
- * @since v0.7.7
508
- * @param callback Invoked once the operation completes.
509
- * @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`.
510
- */
511
- export function clearLine(stream: NodeJS.WritableStream, dir: Direction, callback?: () => void): boolean;
512
- /**
513
- * The `readline.clearScreenDown()` method clears the given `TTY` stream from
514
- * the current position of the cursor down.
515
- * @since v0.7.7
516
- * @param callback Invoked once the operation completes.
517
- * @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`.
518
- */
519
- export function clearScreenDown(stream: NodeJS.WritableStream, callback?: () => void): boolean;
520
- /**
521
- * The `readline.cursorTo()` method moves cursor to the specified position in a
522
- * given `TTY` `stream`.
523
- * @since v0.7.7
524
- * @param callback Invoked once the operation completes.
525
- * @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`.
526
- */
527
- export function cursorTo(stream: NodeJS.WritableStream, x: number, y?: number, callback?: () => void): boolean;
528
- /**
529
- * The `readline.moveCursor()` method moves the cursor _relative_ to its current
530
- * position in a given `TTY` `stream`.
531
- * @since v0.7.7
532
- * @param callback Invoked once the operation completes.
533
- * @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`.
534
- */
535
- export function moveCursor(stream: NodeJS.WritableStream, dx: number, dy: number, callback?: () => void): boolean;
536
- }
537
- declare module "node:readline" {
538
- export * from "readline";
539
- }