2012-02-27 11:09:34 -08:00
|
|
|
# Readline
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2017-01-22 19:16:21 -08:00
|
|
|
<!--introduced_in=v0.10.0-->
|
|
|
|
|
2016-07-16 00:35:38 +02:00
|
|
|
> Stability: 2 - Stable
|
2012-03-02 15:14:03 -08:00
|
|
|
|
2020-06-22 13:56:08 -04:00
|
|
|
<!-- source_link=lib/readline.js -->
|
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The `node:readline` module provides an interface for reading data from a
|
|
|
|
[Readable][] stream (such as [`process.stdin`][]) one line at a time.
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
To use the promise-based APIs:
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
import * as readline from 'node:readline/promises';
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const readline = require('node:readline/promises');
|
2021-04-27 16:14:39 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
To use the callback and sync APIs:
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
import * as readline from 'node:readline';
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const readline = require('node:readline');
|
2016-05-27 10:59:50 -07:00
|
|
|
```
|
|
|
|
|
2022-04-20 10:23:41 +02:00
|
|
|
The following simple example illustrates the basic use of the `node:readline`
|
|
|
|
module.
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
```mjs
|
|
|
|
import * as readline from 'node:readline/promises';
|
2022-01-18 19:04:09 +01:00
|
|
|
import { stdin as input, stdout as output } from 'node:process';
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
const rl = readline.createInterface({ input, output });
|
|
|
|
|
|
|
|
const answer = await rl.question('What do you think of Node.js? ');
|
|
|
|
|
|
|
|
console.log(`Thank you for your valuable feedback: ${answer}`);
|
|
|
|
|
|
|
|
rl.close();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const readline = require('node:readline');
|
|
|
|
const { stdin: input, stdout: output } = require('node:process');
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
const rl = readline.createInterface({ input, output });
|
2012-03-26 15:21:25 -07:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
rl.question('What do you think of Node.js? ', (answer) => {
|
|
|
|
// TODO: Log the answer in a database
|
2016-11-16 01:41:14 +02:00
|
|
|
console.log(`Thank you for your valuable feedback: ${answer}`);
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
rl.close();
|
|
|
|
});
|
|
|
|
```
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
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
|
|
|
|
received on the `input` stream.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<a id='readline_class_interface'></a>
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
## Class: `InterfaceConstructor`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.104
|
|
|
|
-->
|
2012-02-27 11:09:34 -08:00
|
|
|
|
2019-08-23 22:02:23 -07:00
|
|
|
* Extends: {EventEmitter}
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
Instances of the `InterfaceConstructor` class are constructed using the
|
|
|
|
`readlinePromises.createInterface()` or `readline.createInterface()` method.
|
|
|
|
Every instance is associated with a single `input` [Readable][] stream and a
|
|
|
|
single `output` [Writable][] stream.
|
2016-05-27 10:59:50 -07:00
|
|
|
The `output` stream is used to print prompts for user input that arrives on,
|
|
|
|
and is read from, the `input` stream.
|
2012-04-10 13:59:13 +08:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'close'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'close'` event is emitted when one of the following occur:
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
* The `rl.close()` method is called and the `InterfaceConstructor` instance has
|
2016-05-27 10:59:50 -07:00
|
|
|
relinquished control over the `input` and `output` streams;
|
|
|
|
* The `input` stream receives its `'end'` event;
|
2020-10-18 06:52:55 -07:00
|
|
|
* The `input` stream receives <kbd>Ctrl</kbd>+<kbd>D</kbd> to signal
|
|
|
|
end-of-transmission (EOT);
|
|
|
|
* The `input` stream receives <kbd>Ctrl</kbd>+<kbd>C</kbd> to signal `SIGINT`
|
|
|
|
and there is no `'SIGINT'` event listener registered on the
|
2021-04-27 16:14:39 +02:00
|
|
|
`InterfaceConstructor` instance.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is called without passing any arguments.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
The `InterfaceConstructor` instance is finished once the `'close'` event is
|
2018-01-10 20:07:01 -08:00
|
|
|
emitted.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'line'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
2011-08-08 00:56:04 +02:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'line'` event is emitted whenever the `input` stream receives an
|
|
|
|
end-of-line input (`\n`, `\r`, or `\r\n`). This usually occurs when the user
|
2020-10-21 05:02:25 -07:00
|
|
|
presses <kbd>Enter</kbd> or <kbd>Return</kbd>.
|
2011-08-08 00:56:04 +02:00
|
|
|
|
2022-03-07 22:08:40 +01:00
|
|
|
The `'line'` event is also emitted if new data has been read from a stream and
|
|
|
|
that stream ends without a final end-of-line marker.
|
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is called with a string containing the single line of
|
|
|
|
received input.
|
2011-08-08 00:56:04 +02:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
2016-05-27 10:59:50 -07:00
|
|
|
rl.on('line', (input) => {
|
|
|
|
console.log(`Received: ${input}`);
|
2016-01-17 18:39:07 +01:00
|
|
|
});
|
|
|
|
```
|
2011-08-08 00:56:04 +02:00
|
|
|
|
2020-05-30 22:17:09 +02:00
|
|
|
### Event: `'history'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-05-30 22:17:09 +02:00
|
|
|
<!-- YAML
|
2021-09-04 15:29:35 +02:00
|
|
|
added:
|
|
|
|
- v15.8.0
|
|
|
|
- v14.18.0
|
2020-05-30 22:17:09 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
The `'history'` event is emitted whenever the history array has changed.
|
|
|
|
|
|
|
|
The listener function is called with an array containing the history array.
|
|
|
|
It will reflect all changes, added lines and removed lines due to
|
|
|
|
`historySize` and `removeHistoryDuplicates`.
|
|
|
|
|
|
|
|
The primary purpose is to allow a listener to persist the history.
|
|
|
|
It is also possible for the listener to change the history object. This
|
|
|
|
could be useful to prevent certain lines to be added to the history, like
|
|
|
|
a password.
|
|
|
|
|
|
|
|
```js
|
|
|
|
rl.on('history', (history) => {
|
|
|
|
console.log(`Received: ${history}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'pause'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
2011-08-08 00:56:04 +02:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'pause'` event is emitted when one of the following occur:
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
* The `input` stream is paused.
|
2018-04-09 19:30:22 +03:00
|
|
|
* The `input` stream is not paused and receives the `'SIGCONT'` event. (See
|
2018-04-29 14:16:44 +03:00
|
|
|
events [`'SIGTSTP'`][] and [`'SIGCONT'`][].)
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is called without passing any arguments.
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
rl.on('pause', () => {
|
|
|
|
console.log('Readline paused.');
|
|
|
|
});
|
|
|
|
```
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'resume'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'resume'` event is emitted whenever the `input` stream is resumed.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is called without passing any arguments.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
rl.on('resume', () => {
|
|
|
|
console.log('Readline resumed.');
|
|
|
|
});
|
|
|
|
```
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'SIGCONT'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
2012-03-27 12:41:42 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'SIGCONT'` event is emitted when a Node.js process previously moved into
|
2020-10-18 06:52:55 -07:00
|
|
|
the background using <kbd>Ctrl</kbd>+<kbd>Z</kbd> (i.e. `SIGTSTP`) is then
|
|
|
|
brought back to the foreground using fg(1p).
|
2012-03-27 12:41:42 -07:00
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
If the `input` stream was paused _before_ the `SIGTSTP` request, this event will
|
2016-05-27 10:59:50 -07:00
|
|
|
not be emitted.
|
2012-04-17 11:44:54 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is invoked without passing any arguments.
|
2012-04-17 11:44:54 -07:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
rl.on('SIGCONT', () => {
|
|
|
|
// `prompt` will automatically resume the stream
|
|
|
|
rl.prompt();
|
|
|
|
});
|
|
|
|
```
|
2012-03-27 12:41:42 -07:00
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
The `'SIGCONT'` event is _not_ supported on Windows.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'SIGINT'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.3.0
|
|
|
|
-->
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
The `'SIGINT'` event is emitted whenever the `input` stream receives
|
|
|
|
a <kbd>Ctrl+C</kbd> input, known typically as `SIGINT`. If there are no
|
|
|
|
`'SIGINT'` event listeners registered when the `input` stream receives a
|
|
|
|
`SIGINT`, the `'pause'` event will be emitted.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is invoked without passing any arguments.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
rl.on('SIGINT', () => {
|
2017-04-25 02:38:52 +03:00
|
|
|
rl.question('Are you sure you want to exit? ', (answer) => {
|
2016-01-17 18:39:07 +01:00
|
|
|
if (answer.match(/^y(es)?$/i)) rl.pause();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
```
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### Event: `'SIGTSTP'`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.5
|
|
|
|
-->
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
The `'SIGTSTP'` event is emitted when the `input` stream receives
|
|
|
|
a <kbd>Ctrl</kbd>+<kbd>Z</kbd> input, typically known as `SIGTSTP`. If there are
|
2020-10-18 06:52:55 -07:00
|
|
|
no `'SIGTSTP'` event listeners registered when the `input` stream receives a
|
|
|
|
`SIGTSTP`, the Node.js process will be sent to the background.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2018-04-09 19:30:22 +03:00
|
|
|
When the program is resumed using fg(1p), the `'pause'` and `'SIGCONT'` events
|
2016-05-27 10:59:50 -07:00
|
|
|
will be emitted. These can be used to resume the `input` stream.
|
2012-02-17 08:53:24 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `'pause'` and `'SIGCONT'` events will not be emitted if the `input` was
|
|
|
|
paused before the process was sent to the background.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The listener function is invoked without passing any arguments.
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
rl.on('SIGTSTP', () => {
|
|
|
|
// This will override SIGTSTP and prevent the program from going to the
|
|
|
|
// background.
|
|
|
|
console.log('Caught SIGTSTP.');
|
|
|
|
});
|
|
|
|
```
|
2012-02-15 09:08:26 -05:00
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
The `'SIGTSTP'` event is _not_ supported on Windows.
|
2012-04-10 13:59:13 +08:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.close()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
2011-04-20 12:04:42 -04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
The `rl.close()` method closes the `InterfaceConstructor` instance and
|
2016-05-27 10:59:50 -07:00
|
|
|
relinquishes control over the `input` and `output` streams. When called,
|
|
|
|
the `'close'` event will be emitted.
|
2016-01-17 18:39:07 +01:00
|
|
|
|
2018-09-03 17:39:09 -04:00
|
|
|
Calling `rl.close()` does not immediately stop other events (including `'line'`)
|
2021-04-27 16:14:39 +02:00
|
|
|
from being emitted by the `InterfaceConstructor` instance.
|
2018-09-03 17:39:09 -04:00
|
|
|
|
2025-03-04 17:54:01 +00:00
|
|
|
### `rl[Symbol.dispose]()`
|
|
|
|
|
|
|
|
<!-- YAML
|
2025-04-23 10:59:33 +02:00
|
|
|
added:
|
2025-04-11 17:38:28 -03:00
|
|
|
- v23.10.0
|
|
|
|
- v22.15.0
|
2025-03-04 17:54:01 +00:00
|
|
|
-->
|
|
|
|
|
|
|
|
Alias for `rl.close()`.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.pause()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.3.4
|
|
|
|
-->
|
2016-01-17 18:39:07 +01:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `rl.pause()` method pauses the `input` stream, allowing it to be resumed
|
|
|
|
later if necessary.
|
|
|
|
|
|
|
|
Calling `rl.pause()` does not immediately pause other events (including
|
2021-04-27 16:14:39 +02:00
|
|
|
`'line'`) from being emitted by the `InterfaceConstructor` instance.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.prompt([preserveCursor])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `preserveCursor` {boolean} If `true`, prevents the cursor placement from
|
|
|
|
being reset to `0`.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
The `rl.prompt()` method writes the `InterfaceConstructor` instances configured
|
2016-05-27 10:59:50 -07:00
|
|
|
`prompt` to a new line in `output` in order to provide a user with a new
|
|
|
|
location at which to provide input.
|
|
|
|
|
|
|
|
When called, `rl.prompt()` will resume the `input` stream if it has been
|
|
|
|
paused.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
If the `InterfaceConstructor` was created with `output` set to `null` or
|
2016-05-27 10:59:50 -07:00
|
|
|
`undefined` the prompt is not written.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.resume()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.3.4
|
|
|
|
-->
|
2016-01-10 17:18:49 +01:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `rl.resume()` method resumes the `input` stream if it has been paused.
|
2016-01-10 17:18:49 +01:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.setPrompt(prompt)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
2016-01-10 17:18:49 +01:00
|
|
|
|
2017-02-04 16:15:33 +01:00
|
|
|
* `prompt` {string}
|
2016-01-10 17:18:49 +01:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `rl.setPrompt()` method sets the prompt that will be written to `output`
|
|
|
|
whenever `rl.prompt()` is called.
|
|
|
|
|
2020-05-31 19:34:17 +02:00
|
|
|
### `rl.getPrompt()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2020-05-31 19:34:17 +02:00
|
|
|
<!-- YAML
|
2021-05-11, Version 14.17.0 'Fermium' (LTS)
Notable Changes:
Diagnostics channel (experimental module):
`diagnostics_channel` is a new experimental module that provides an API
to create named channels to report arbitrary message data for
diagnostics purposes.
The module was initially introduced in Node.js v15.1.0 and is
backported to v14.17.0 to enable testing it at a larger scale.
With `diagnostics_channel`, Node.js core and module authors can publish
contextual data about what they are doing at a given time. This could
be the hostname and query string of a mysql query, for example. Just
create a named channel with `dc.channel(name)` and call
`channel.publish(data)` to send the data to any listeners to that
channel.
```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');
MySQL.prototype.query = function query(queryString, values, callback) {
// Broadcast query information whenever a query is made
channel.publish({
query: queryString,
host: this.hostname,
});
this.doQuery(queryString, values, callback);
};
```
Channels are like one big global event emitter but are split into
separate objects to ensure they get the best performance. If nothing is
listening to the channel, the publishing overhead should be as close to
zero as possible. Consuming channel data is as easy as using
`channel.subscribe(listener)` to run a function whenever a message is
published to that channel.
```js
const dc = require('diagnostics_channel');
const channel = dc.channel('mysql.query');
channel.subscribe(({ query, host }) => {
console.log(`mysql query to ${host}: ${query}`);
});
```
The data captured can be used to provide context for what an app is
doing at a given time. This can be used for things like augmenting
tracing data, tracking network and filesystem activity, logging
queries, and many other things. It's also a very useful data source
for diagnostics tools to provide a clearer picture of exactly what the
application is doing at a given point in the data they are presenting.
Contributed by Stephen Belanger (https://github.com/nodejs/node/pull/34895).
UUID support in the crypto module:
The new `crypto.randomUUID()` method now allows to generate random
[RFC 4122](https://www.rfc-editor.org/rfc/rfc4122.txt) Version 4
UUID strings:
```js
const { randomUUID } = require('crypto');
console.log(randomUUID());
// 'aa7c91a1-f8fc-4339-b9db-f93fc7233429'
```
Contributed by James M Snell (https://github.com/nodejs/node/pull/36729).
Experimental support for `AbortController` and `AbortSignal`:
Node.js 14.17.0 adds experimental partial support for `AbortController`
and `AbortSignal`.
Both constructors can be enabled globally using the
`--experimental-abortcontroller` flag.
Additionally, several Node.js APIs have been updated to support
`AbortSignal` for cancellation.
It is not mandatory to use the built-in constructors with them. Any
spec-compliant third-party alternatives should be compatible.
`AbortSignal` support was added to the following methods:
* `child_process.exec`
* `child_process.execFile`
* `child_process.fork`
* `child_process.spawn`
* `dgram.createSocket`
* `events.on`
* `events.once`
* `fs.readFile`
* `fs.watch`
* `fs.writeFile`
* `http.request`
* `https.request`
* `http2Session.request`
* The promisified variants of `setImmediate` and `setTimeout`
Other notable changes:
* doc:
* revoke deprecation of legacy url, change status to legacy (James M Snell) (https://github.com/nodejs/node/pull/37784)
* add legacy status to stability index (James M Snell) (https://github.com/nodejs/node/pull/37784)
* upgrade stability status of report API (Gireesh Punathil) (https://github.com/nodejs/node/pull/35654)
* deps:
* V8: Backport various patches for Apple Silicon support (BoHong Li) (https://github.com/nodejs/node/pull/38051)
* update ICU to 68.1 (Michaël Zasso) (https://github.com/nodejs/node/pull/36187)
* upgrade to libuv 1.41.0 (Colin Ihrig) (https://github.com/nodejs/node/pull/37360)
* http:
* add http.ClientRequest.getRawHeaderNames() (simov) (https://github.com/nodejs/node/pull/37660)
* report request start and end with diagnostics\_channel (Stephen Belanger) (https://github.com/nodejs/node/pull/34895)
* util:
* add getSystemErrorMap() impl (eladkeyshawn) (https://github.com/nodejs/node/pull/38101)
PR-URL: https://github.com/nodejs/node/pull/38507
2021-05-02 23:12:18 -04:00
|
|
|
added:
|
|
|
|
- v15.3.0
|
|
|
|
- v14.17.0
|
2020-05-31 19:34:17 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: {string} the current prompt string
|
|
|
|
|
|
|
|
The `rl.getPrompt()` method returns the current prompt used by `rl.prompt()`.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.write(data[, key])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
|
|
|
-->
|
|
|
|
|
2017-02-04 16:15:33 +01:00
|
|
|
* `data` {string}
|
2016-05-27 10:59:50 -07:00
|
|
|
* `key` {Object}
|
2020-10-18 06:52:55 -07:00
|
|
|
* `ctrl` {boolean} `true` to indicate the <kbd>Ctrl</kbd> key.
|
|
|
|
* `meta` {boolean} `true` to indicate the <kbd>Meta</kbd> key.
|
|
|
|
* `shift` {boolean} `true` to indicate the <kbd>Shift</kbd> key.
|
2017-02-04 16:15:33 +01:00
|
|
|
* `name` {string} The name of the a key.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2018-04-02 08:38:48 +03:00
|
|
|
The `rl.write()` method will write either `data` or a key sequence identified
|
2016-05-27 10:59:50 -07:00
|
|
|
by `key` to the `output`. The `key` argument is supported only if `output` is
|
2020-01-07 07:37:42 -05:00
|
|
|
a [TTY][] text terminal. See [TTY keybindings][] for a list of key
|
|
|
|
combinations.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
|
|
|
If `key` is specified, `data` is ignored.
|
|
|
|
|
|
|
|
When called, `rl.write()` will resume the `input` stream if it has been
|
|
|
|
paused.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
If the `InterfaceConstructor` was created with `output` set to `null` or
|
2016-05-27 10:59:50 -07:00
|
|
|
`undefined` the `data` and `key` are not written.
|
|
|
|
|
|
|
|
```js
|
|
|
|
rl.write('Delete this!');
|
2020-10-18 06:52:55 -07:00
|
|
|
// Simulate Ctrl+U to delete the line written previously
|
2017-06-01 02:07:25 +03:00
|
|
|
rl.write(null, { ctrl: true, name: 'u' });
|
2016-01-17 18:39:07 +01:00
|
|
|
```
|
2016-01-10 17:18:49 +01:00
|
|
|
|
2018-04-29 20:46:41 +03:00
|
|
|
The `rl.write()` method will write the data to the `readline` `Interface`'s
|
2021-10-10 21:55:04 -07:00
|
|
|
`input` _as if it were provided by the user_.
|
2016-08-26 21:36:43 -07:00
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl[Symbol.asyncIterator]()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2018-10-26 17:53:04 -07:00
|
|
|
<!-- YAML
|
2020-04-24 18:43:06 +02:00
|
|
|
added:
|
|
|
|
- v11.4.0
|
|
|
|
- v10.16.0
|
2019-04-01 10:07:57 +02:00
|
|
|
changes:
|
2020-04-24 18:43:06 +02:00
|
|
|
- version:
|
|
|
|
- v11.14.0
|
|
|
|
- v10.17.0
|
2019-04-01 10:07:57 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/26989
|
|
|
|
description: Symbol.asyncIterator support is no longer experimental.
|
2018-10-26 17:53:04 -07:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: {AsyncIterator}
|
|
|
|
|
|
|
|
Create an `AsyncIterator` object that iterates through each line in the input
|
|
|
|
stream as a string. This method allows asynchronous iteration of
|
2021-04-27 16:14:39 +02:00
|
|
|
`InterfaceConstructor` objects through `for await...of` loops.
|
2018-10-26 17:53:04 -07:00
|
|
|
|
|
|
|
Errors in the input stream are not forwarded.
|
|
|
|
|
|
|
|
If the loop is terminated with `break`, `throw`, or `return`,
|
|
|
|
[`rl.close()`][] will be called. In other words, iterating over a
|
2021-04-27 16:14:39 +02:00
|
|
|
`InterfaceConstructor` will always consume the input stream fully.
|
2018-10-26 17:53:04 -07:00
|
|
|
|
2019-06-25 13:18:36 -04:00
|
|
|
Performance is not on par with the traditional `'line'` event API. Use `'line'`
|
|
|
|
instead for performance-sensitive applications.
|
2018-10-26 17:53:04 -07:00
|
|
|
|
|
|
|
```js
|
|
|
|
async function processLineByLine() {
|
|
|
|
const rl = readline.createInterface({
|
|
|
|
// ...
|
|
|
|
});
|
|
|
|
|
|
|
|
for await (const line of rl) {
|
|
|
|
// Each line in the readline input will be successively available here as
|
|
|
|
// `line`.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2020-08-08 10:01:36 +03:00
|
|
|
`readline.createInterface()` will start to consume the input stream once
|
|
|
|
invoked. Having asynchronous operations between interface creation and
|
|
|
|
asynchronous iteration may result in missed lines.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.line`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-11-22 20:56:42 -10:00
|
|
|
<!-- YAML
|
2020-02-23 11:54:39 -08:00
|
|
|
added: v0.1.98
|
2020-05-31 20:54:41 +02:00
|
|
|
changes:
|
2021-09-04 15:29:35 +02:00
|
|
|
- version:
|
|
|
|
- v15.8.0
|
|
|
|
- v14.18.0
|
2020-05-31 20:54:41 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/33676
|
|
|
|
description: Value will always be a string, never undefined.
|
2019-11-22 20:56:42 -10:00
|
|
|
-->
|
|
|
|
|
2020-05-31 20:54:41 +02:00
|
|
|
* {string}
|
2019-11-22 20:56:42 -10:00
|
|
|
|
|
|
|
The current input data being processed by node.
|
|
|
|
|
|
|
|
This can be used when collecting input from a TTY stream to retrieve the
|
|
|
|
current value that has been processed thus far, prior to the `line` event
|
2020-06-20 16:46:33 -07:00
|
|
|
being emitted. Once the `line` event has been emitted, this property will
|
2019-11-22 20:56:42 -10:00
|
|
|
be an empty string.
|
|
|
|
|
|
|
|
Be aware that modifying the value during the instance runtime may have
|
|
|
|
unintended consequences if `rl.cursor` is not also controlled.
|
|
|
|
|
|
|
|
**If not using a TTY stream for input, use the [`'line'`][] event.**
|
|
|
|
|
|
|
|
One possible use case would be as follows:
|
|
|
|
|
|
|
|
```js
|
|
|
|
const values = ['lorem ipsum', 'dolor sit amet'];
|
|
|
|
const rl = readline.createInterface(process.stdin);
|
|
|
|
const showResults = debounce(() => {
|
|
|
|
console.log(
|
|
|
|
'\n',
|
2022-11-17 08:19:12 -05:00
|
|
|
values.filter((val) => val.startsWith(rl.line)).join(' '),
|
2019-11-22 20:56:42 -10:00
|
|
|
);
|
|
|
|
}, 300);
|
|
|
|
process.stdin.on('keypress', (c, k) => {
|
|
|
|
showResults();
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.cursor`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-11-22 20:56:42 -10:00
|
|
|
<!-- YAML
|
2020-02-23 11:54:39 -08:00
|
|
|
added: v0.1.98
|
2019-11-22 20:56:42 -10:00
|
|
|
-->
|
|
|
|
|
|
|
|
* {number|undefined}
|
|
|
|
|
|
|
|
The cursor position relative to `rl.line`.
|
|
|
|
|
|
|
|
This will track where the current cursor lands in the input string, when
|
2020-06-20 16:46:33 -07:00
|
|
|
reading input from a TTY stream. The position of cursor determines the
|
2019-11-22 20:56:42 -10:00
|
|
|
portion of the input string that will be modified as input is processed,
|
|
|
|
as well as the column where the terminal caret will be rendered.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
### `rl.getCursorPos()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2019-11-27 11:02:02 -09:00
|
|
|
<!-- YAML
|
2020-04-24 18:43:06 +02:00
|
|
|
added:
|
|
|
|
- v13.5.0
|
|
|
|
- v12.16.0
|
2019-11-27 11:02:02 -09:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: {Object}
|
|
|
|
* `rows` {number} the row of the prompt the cursor currently lands on
|
|
|
|
* `cols` {number} the screen column the cursor currently lands on
|
|
|
|
|
|
|
|
Returns the real position of the cursor in relation to the input
|
2020-06-20 16:46:33 -07:00
|
|
|
prompt + string. Long input (wrapping) strings, as well as multiple
|
2019-11-27 11:02:02 -09:00
|
|
|
line prompts are included in the calculations.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
## Promises API
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2025-03-16 17:27:47 -07:00
|
|
|
changes:
|
|
|
|
- version: REPLACEME
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/57513
|
|
|
|
description: Marking the API stable.
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
### Class: `readlinePromises.Interface`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Extends: {readline.InterfaceConstructor}
|
|
|
|
|
|
|
|
Instances of the `readlinePromises.Interface` class are constructed using the
|
|
|
|
`readlinePromises.createInterface()` method. Every instance is associated with a
|
|
|
|
single `input` [Readable][] stream and a single `output` [Writable][] stream.
|
|
|
|
The `output` stream is used to print prompts for user input that arrives on,
|
|
|
|
and is read from, the `input` stream.
|
|
|
|
|
|
|
|
#### `rl.question(query[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `query` {string} A statement or query to write to `output`, prepended to the
|
|
|
|
prompt.
|
|
|
|
* `options` {Object}
|
|
|
|
* `signal` {AbortSignal} Optionally allows the `question()` to be canceled
|
2022-03-28 18:44:21 +08:00
|
|
|
using an `AbortSignal`.
|
2021-04-27 16:14:39 +02:00
|
|
|
* Returns: {Promise} A promise that is fulfilled with the user's
|
|
|
|
input in response to the `query`.
|
|
|
|
|
|
|
|
The `rl.question()` method displays the `query` by writing it to the `output`,
|
|
|
|
waits for user input to be provided on `input`, then invokes the `callback`
|
|
|
|
function passing the provided input as the first argument.
|
|
|
|
|
|
|
|
When called, `rl.question()` will resume the `input` stream if it has been
|
|
|
|
paused.
|
|
|
|
|
|
|
|
If the `readlinePromises.Interface` was created with `output` set to `null` or
|
|
|
|
`undefined` the `query` is not written.
|
|
|
|
|
2022-04-08 18:17:03 +08:00
|
|
|
If the question is called after `rl.close()`, it returns a rejected promise.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
Example usage:
|
|
|
|
|
|
|
|
```mjs
|
|
|
|
const answer = await rl.question('What is your favorite food? ');
|
|
|
|
console.log(`Oh, so your favorite food is ${answer}`);
|
|
|
|
```
|
|
|
|
|
2022-03-28 18:44:21 +08:00
|
|
|
Using an `AbortSignal` to cancel a question.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
```mjs
|
2022-03-28 18:44:21 +08:00
|
|
|
const signal = AbortSignal.timeout(10_000);
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
signal.addEventListener('abort', () => {
|
|
|
|
console.log('The food question timed out');
|
|
|
|
}, { once: true });
|
|
|
|
|
2022-03-28 18:44:21 +08:00
|
|
|
const answer = await rl.question('What is your favorite food? ', { signal });
|
|
|
|
console.log(`Oh, so your favorite food is ${answer}`);
|
2021-04-27 16:14:39 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
### Class: `readlinePromises.Readline`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
2021-08-05 20:01:33 +02:00
|
|
|
#### `new readlinePromises.Readline(stream[, options])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `stream` {stream.Writable} A [TTY][] stream.
|
2021-08-05 20:01:33 +02:00
|
|
|
* `options` {Object}
|
|
|
|
* `autoCommit` {boolean} If `true`, no need to call `rl.commit()`.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
#### `rl.clearLine(dir)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `dir` {integer}
|
|
|
|
* `-1`: to the left from cursor
|
|
|
|
* `1`: to the right from cursor
|
|
|
|
* `0`: the entire line
|
|
|
|
* Returns: this
|
|
|
|
|
|
|
|
The `rl.clearLine()` method adds to the internal list of pending action an
|
|
|
|
action that clears current line of the associated `stream` in a specified
|
|
|
|
direction identified by `dir`.
|
2021-08-05 20:01:33 +02:00
|
|
|
Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`
|
|
|
|
was passed to the constructor.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
#### `rl.clearScreenDown()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: this
|
|
|
|
|
|
|
|
The `rl.clearScreenDown()` method adds to the internal list of pending action an
|
|
|
|
action that clears the associated stream from the current position of the
|
|
|
|
cursor down.
|
2021-08-05 20:01:33 +02:00
|
|
|
Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`
|
|
|
|
was passed to the constructor.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
#### `rl.commit()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: {Promise}
|
|
|
|
|
|
|
|
The `rl.commit()` method sends all the pending actions to the associated
|
|
|
|
`stream` and clears the internal list of pending actions.
|
|
|
|
|
|
|
|
#### `rl.cursorTo(x[, y])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `x` {integer}
|
|
|
|
* `y` {integer}
|
|
|
|
* Returns: this
|
|
|
|
|
|
|
|
The `rl.cursorTo()` method adds to the internal list of pending action an action
|
|
|
|
that moves cursor to the specified position in the associated `stream`.
|
2021-08-05 20:01:33 +02:00
|
|
|
Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`
|
|
|
|
was passed to the constructor.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
#### `rl.moveCursor(dx, dy)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `dx` {integer}
|
|
|
|
* `dy` {integer}
|
|
|
|
* Returns: this
|
|
|
|
|
|
|
|
The `rl.moveCursor()` method adds to the internal list of pending action an
|
2021-10-10 21:55:04 -07:00
|
|
|
action that moves the cursor _relative_ to its current position in the
|
2021-04-27 16:14:39 +02:00
|
|
|
associated `stream`.
|
2021-08-05 20:01:33 +02:00
|
|
|
Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`
|
|
|
|
was passed to the constructor.
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
#### `rl.rollback()`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* Returns: this
|
|
|
|
|
|
|
|
The `rl.rollback` methods clears the internal list of pending actions without
|
|
|
|
sending it to the associated `stream`.
|
|
|
|
|
|
|
|
### `readlinePromises.createInterface(options)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
added: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
-->
|
|
|
|
|
|
|
|
* `options` {Object}
|
|
|
|
* `input` {stream.Readable} The [Readable][] stream to listen to. This option
|
2021-10-10 21:55:04 -07:00
|
|
|
is _required_.
|
2021-04-27 16:14:39 +02:00
|
|
|
* `output` {stream.Writable} The [Writable][] stream to write readline data
|
|
|
|
to.
|
|
|
|
* `completer` {Function} An optional function used for Tab autocompletion.
|
|
|
|
* `terminal` {boolean} `true` if the `input` and `output` streams should be
|
|
|
|
treated like a TTY, and have ANSI/VT100 escape codes written to it.
|
|
|
|
**Default:** checking `isTTY` on the `output` stream upon instantiation.
|
2021-10-10 21:55:04 -07:00
|
|
|
* `history` {string\[]} Initial list of history lines. This option makes sense
|
2021-04-27 16:14:39 +02:00
|
|
|
only if `terminal` is set to `true` by the user or by an internal `output`
|
|
|
|
check, otherwise the history caching mechanism is not initialized at all.
|
|
|
|
**Default:** `[]`.
|
|
|
|
* `historySize` {number} Maximum number of history lines retained. To disable
|
|
|
|
the history set this value to `0`. This option makes sense only if
|
|
|
|
`terminal` is set to `true` by the user or by an internal `output` check,
|
|
|
|
otherwise the history caching mechanism is not initialized at all.
|
|
|
|
**Default:** `30`.
|
|
|
|
* `removeHistoryDuplicates` {boolean} If `true`, when a new input line added
|
|
|
|
to the history list duplicates an older one, this removes the older line
|
|
|
|
from the list. **Default:** `false`.
|
|
|
|
* `prompt` {string} The prompt string to use. **Default:** `'> '`.
|
|
|
|
* `crlfDelay` {number} If the delay between `\r` and `\n` exceeds
|
|
|
|
`crlfDelay` milliseconds, both `\r` and `\n` will be treated as separate
|
|
|
|
end-of-line input. `crlfDelay` will be coerced to a number no less than
|
|
|
|
`100`. It can be set to `Infinity`, in which case `\r` followed by `\n`
|
|
|
|
will always be considered a single newline (which may be reasonable for
|
|
|
|
[reading files][] with `\r\n` line delimiter). **Default:** `100`.
|
|
|
|
* `escapeCodeTimeout` {number} The duration `readlinePromises` will wait for a
|
|
|
|
character (when reading an ambiguous key sequence in milliseconds one that
|
|
|
|
can both form a complete key sequence using the input read so far and can
|
|
|
|
take additional input to complete a longer key sequence).
|
|
|
|
**Default:** `500`.
|
|
|
|
* `tabSize` {integer} The number of spaces a tab is equal to (minimum 1).
|
|
|
|
**Default:** `8`.
|
2025-05-04 03:24:42 +08:00
|
|
|
* `signal` {AbortSignal} Allows closing the interface using an AbortSignal.
|
2021-04-27 16:14:39 +02:00
|
|
|
* Returns: {readlinePromises.Interface}
|
|
|
|
|
|
|
|
The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`
|
|
|
|
instance.
|
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { createInterface } from 'node:readline/promises';
|
|
|
|
import { stdin, stdout } from 'node:process';
|
|
|
|
const rl = createInterface({
|
|
|
|
input: stdin,
|
|
|
|
output: stdout,
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { createInterface } = require('node:readline/promises');
|
|
|
|
const rl = createInterface({
|
2021-04-27 16:14:39 +02:00
|
|
|
input: process.stdin,
|
2022-11-17 08:19:12 -05:00
|
|
|
output: process.stdout,
|
2021-04-27 16:14:39 +02:00
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Once the `readlinePromises.Interface` instance is created, the most common case
|
|
|
|
is to listen for the `'line'` event:
|
|
|
|
|
|
|
|
```js
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
console.log(`Received: ${line}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
If `terminal` is `true` for this instance then the `output` stream will get
|
|
|
|
the best compatibility if it defines an `output.columns` property and emits
|
|
|
|
a `'resize'` event on the `output` if or when the columns ever change
|
|
|
|
([`process.stdout`][] does this automatically when it is a TTY).
|
|
|
|
|
|
|
|
#### Use of the `completer` function
|
|
|
|
|
|
|
|
The `completer` function takes the current line entered by the user
|
|
|
|
as an argument, and returns an `Array` with 2 entries:
|
|
|
|
|
|
|
|
* An `Array` with matching entries for the completion.
|
|
|
|
* The substring that was used for the matching.
|
|
|
|
|
|
|
|
For instance: `[[substr1, substr2, ...], originalsubstring]`.
|
|
|
|
|
|
|
|
```js
|
|
|
|
function completer(line) {
|
|
|
|
const completions = '.help .error .exit .quit .q'.split(' ');
|
|
|
|
const hits = completions.filter((c) => c.startsWith(line));
|
|
|
|
// Show all completions if none found
|
|
|
|
return [hits.length ? hits : completions, line];
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2023-05-27 22:32:38 +03:00
|
|
|
The `completer` function can also return a {Promise}, or be asynchronous:
|
2021-04-27 16:14:39 +02:00
|
|
|
|
|
|
|
```js
|
|
|
|
async function completer(linePartial) {
|
|
|
|
await someAsyncWork();
|
|
|
|
return [['123'], linePartial];
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Callback API
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.104
|
|
|
|
-->
|
|
|
|
|
|
|
|
### Class: `readline.Interface`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.104
|
|
|
|
changes:
|
2021-10-19, Version 17.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup`
options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- doc: deprecate (doc-only) http abort related
(dr-js) [https://github.com/nodejs/node/pull/36670]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
OpenSSL 3.0:
Node.js now includes OpenSSL 3.0, specifically https://github.com/quictls/openssl
which provides QUIC support.
While OpenSSL 3.0 APIs should be mostly compatible with those provided
by OpenSSL 1.1.1, we do anticipate some ecosystem impact due to
tightened restrictions on the allowed algorithms and key sizes.
If you hit an `ERR_OSSL_EVP_UNSUPPORTED` error in your application with
Node.js 17, it’s likely that your application or a module you’re using
is attempting to use an algorithm or key size which is no longer allowed
by default with OpenSSL 3.0. A command-line option,
`--openssl-legacy-provider`, has been added to revert to the legacy
provider as a temporary workaround for these tightened restrictions.
For details about all the features in
OpenSSL 3.0 please see https://www.openssl.org/blog/blog/2021/09/07/OpenSSL3.Final.
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
Contributed in https://github.com/nodejs/node/pull/38512, https://github.com/nodejs/node/pull/40478
V8 9.5:
The V8 JavaScript engine is updated to V8 9.5. This release comes with
additional supported types for the `Intl.DisplayNames` API and Extended
`timeZoneName` options in the `Intl.DateTimeFormat` API. You can read
more details in the V8 9.5 release post https://v8.dev/blog/v8-release-95.
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
Readline Promise API:
The `readline` module provides an interface for reading data from a
Readable stream (such as `process.stdin`) one line at a time.
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
Other Notable Changes:
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) errors: print Node.js version on fatal exceptions that
cause exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- deps: upgrade npm to 8.1.0
(npm team) [https://github.com/nodejs/node/pull/40463]
- (SEMVER-MINOR) fs: add FileHandle.prototype.readableWebStream()
(James M Snell) [https://github.com/nodejs/node/pull/39331]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
Semver-Major Commits:
- (SEMVER-MAJOR) build: compile with C++17 (MSVC)
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) build: compile with --gnu++17
(Richard Lau) [https://github.com/nodejs/node/pull/38807]
- (SEMVER-MAJOR) deps: update V8 to 9.5.172.19
(Michaël Zasso) [https://github.com/nodejs/node/pull/40178]
- (SEMVER-MAJOR) deps,test,src,doc,tools: update to OpenSSL 3.0
(Daniel Bevenius) [https://github.com/nodejs/node/pull/38512]
- (SEMVER-MAJOR) dgram: tighten `address` validation in `socket.send`
(Voltrex) [https://github.com/nodejs/node/pull/39190]
- (SEMVER-MAJOR) dns: runtime deprecate type coercion of `dns.lookup` options
(Antoine du Hamel) [https://github.com/nodejs/node/pull/39793]
- (SEMVER-MAJOR) dns: default to verbatim=true in dns.lookup()
(treysis) [https://github.com/nodejs/node/pull/39987]
- (SEMVER-MAJOR) doc: update minimum supported FreeBSD to 12.2
(Michaël Zasso) [https://github.com/nodejs/node/pull/40179]
- (SEMVER-MAJOR) errors: disp ver on fatal except that causes exit
(Divlo) [https://github.com/nodejs/node/pull/38332]
- (SEMVER-MAJOR) fs: fix rmsync error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38684]
- (SEMVER-MAJOR) fs: aggregate errors in fsPromises to avoid error swallowing
(Nitzan Uziely) [https://github.com/nodejs/node/pull/38259]
- (SEMVER-MAJOR) lib: add structuredClone() global
(Ethan Arrowood) [https://github.com/nodejs/node/pull/39759]
- (SEMVER-MAJOR) lib: expose `DOMException` as global
(Khaidi Chu) [https://github.com/nodejs/node/pull/39176]
- (SEMVER-MAJOR) module: subpath folder mappings EOL
(Guy Bedford) [https://github.com/nodejs/node/pull/40121]
- (SEMVER-MAJOR) module: runtime deprecate trailing slash patterns
(Guy Bedford) [https://github.com/nodejs/node/pull/40117]
- (SEMVER-MAJOR) readline: validate `AbortSignal`s and remove unused event listeners
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: introduce promise-based API
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) readline: refactor `Interface` to ES2015 class
(Antoine du Hamel) [https://github.com/nodejs/node/pull/37947]
- (SEMVER-MAJOR) src: allow CAP\_NET\_BIND\_SERVICE in SafeGetenv
(Daniel Bevenius) [https://github.com/nodejs/node/pull/37727]
- (SEMVER-MAJOR) src: return Maybe from a couple of functions
(Darshan Sen) [https://github.com/nodejs/node/pull/39603]
- (SEMVER-MAJOR) src: allow custom PageAllocator in NodePlatform
(Shelley Vohr) [https://github.com/nodejs/node/pull/38362]
- (SEMVER-MAJOR) stream: fix highwatermark threshold and add the missing error
(Rongjian Zhang) [https://github.com/nodejs/node/pull/38700]
- (SEMVER-MAJOR) stream: don't emit 'data' after 'error' or 'close'
(Robert Nagy) [https://github.com/nodejs/node/pull/39639]
- (SEMVER-MAJOR) stream: do not emit `end` on readable error
(Szymon Marczak) [https://github.com/nodejs/node/pull/39607]
- (SEMVER-MAJOR) stream: forward errored to callback
(Robert Nagy) [https://github.com/nodejs/node/pull/39364]
- (SEMVER-MAJOR) stream: destroy readable on read error
(Robert Nagy) [https://github.com/nodejs/node/pull/39342]
- (SEMVER-MAJOR) stream: validate abort signal
(Robert Nagy) [https://github.com/nodejs/node/pull/39346]
- (SEMVER-MAJOR) stream: unify stream utils
(Robert Nagy) [https://github.com/nodejs/node/pull/39294]
- (SEMVER-MAJOR) stream: throw on premature close in Readable\
(Darshan Sen) [https://github.com/nodejs/node/pull/39117]
- (SEMVER-MAJOR) stream: finished should error on errored stream
(Robert Nagy) [https://github.com/nodejs/node/pull/39235]
- (SEMVER-MAJOR) stream: error Duplex write/read if not writable/readable
(Robert Nagy) [https://github.com/nodejs/node/pull/34385]
- (SEMVER-MAJOR) stream: bypass legacy destroy for pipeline and async iteration
(Robert Nagy) [https://github.com/nodejs/node/pull/38505]
- (SEMVER-MAJOR) url: throw invalid this on detached accessors
(James M Snell) [https://github.com/nodejs/node/pull/39752]
- (SEMVER-MAJOR) url: forbid certain confusable changes from being introduced by toASCII
(Timothy Gu) [https://github.com/nodejs/node/pull/38631]
PR-URL: https://github.com/nodejs/node/pull/40119
2021-09-15 01:55:37 +01:00
|
|
|
- version: v17.0.0
|
2021-04-27 16:14:39 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37947
|
|
|
|
description: The class `readline.Interface` now inherits from `Interface`.
|
|
|
|
-->
|
|
|
|
|
|
|
|
* Extends: {readline.InterfaceConstructor}
|
|
|
|
|
|
|
|
Instances of the `readline.Interface` class are constructed using the
|
|
|
|
`readline.createInterface()` method. Every instance is associated with a
|
|
|
|
single `input` [Readable][] stream and a single `output` [Writable][] stream.
|
|
|
|
The `output` stream is used to print prompts for user input that arrives on,
|
|
|
|
and is read from, the `input` stream.
|
|
|
|
|
|
|
|
#### `rl.question(query[, options], callback)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.3.3
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `query` {string} A statement or query to write to `output`, prepended to the
|
|
|
|
prompt.
|
|
|
|
* `options` {Object}
|
|
|
|
* `signal` {AbortSignal} Optionally allows the `question()` to be canceled
|
|
|
|
using an `AbortController`.
|
|
|
|
* `callback` {Function} A callback function that is invoked with the user's
|
|
|
|
input in response to the `query`.
|
|
|
|
|
|
|
|
The `rl.question()` method displays the `query` by writing it to the `output`,
|
|
|
|
waits for user input to be provided on `input`, then invokes the `callback`
|
|
|
|
function passing the provided input as the first argument.
|
|
|
|
|
|
|
|
When called, `rl.question()` will resume the `input` stream if it has been
|
|
|
|
paused.
|
|
|
|
|
|
|
|
If the `readline.Interface` was created with `output` set to `null` or
|
|
|
|
`undefined` the `query` is not written.
|
|
|
|
|
|
|
|
The `callback` function passed to `rl.question()` does not follow the typical
|
|
|
|
pattern of accepting an `Error` object or `null` as the first argument.
|
|
|
|
The `callback` is called with the provided answer as the only argument.
|
|
|
|
|
2022-04-08 18:17:03 +08:00
|
|
|
An error will be thrown if calling `rl.question()` after `rl.close()`.
|
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
Example usage:
|
|
|
|
|
|
|
|
```js
|
|
|
|
rl.question('What is your favorite food? ', (answer) => {
|
|
|
|
console.log(`Oh, so your favorite food is ${answer}`);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
Using an `AbortController` to cancel a question.
|
|
|
|
|
|
|
|
```js
|
|
|
|
const ac = new AbortController();
|
|
|
|
const signal = ac.signal;
|
|
|
|
|
|
|
|
rl.question('What is your favorite food? ', { signal }, (answer) => {
|
|
|
|
console.log(`Oh, so your favorite food is ${answer}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
signal.addEventListener('abort', () => {
|
|
|
|
console.log('The food question timed out');
|
|
|
|
}, { once: true });
|
|
|
|
|
|
|
|
setTimeout(() => ac.abort(), 10000);
|
|
|
|
```
|
|
|
|
|
|
|
|
### `readline.clearLine(stream, dir[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.7
|
2019-07-13 18:08:19 -04:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2019-07-23 10:29:14 +02:00
|
|
|
- version: v12.7.0
|
2019-07-13 18:08:19 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28674
|
|
|
|
description: The stream's write() callback and return value are exposed.
|
2016-05-26 11:39:07 -04:00
|
|
|
-->
|
2014-01-23 15:35:50 +04:00
|
|
|
|
2018-01-30 00:15:53 +02:00
|
|
|
* `stream` {stream.Writable}
|
2016-05-27 10:59:50 -07:00
|
|
|
* `dir` {number}
|
2019-10-23 21:28:42 -07:00
|
|
|
* `-1`: to the left from cursor
|
|
|
|
* `1`: to the right from cursor
|
|
|
|
* `0`: the entire line
|
2019-07-13 18:08:19 -04:00
|
|
|
* `callback` {Function} Invoked once the operation completes.
|
|
|
|
* Returns: {boolean} `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`.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
|
|
|
The `readline.clearLine()` method clears current line of given [TTY][] stream
|
|
|
|
in a specified direction identified by `dir`.
|
2014-01-23 15:35:50 +04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
### `readline.clearScreenDown(stream[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.7
|
2019-07-11 12:35:34 -04:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2019-07-23 10:29:14 +02:00
|
|
|
- version: v12.7.0
|
2019-07-11 12:35:34 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28641
|
|
|
|
description: The stream's write() callback and return value are exposed.
|
2016-05-26 11:39:07 -04:00
|
|
|
-->
|
2014-01-23 15:35:50 +04:00
|
|
|
|
2018-01-30 00:15:53 +02:00
|
|
|
* `stream` {stream.Writable}
|
2019-07-11 12:35:34 -04:00
|
|
|
* `callback` {Function} Invoked once the operation completes.
|
|
|
|
* Returns: {boolean} `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`.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
|
|
|
The `readline.clearScreenDown()` method clears the given [TTY][] stream from
|
|
|
|
the current position of the cursor down.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
### `readline.createInterface(options)`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.1.98
|
2017-02-21 23:38:48 +01:00
|
|
|
changes:
|
2021-09-04 15:29:35 +02:00
|
|
|
- version:
|
|
|
|
- v15.14.0
|
|
|
|
- v14.18.0
|
2021-03-26 19:30:00 +03:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/37932
|
|
|
|
description: The `signal` option is supported now.
|
2021-09-04 15:29:35 +02:00
|
|
|
- version:
|
|
|
|
- v15.8.0
|
|
|
|
- v14.18.0
|
2020-05-30 22:17:09 +02:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/33662
|
|
|
|
description: The `history` option is supported now.
|
2020-02-17 13:02:21 -08:00
|
|
|
- version: v13.9.0
|
2020-01-12 21:03:35 +01:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/31318
|
|
|
|
description: The `tabSize` option is supported now.
|
2020-10-01 20:23:33 +02:00
|
|
|
- version:
|
|
|
|
- v8.3.0
|
|
|
|
- v6.11.4
|
2017-10-08 03:19:57 +03:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/13497
|
|
|
|
description: Remove max limit of `crlfDelay` option.
|
|
|
|
- version: v6.6.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/8109
|
|
|
|
description: The `crlfDelay` option is supported now.
|
2017-02-21 23:38:48 +01:00
|
|
|
- version: v6.3.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/7125
|
|
|
|
description: The `prompt` option is supported now.
|
|
|
|
- version: v6.0.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/6352
|
|
|
|
description: The `historySize` option can be `0` now.
|
2016-05-26 11:39:07 -04:00
|
|
|
-->
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
* `options` {Object}
|
2018-02-12 02:31:55 -05:00
|
|
|
* `input` {stream.Readable} The [Readable][] stream to listen to. This option
|
2021-10-10 21:55:04 -07:00
|
|
|
is _required_.
|
2018-02-12 02:31:55 -05:00
|
|
|
* `output` {stream.Writable} The [Writable][] stream to write readline data
|
|
|
|
to.
|
2016-05-27 10:59:50 -07:00
|
|
|
* `completer` {Function} An optional function used for Tab autocompletion.
|
|
|
|
* `terminal` {boolean} `true` if the `input` and `output` streams should be
|
|
|
|
treated like a TTY, and have ANSI/VT100 escape codes written to it.
|
2018-04-02 04:44:32 +03:00
|
|
|
**Default:** checking `isTTY` on the `output` stream upon instantiation.
|
2021-10-10 21:55:04 -07:00
|
|
|
* `history` {string\[]} Initial list of history lines. This option makes sense
|
2020-05-30 22:17:09 +02:00
|
|
|
only if `terminal` is set to `true` by the user or by an internal `output`
|
|
|
|
check, otherwise the history caching mechanism is not initialized at all.
|
|
|
|
**Default:** `[]`.
|
2017-10-27 21:51:28 +02:00
|
|
|
* `historySize` {number} Maximum number of history lines retained. To disable
|
2018-02-12 02:31:55 -05:00
|
|
|
the history set this value to `0`. This option makes sense only if
|
|
|
|
`terminal` is set to `true` by the user or by an internal `output` check,
|
|
|
|
otherwise the history caching mechanism is not initialized at all.
|
2018-04-02 04:44:32 +03:00
|
|
|
**Default:** `30`.
|
2020-05-30 22:17:09 +02:00
|
|
|
* `removeHistoryDuplicates` {boolean} If `true`, when a new input line added
|
|
|
|
to the history list duplicates an older one, this removes the older line
|
|
|
|
from the list. **Default:** `false`.
|
2018-04-02 04:44:32 +03:00
|
|
|
* `prompt` {string} The prompt string to use. **Default:** `'> '`.
|
2016-08-15 17:37:01 +05:30
|
|
|
* `crlfDelay` {number} If the delay between `\r` and `\n` exceeds
|
|
|
|
`crlfDelay` milliseconds, both `\r` and `\n` will be treated as separate
|
2018-02-12 02:31:55 -05:00
|
|
|
end-of-line input. `crlfDelay` will be coerced to a number no less than
|
|
|
|
`100`. It can be set to `Infinity`, in which case `\r` followed by `\n`
|
|
|
|
will always be considered a single newline (which may be reasonable for
|
2018-04-02 04:44:32 +03:00
|
|
|
[reading files][] with `\r\n` line delimiter). **Default:** `100`.
|
2018-04-04 00:00:35 +04:30
|
|
|
* `escapeCodeTimeout` {number} The duration `readline` will wait for a
|
|
|
|
character (when reading an ambiguous key sequence in milliseconds one that
|
|
|
|
can both form a complete key sequence using the input read so far and can
|
|
|
|
take additional input to complete a longer key sequence).
|
|
|
|
**Default:** `500`.
|
2020-01-12 21:03:35 +01:00
|
|
|
* `tabSize` {integer} The number of spaces a tab is equal to (minimum 1).
|
|
|
|
**Default:** `8`.
|
2021-03-26 19:30:00 +03:00
|
|
|
* `signal` {AbortSignal} Allows closing the interface using an AbortSignal.
|
|
|
|
Aborting the signal will internally call `close` on the interface.
|
2021-03-04 21:15:00 +05:30
|
|
|
* Returns: {readline.Interface}
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `readline.createInterface()` method creates a new `readline.Interface`
|
|
|
|
instance.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { createInterface } from 'node:readline';
|
|
|
|
import { stdin, stdout } from 'node:process';
|
|
|
|
const rl = createInterface({
|
|
|
|
input: stdin,
|
|
|
|
output: stdout,
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { createInterface } = require('node:readline');
|
|
|
|
const rl = createInterface({
|
2016-05-27 10:59:50 -07:00
|
|
|
input: process.stdin,
|
2022-11-17 08:19:12 -05:00
|
|
|
output: process.stdout,
|
2016-05-27 10:59:50 -07:00
|
|
|
});
|
|
|
|
```
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
Once the `readline.Interface` instance is created, the most common case is to
|
|
|
|
listen for the `'line'` event:
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
```js
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
console.log(`Received: ${line}`);
|
|
|
|
});
|
|
|
|
```
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
If `terminal` is `true` for this instance then the `output` stream will get
|
|
|
|
the best compatibility if it defines an `output.columns` property and emits
|
|
|
|
a `'resize'` event on the `output` if or when the columns ever change
|
|
|
|
([`process.stdout`][] does this automatically when it is a TTY).
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-01 09:09:11 -04:00
|
|
|
When creating a `readline.Interface` using `stdin` as input, the program
|
2022-01-22 19:21:17 -08:00
|
|
|
will not terminate until it receives an [EOF character][]. To exit without
|
|
|
|
waiting for user input, call `process.stdin.unref()`.
|
2021-04-01 09:09:11 -04:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
#### Use of the `completer` function
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2017-04-23 03:12:22 +03:00
|
|
|
The `completer` function takes the current line entered by the user
|
2018-04-29 20:46:41 +03:00
|
|
|
as an argument, and returns an `Array` with 2 entries:
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2018-04-29 20:46:41 +03:00
|
|
|
* An `Array` with matching entries for the completion.
|
2016-05-27 10:59:50 -07:00
|
|
|
* The substring that was used for the matching.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
For instance: `[[substr1, substr2, ...], originalsubstring]`.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
function completer(line) {
|
2016-11-16 01:41:14 +02:00
|
|
|
const completions = '.help .error .exit .quit .q'.split(' ');
|
2017-04-25 02:38:52 +03:00
|
|
|
const hits = completions.filter((c) => c.startsWith(line));
|
2019-03-07 01:03:53 +01:00
|
|
|
// Show all completions if none found
|
2016-07-14 22:41:29 -07:00
|
|
|
return [hits.length ? hits : completions, line];
|
2016-01-17 18:39:07 +01:00
|
|
|
}
|
|
|
|
```
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
The `completer` function can be called asynchronously if it accepts two
|
|
|
|
arguments:
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2016-01-17 18:39:07 +01:00
|
|
|
```js
|
|
|
|
function completer(linePartial, callback) {
|
|
|
|
callback(null, [['123'], linePartial]);
|
|
|
|
}
|
|
|
|
```
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
### `readline.cursorTo(stream, x[, y][, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.7
|
2019-07-13 20:10:17 -04:00
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2019-07-23 10:29:14 +02:00
|
|
|
- version: v12.7.0
|
2019-07-13 20:10:17 -04:00
|
|
|
pr-url: https://github.com/nodejs/node/pull/28674
|
|
|
|
description: The stream's write() callback and return value are exposed.
|
2016-05-26 11:39:07 -04:00
|
|
|
-->
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2018-01-30 00:15:53 +02:00
|
|
|
* `stream` {stream.Writable}
|
2016-05-27 10:59:50 -07:00
|
|
|
* `x` {number}
|
|
|
|
* `y` {number}
|
2019-07-13 20:10:17 -04:00
|
|
|
* `callback` {Function} Invoked once the operation completes.
|
|
|
|
* Returns: {boolean} `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`.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
|
|
|
The `readline.cursorTo()` method moves cursor to the specified position in a
|
|
|
|
given [TTY][] `stream`.
|
2015-11-04 12:43:06 -05:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
### `readline.moveCursor(stream, dx, dy[, callback])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2021-04-27 16:14:39 +02:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.7
|
|
|
|
changes:
|
2022-04-19, Version 18.0.0 (Current)
Notable Changes:
Deprecations and Removals:
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) stream: remove thenable support (Robert Nagy)
(https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
fetch (experimental):
An experimental fetch API is available on the global scope by default.
The implementation is based upon https://undici.nodejs.org/#/,
an HTTP/1.1 client written for Node.js by contributors to the project.
Through this addition, the following globals are made available: `fetch`
, `FormData`, `Headers`, `Request`, `Response`.
Disable this API with the `--no-experimental-fetch` command-line flag.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/41811.
HTTP Timeouts:
`server.headersTimeout`, which limits the amount of time the parser will
wait to receive the complete HTTP headers, is now set to `60000` (60
seconds) by default.
`server.requestTimeout`, which sets the timeout value in milliseconds
for receiving the entire request from the client, is now set to `300000`
(5 minutes) by default.
If these timeouts expire, the server responds with status 408 without
forwarding the request to the request listener and then closes the
connection.
Both timeouts must be set to a non-zero value to protect against
potential Denial-of-Service attacks in case the server is deployed
without a reverse proxy in front.
Contributed by Paolo Insogna in https://github.com/nodejs/node/pull/41263.
Test Runner module (experimental):
The `node:test` module facilitates the creation of JavaScript tests that
report results in TAP format. This module is only available under the
`node:` scheme.
Contributed by Colin Ihrig in https://github.com/nodejs/node/pull/42325.
Toolchain and Compiler Upgrades:
- Prebuilt binaries for Linux are now built on Red Hat Enterprise Linux
(RHEL) 8 and are compatible with Linux distributions based on glibc
2.28 or later, for example, Debian 10, RHEL 8, Ubuntu 20.04.
- Prebuilt binaries for macOS now require macOS 10.15 or later.
- For AIX the minimum supported architecture has been raised from Power
7 to Power 8.
Prebuilt binaries for 32-bit Windows will initially not be available due
to issues building the V8 dependency in Node.js. We hope to restore
32-bit Windows binaries for Node.js 18 with a future V8 update.
Node.js does not support running on operating systems that are no longer
supported by their vendor. For operating systems where their vendor has
planned to end support earlier than April 2025, such as Windows 8.1
(January 2023) and Windows Server 2012 R2 (October 2023), support for
Node.js 18 will end at the earlier date.
Full details about the supported toolchains and compilers are documented
in the Node.js `BUILDING.md` file.
Contributed by Richard Lau in https://github.com/nodejs/node/pull/42292,
https://github.com/nodejs/node/pull/42604 and https://github.com/nodejs/node/pull/42659
, and Michaël Zasso in https://github.com/nodejs/node/pull/42105 and
https://github.com/nodejs/node/pull/42666.
V8 10.1:
The V8 engine is updated to version 10.1, which is part of Chromium 101.
Compared to the version included in Node.js 17.9.0, the following new
features are included:
- The `findLast` and `findLastIndex` array methods.
- Improvements to the `Intl.Locale` API.
- The `Intl.supportedValuesOf` function.
- Improved performance of class fields and private class methods (the
initialization of them is now as fast as ordinary property stores).
The data format returned by the serialization API (`v8.serialize(value)`)
has changed, and cannot be deserialized by earlier versions of Node.js.
On the other hand, it is still possible to deserialize the previous
format, as the API is backwards-compatible.
Contributed by Michaël Zasso in https://github.com/nodejs/node/pull/42657.
Web Streams API (experimental):
Node.js now exposes the experimental implementation of the Web Streams
API on the global scope. This means the following APIs are now globally
available:
- `ReadableStream`, `ReadableStreamDefaultReader`,
`ReadableStreamBYOBReader`, `ReadableStreamBYOBRequest`,
`ReadableByteStreamController`, `ReadableStreamDefaultController`,
`TransformStream`, `TransformStreamDefaultController`, `WritableStream`,
`WritableStreamDefaultWriter`, `WritableStreamDefaultController`,
`ByteLengthQueuingStrategy`, `CountQueuingStrategy`, `TextEncoderStream`,
`TextDecoderStream`, `CompressionStream`, `DecompressionStream`.
Contributed James Snell in https://github.com/nodejs/node/pull/39062,
and Antoine du Hamel in https://github.com/nodejs/node/pull/42225.
Other Notable Changes:
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- doc: add RafaelGSS to collaborators
(RafaelGSS) (https://github.com/nodejs/node/pull/42718)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
Semver-Major Commits:
- (SEMVER-MAJOR) assert,util: compare RegExp.lastIndex while using deep
equal checks
(Ruben Bridgewater) (https://github.com/nodejs/node/pull/41020)
- (SEMVER-MAJOR) buffer: refactor `byteLength` to remove outdated
optimizations
(Rongjian Zhang) (https://github.com/nodejs/node/pull/38545)
- (SEMVER-MAJOR) buffer: expose Blob as a global
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) buffer: graduate Blob from experimental
(James M Snell) (https://github.com/nodejs/node/pull/41270)
- (SEMVER-MAJOR) build: make x86 Windows support temporarily
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42666)
- (SEMVER-MAJOR) build: bump macOS deployment target to 10.15
(Richard Lau) (https://github.com/nodejs/node/pull/42292)
- (SEMVER-MAJOR) build: downgrade Windows 8.1 and server 2012 R2 to
experimental
(Michaël Zasso) (https://github.com/nodejs/node/pull/42105)
- (SEMVER-MAJOR) child\_process: improve argument validation
(Rich Trott) (https://github.com/nodejs/node/pull/41305)
- (SEMVER-MAJOR) cluster: make `kill` to be just `process.kill`
(Bar Admoni) (https://github.com/nodejs/node/pull/34312)
- (SEMVER-MAJOR) crypto: cleanup validation
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/39841)
- (SEMVER-MAJOR) crypto: prettify othername in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42123)
- (SEMVER-MAJOR) crypto: fix X509Certificate toLegacyObject
(Tobias Nießen) (https://github.com/nodejs/node/pull/42124)
- (SEMVER-MAJOR) crypto: use RFC2253 format in PrintGeneralName
(Tobias Nießen) (https://github.com/nodejs/node/pull/42002)
- (SEMVER-MAJOR) crypto: change default check(Host|Email) behavior
(Tobias Nießen) (https://github.com/nodejs/node/pull/41600)
- (SEMVER-MAJOR) deps: V8: cherry-pick semver-major commits from 10.2
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 10.1.124.6
(Michaël Zasso) (https://github.com/nodejs/node/pull/42657)
- (SEMVER-MAJOR) deps: update V8 to 9.8.177.9
(Michaël Zasso) (https://github.com/nodejs/node/pull/41610)
- (SEMVER-MAJOR) deps: update V8 to 9.7.106.18
(Michaël Zasso) (https://github.com/nodejs/node/pull/40907)
- (SEMVER-MAJOR) dns: remove `dns.lookup` and `dnsPromises.lookup`
options type coercion
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) doc: update minimum glibc requirements for Linux
(Richard Lau) (https://github.com/nodejs/node/pull/42659)
- (SEMVER-MAJOR) doc: update AIX minimum supported arch
(Richard Lau) (https://github.com/nodejs/node/pull/42604)
- (SEMVER-MAJOR) fs: runtime deprecate string coercion in `fs.write`,
`fs.writeFileSync`
(Livia Medeiros) (https://github.com/nodejs/node/pull/42607)
- (SEMVER-MAJOR) http: refactor headersTimeout and requestTimeout logic
(Paolo Insogna) (https://github.com/nodejs/node/pull/41263)
- (SEMVER-MAJOR) http: make TCP noDelay enabled by default
(Paolo Insogna) (https://github.com/nodejs/node/pull/42163)
- (SEMVER-MAJOR) lib: enable fetch by default
(Michaël Zasso) (https://github.com/nodejs/node/pull/41811)
- (SEMVER-MAJOR) lib: replace validator and error
(Mohammed Keyvanzadeh) (https://github.com/nodejs/node/pull/41678)
- (SEMVER-MAJOR) module,repl: support 'node:'-only core modules
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) net: make `server.address()` return an integer for
`family`
(Antoine du Hamel) (https://github.com/nodejs/node/pull/41431)
- (SEMVER-MAJOR) process: disallow some uses of Object.defineProperty()
on process.env
(Himself65) (https://github.com/nodejs/node/pull/28006)
- (SEMVER-MAJOR) process: runtime deprecate multipleResolves
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41896)
- (SEMVER-MAJOR) readline: fix question still called after closed
(Xuguang Mei) (https://github.com/nodejs/node/pull/42464)
- (SEMVER-MAJOR) stream: remove thenable support
(Robert Nagy) (https://github.com/nodejs/node/pull/40773)
- (SEMVER-MAJOR) stream: expose web streams globals, remove runtime
experimental warning
(Antoine du Hamel) (https://github.com/nodejs/node/pull/42225)
- (SEMVER-MAJOR) stream: need to cleanup event listeners if last stream
is readable
(Xuguang Mei) (https://github.com/nodejs/node/pull/41954)
- (SEMVER-MAJOR) stream: revert revert `map` spec compliance
(Benjamin Gruenbaum) (https://github.com/nodejs/node/pull/41933)
- (SEMVER-MAJOR) stream: throw invalid arg type from End Of Stream
(Jithil P Ponnan) (https://github.com/nodejs/node/pull/41766)
- (SEMVER-MAJOR) stream: don't emit finish after destroy
(Robert Nagy) (https://github.com/nodejs/node/pull/40852)
- (SEMVER-MAJOR) stream: add errored and closed props
(Robert Nagy) (https://github.com/nodejs/node/pull/40696)
- (SEMVER-MAJOR) test: add initial test module
(Colin Ihrig) (https://github.com/nodejs/node/pull/42325)
- (SEMVER-MAJOR) timers: refactor internal classes to ES2015 syntax
(Rabbit) (https://github.com/nodejs/node/pull/37408)
- (SEMVER-MAJOR) tls: represent registeredID numerically always
(Tobias Nießen) (https://github.com/nodejs/node/pull/41561)
- (SEMVER-MAJOR) tls: move tls.parseCertString to end-of-life
(Tobias Nießen) (https://github.com/nodejs/node/pull/41479)
- (SEMVER-MAJOR) url: throw on NULL in IPv6 hostname
(Rich Trott) (https://github.com/nodejs/node/pull/42313)
- (SEMVER-MAJOR) v8: make v8.writeHeapSnapshot() error codes consistent
(Darshan Sen) (https://github.com/nodejs/node/pull/42577)
- (SEMVER-MAJOR) v8: make writeHeapSnapshot throw if fopen fails
(Antonio Román) (https://github.com/nodejs/node/pull/41373)
- (SEMVER-MAJOR) worker: expose BroadcastChannel as a global
(James M Snell) (https://github.com/nodejs/node/pull/41271)
- (SEMVER-MAJOR) worker: graduate BroadcastChannel to supported
(James M Snell) (https://github.com/nodejs/node/pull/41271)
PR-URL: https://github.com/nodejs/node/pull/42262
2022-03-08 01:39:47 +00:00
|
|
|
- version: v18.0.0
|
2022-01-24 19:39:16 +03:30
|
|
|
pr-url: https://github.com/nodejs/node/pull/41678
|
|
|
|
description: Passing an invalid callback to the `callback` argument
|
|
|
|
now throws `ERR_INVALID_ARG_TYPE` instead of
|
|
|
|
`ERR_INVALID_CALLBACK`.
|
2021-04-27 16:14:39 +02:00
|
|
|
- version: v12.7.0
|
|
|
|
pr-url: https://github.com/nodejs/node/pull/28674
|
|
|
|
description: The stream's write() callback and return value are exposed.
|
|
|
|
-->
|
|
|
|
|
|
|
|
* `stream` {stream.Writable}
|
|
|
|
* `dx` {number}
|
|
|
|
* `dy` {number}
|
|
|
|
* `callback` {Function} Invoked once the operation completes.
|
|
|
|
* Returns: {boolean} `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`.
|
|
|
|
|
2021-10-10 21:55:04 -07:00
|
|
|
The `readline.moveCursor()` method moves the cursor _relative_ to its current
|
2021-04-27 16:14:39 +02:00
|
|
|
position in a given [TTY][] `stream`.
|
|
|
|
|
2019-12-24 14:56:39 -08:00
|
|
|
## `readline.emitKeypressEvents(stream[, interface])`
|
2021-10-10 21:55:04 -07:00
|
|
|
|
2016-05-26 11:39:07 -04:00
|
|
|
<!-- YAML
|
|
|
|
added: v0.7.7
|
|
|
|
-->
|
2016-04-02 20:55:17 -04:00
|
|
|
|
2018-01-30 00:15:53 +02:00
|
|
|
* `stream` {stream.Readable}
|
2021-04-27 16:14:39 +02:00
|
|
|
* `interface` {readline.InterfaceConstructor}
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2017-09-14 01:31:37 +02:00
|
|
|
The `readline.emitKeypressEvents()` method causes the given [Readable][]
|
2018-04-29 20:46:41 +03:00
|
|
|
stream to begin emitting `'keypress'` events corresponding to received input.
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2016-05-13 10:54:31 +03:00
|
|
|
Optionally, `interface` specifies a `readline.Interface` instance for which
|
|
|
|
autocompletion is disabled when copy-pasted input is detected.
|
2016-04-02 20:55:17 -04:00
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
If the `stream` is a [TTY][], then it must be in raw mode.
|
|
|
|
|
2018-02-05 21:55:16 -08:00
|
|
|
This is automatically called by any readline instance on its `input` if the
|
|
|
|
`input` is a terminal. Closing the `readline` instance does not stop
|
2016-11-03 11:23:57 -05:00
|
|
|
the `input` from emitting `'keypress'` events.
|
|
|
|
|
2016-05-07 09:53:05 +02:00
|
|
|
```js
|
|
|
|
readline.emitKeypressEvents(process.stdin);
|
2016-05-27 10:59:50 -07:00
|
|
|
if (process.stdin.isTTY)
|
2016-05-07 09:53:05 +02:00
|
|
|
process.stdin.setRawMode(true);
|
|
|
|
```
|
|
|
|
|
2016-05-27 10:59:50 -07:00
|
|
|
## Example: Tiny CLI
|
|
|
|
|
|
|
|
The following example illustrates the use of `readline.Interface` class to
|
|
|
|
implement a small command-line interface:
|
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { createInterface } from 'node:readline';
|
|
|
|
import { exit, stdin, stdout } from 'node:process';
|
|
|
|
const rl = createInterface({
|
|
|
|
input: stdin,
|
|
|
|
output: stdout,
|
|
|
|
prompt: 'OHAI> ',
|
|
|
|
});
|
|
|
|
|
|
|
|
rl.prompt();
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
switch (line.trim()) {
|
|
|
|
case 'hello':
|
|
|
|
console.log('world!');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log(`Say what? I might have heard '${line.trim()}'`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rl.prompt();
|
|
|
|
}).on('close', () => {
|
|
|
|
console.log('Have a great day!');
|
|
|
|
exit(0);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { createInterface } = require('node:readline');
|
|
|
|
const rl = createInterface({
|
2016-06-02 20:31:23 -05:00
|
|
|
input: process.stdin,
|
|
|
|
output: process.stdout,
|
2022-11-17 08:19:12 -05:00
|
|
|
prompt: 'OHAI> ',
|
2016-06-02 20:31:23 -05:00
|
|
|
});
|
2016-05-27 10:59:50 -07:00
|
|
|
|
|
|
|
rl.prompt();
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
2017-04-21 17:38:31 +03:00
|
|
|
switch (line.trim()) {
|
2016-05-27 10:59:50 -07:00
|
|
|
case 'hello':
|
|
|
|
console.log('world!');
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log(`Say what? I might have heard '${line.trim()}'`);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rl.prompt();
|
|
|
|
}).on('close', () => {
|
|
|
|
console.log('Have a great day!');
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
2020-06-14 14:49:34 -07:00
|
|
|
## Example: Read file stream line-by-Line
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2018-10-26 17:53:04 -07:00
|
|
|
A common use case for `readline` is to consume an input file one line at a
|
|
|
|
time. The easiest way to do so is leveraging the [`fs.ReadStream`][] API as
|
2019-06-27 13:49:58 -04:00
|
|
|
well as a `for await...of` loop:
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { createReadStream } from 'node:fs';
|
|
|
|
import { createInterface } from 'node:readline';
|
2018-10-26 17:53:04 -07:00
|
|
|
|
|
|
|
async function processLineByLine() {
|
2024-12-14 16:50:34 -03:00
|
|
|
const fileStream = createReadStream('input.txt');
|
2018-10-26 17:53:04 -07:00
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
const rl = createInterface({
|
|
|
|
input: fileStream,
|
|
|
|
crlfDelay: Infinity,
|
|
|
|
});
|
|
|
|
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
|
|
// ('\r\n') in input.txt as a single line break.
|
|
|
|
|
|
|
|
for await (const line of rl) {
|
|
|
|
// Each line in input.txt will be successively available here as `line`.
|
|
|
|
console.log(`Line from file: ${line}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
processLineByLine();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
|
|
|
const { createReadStream } = require('node:fs');
|
|
|
|
const { createInterface } = require('node:readline');
|
|
|
|
|
|
|
|
async function processLineByLine() {
|
|
|
|
const fileStream = createReadStream('input.txt');
|
|
|
|
|
|
|
|
const rl = createInterface({
|
2018-10-26 17:53:04 -07:00
|
|
|
input: fileStream,
|
2022-11-17 08:19:12 -05:00
|
|
|
crlfDelay: Infinity,
|
2018-10-26 17:53:04 -07:00
|
|
|
});
|
|
|
|
// Note: we use the crlfDelay option to recognize all instances of CR LF
|
|
|
|
// ('\r\n') in input.txt as a single line break.
|
|
|
|
|
|
|
|
for await (const line of rl) {
|
|
|
|
// Each line in input.txt will be successively available here as `line`.
|
|
|
|
console.log(`Line from file: ${line}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
processLineByLine();
|
|
|
|
```
|
|
|
|
|
|
|
|
Alternatively, one could use the [`'line'`][] event:
|
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { createReadStream } from 'node:fs';
|
|
|
|
import { createInterface } from 'node:readline';
|
|
|
|
|
|
|
|
const rl = createInterface({
|
|
|
|
input: createReadStream('sample.txt'),
|
|
|
|
crlfDelay: Infinity,
|
|
|
|
});
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
console.log(`Line from file: ${line}`);
|
|
|
|
});
|
|
|
|
```
|
2016-05-27 10:59:50 -07:00
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```cjs
|
|
|
|
const { createReadStream } = require('node:fs');
|
|
|
|
const { createInterface } = require('node:readline');
|
|
|
|
|
|
|
|
const rl = createInterface({
|
|
|
|
input: createReadStream('sample.txt'),
|
2022-11-17 08:19:12 -05:00
|
|
|
crlfDelay: Infinity,
|
2016-05-27 10:59:50 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
2016-11-16 01:41:14 +02:00
|
|
|
console.log(`Line from file: ${line}`);
|
2016-05-27 10:59:50 -07:00
|
|
|
});
|
|
|
|
```
|
2015-11-27 18:30:32 -05:00
|
|
|
|
2019-06-27 13:49:58 -04:00
|
|
|
Currently, `for await...of` loop can be a bit slower. If `async` / `await`
|
2019-03-06 16:58:53 +02:00
|
|
|
flow and speed are both essential, a mixed approach can be applied:
|
|
|
|
|
2024-12-14 16:50:34 -03:00
|
|
|
```mjs
|
|
|
|
import { once } from 'node:events';
|
|
|
|
import { createReadStream } from 'node:fs';
|
|
|
|
import { createInterface } from 'node:readline';
|
|
|
|
|
|
|
|
(async function processLineByLine() {
|
|
|
|
try {
|
|
|
|
const rl = createInterface({
|
|
|
|
input: createReadStream('big-file.txt'),
|
|
|
|
crlfDelay: Infinity,
|
|
|
|
});
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
// Process the line.
|
|
|
|
});
|
|
|
|
|
|
|
|
await once(rl, 'close');
|
|
|
|
|
|
|
|
console.log('File processed.');
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
```
|
|
|
|
|
|
|
|
```cjs
|
2022-04-20 10:23:41 +02:00
|
|
|
const { once } = require('node:events');
|
|
|
|
const { createReadStream } = require('node:fs');
|
|
|
|
const { createInterface } = require('node:readline');
|
2019-03-06 16:58:53 +02:00
|
|
|
|
|
|
|
(async function processLineByLine() {
|
|
|
|
try {
|
|
|
|
const rl = createInterface({
|
|
|
|
input: createReadStream('big-file.txt'),
|
2022-11-17 08:19:12 -05:00
|
|
|
crlfDelay: Infinity,
|
2019-03-06 16:58:53 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
rl.on('line', (line) => {
|
|
|
|
// Process the line.
|
|
|
|
});
|
|
|
|
|
|
|
|
await once(rl, 'close');
|
|
|
|
|
|
|
|
console.log('File processed.');
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
}
|
|
|
|
})();
|
|
|
|
```
|
|
|
|
|
2020-01-07 07:37:42 -05:00
|
|
|
## TTY keybindings
|
|
|
|
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<th>Keybindings</th>
|
|
|
|
<th>Description</th>
|
|
|
|
<th>Notes</th>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Backspace</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete line left</td>
|
|
|
|
<td>Doesn't work on Linux, Mac and Windows</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Delete</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete line right</td>
|
2020-05-11 23:10:50 +02:00
|
|
|
<td>Doesn't work on Mac</td>
|
2020-01-07 07:37:42 -05:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>C</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Emit <code>SIGINT</code> or close the readline instance</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>H</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete left</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>D</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete right or close the readline instance in case the current line is empty / EOF</td>
|
|
|
|
<td>Doesn't work on Windows</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>U</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete from the current position to the line start</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>K</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete from the current position to the end of line</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2022-01-22 13:42:48 +08:00
|
|
|
<tr>
|
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Y</kbd></td>
|
|
|
|
<td>Yank (Recall) the previously deleted text</td>
|
|
|
|
<td>Only works with text deleted by <kbd>Ctrl</kbd>+<kbd>U</kbd> or <kbd>Ctrl</kbd>+<kbd>K</kbd></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><kbd>Meta</kbd>+<kbd>Y</kbd></td>
|
2023-08-09 03:51:43 +08:00
|
|
|
<td>Cycle among previously deleted texts</td>
|
|
|
|
<td>Only available when the last keystroke is <kbd>Ctrl</kbd>+<kbd>Y</kbd> or <kbd>Meta</kbd>+<kbd>Y</kbd></td>
|
2022-01-22 13:42:48 +08:00
|
|
|
</tr>
|
2020-01-07 07:37:42 -05:00
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>A</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Go to start of line</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>E</kbd></td>
|
2022-03-02 23:55:53 +09:00
|
|
|
<td>Go to end of line</td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>B</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Back one character</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>F</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Forward one character</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>L</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Clear screen</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>N</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Next history item</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>P</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Previous history item</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
2022-01-21 18:24:06 +08:00
|
|
|
<tr>
|
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>-</kbd></td>
|
|
|
|
<td>Undo previous change</td>
|
2022-02-08 01:40:05 +08:00
|
|
|
<td>Any keystroke that emits key code <code>0x1F</code> will do this action.
|
|
|
|
In many terminals, for example <code>xterm</code>,
|
|
|
|
this is bound to <kbd>Ctrl</kbd>+<kbd>-</kbd>.</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>6</kbd></td>
|
|
|
|
<td>Redo previous change</td>
|
|
|
|
<td>Many terminals don't have a default redo keystroke.
|
|
|
|
We choose key code <code>0x1E</code> to perform redo.
|
|
|
|
In <code>xterm</code>, it is bound to <kbd>Ctrl</kbd>+<kbd>6</kbd>
|
|
|
|
by default.</td>
|
2022-01-21 18:24:06 +08:00
|
|
|
</tr>
|
2020-01-07 07:37:42 -05:00
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Z</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Moves running process into background. Type
|
2020-10-18 06:52:55 -07:00
|
|
|
<code>fg</code> and press <kbd>Enter</kbd>
|
2020-01-07 07:37:42 -05:00
|
|
|
to return.</td>
|
|
|
|
<td>Doesn't work on Windows</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>W</kbd> or <kbd>Ctrl</kbd>
|
|
|
|
+<kbd>Backspace</kbd></td>
|
2020-09-17 11:58:30 -07:00
|
|
|
<td>Delete backward to a word boundary</td>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Backspace</kbd> Doesn't
|
2020-05-11 23:10:50 +02:00
|
|
|
work on Linux, Mac and Windows</td>
|
2020-01-07 07:37:42 -05:00
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Delete</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete forward to a word boundary</td>
|
|
|
|
<td>Doesn't work on Mac</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Left arrow</kbd> or
|
|
|
|
<kbd>Meta</kbd>+<kbd>B</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Word left</td>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Left arrow</kbd> Doesn't work
|
2020-01-07 07:37:42 -05:00
|
|
|
on Mac</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Right arrow</kbd> or
|
|
|
|
<kbd>Meta</kbd>+<kbd>F</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Word right</td>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Ctrl</kbd>+<kbd>Right arrow</kbd> Doesn't work
|
2020-01-07 07:37:42 -05:00
|
|
|
on Mac</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Meta</kbd>+<kbd>D</kbd> or <kbd>Meta</kbd>
|
|
|
|
+<kbd>Delete</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete word right</td>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Meta</kbd>+<kbd>Delete</kbd> Doesn't work
|
2020-01-07 07:37:42 -05:00
|
|
|
on windows</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-10-18 06:52:55 -07:00
|
|
|
<td><kbd>Meta</kbd>+<kbd>Backspace</kbd></td>
|
2020-01-07 07:37:42 -05:00
|
|
|
<td>Delete word left</td>
|
|
|
|
<td>Doesn't work on Mac</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
2022-01-22 19:21:17 -08:00
|
|
|
[EOF character]: https://en.wikipedia.org/wiki/End-of-file#EOF_character
|
2021-07-04 20:39:17 -07:00
|
|
|
[Readable]: stream.md#readable-streams
|
2020-09-17 18:53:37 +02:00
|
|
|
[TTY]: tty.md
|
2021-07-04 20:39:17 -07:00
|
|
|
[TTY keybindings]: #tty-keybindings
|
|
|
|
[Writable]: stream.md#writable-streams
|
|
|
|
[`'SIGCONT'`]: #event-sigcont
|
|
|
|
[`'SIGTSTP'`]: #event-sigtstp
|
|
|
|
[`'line'`]: #event-line
|
|
|
|
[`fs.ReadStream`]: fs.md#class-fsreadstream
|
|
|
|
[`process.stdin`]: process.md#processstdin
|
|
|
|
[`process.stdout`]: process.md#processstdout
|
|
|
|
[`rl.close()`]: #rlclose
|
|
|
|
[reading files]: #example-read-file-stream-line-by-line
|