Skip to content

Commit 497bfff

Browse files
vsemozhetbytMylesBorins
authored andcommitted
doc: clarify using crlfDelay with fs streams
PR-URL: #16259 Fixes: #16077 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
1 parent 7bf9878 commit 497bfff

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

doc/api/readline.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,8 @@ changes:
379379
end-of-line input. Default to `100` milliseconds.
380380
`crlfDelay` will be coerced to a number no less than `100`. It can be set to
381381
`Infinity`, in which case `\r` followed by `\n` will always be considered a
382-
single newline.
382+
single newline (which may be reasonable for [reading files][] with `\r\n`
383+
line delimiter).
383384
* `removeHistoryDuplicates` {boolean} If `true`, when a new input line added
384385
to the history list duplicates an older one, this removes the older line
385386
from the list. Defaults to `false`.
@@ -532,7 +533,8 @@ const readline = require('readline');
532533
const fs = require('fs');
533534

534535
const rl = readline.createInterface({
535-
input: fs.createReadStream('sample.txt')
536+
input: fs.createReadStream('sample.txt'),
537+
crlfDelay: Infinity
536538
});
537539

538540
rl.on('line', (line) => {
@@ -547,3 +549,4 @@ rl.on('line', (line) => {
547549
[Readable]: stream.html#stream_readable_streams
548550
[TTY]: tty.html
549551
[Writable]: stream.html#stream_writable_streams
552+
[reading files]: #readline_example_read_file_stream_line_by_line

0 commit comments

Comments
 (0)