Skip to content
Open
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b652daf
test: add reproduction test for JSONL with unicode separators
FrancescoCastaldi Oct 3, 2026
51f5b12
test: add test asserting default unicode separator handling
FrancescoCastaldi Oct 3, 2026
c681ecc
test: add test for crlf and isolated cr when unicode separators are d…
FrancescoCastaldi Oct 3, 2026
06cd9ea
test: add type validation tests for unicodeLineSeparators option
FrancescoCastaldi Oct 3, 2026
5812c96
test: add readline promises interface test with unicodeLineSeparators
FrancescoCastaldi Oct 3, 2026
3ce6ca1
test: add async iterator test with unicodeLineSeparators
FrancescoCastaldi Oct 3, 2026
0603e60
readline: import validateBoolean from internal/validators
FrancescoCastaldi Oct 3, 2026
00a0cbf
readline: declare kLineEnding private symbol
FrancescoCastaldi Oct 3, 2026
4cc59b8
readline: define unicode and non-unicode line ending patterns
FrancescoCastaldi Oct 3, 2026
8d0c9e6
readline: parse unicodeLineSeparators option in InterfaceConstructor
FrancescoCastaldi Oct 3, 2026
85ebf1e
readline: validate boolean type for unicodeLineSeparators option
FrancescoCastaldi Oct 3, 2026
d6fa926
readline: expose unicodeLineSeparators property on Interface instance
FrancescoCastaldi Oct 3, 2026
6ddf841
readline: attach active line ending pattern to instance kLineEnding
FrancescoCastaldi Oct 3, 2026
9b060ce
readline: gate unicode character check in onStreamData
FrancescoCastaldi Oct 3, 2026
5e986cc
readline: use instance kLineEnding in onStreamData regex splitting
FrancescoCastaldi Oct 3, 2026
0d756c7
readline: update _ttyWrite to use instance line ending pattern
FrancescoCastaldi Oct 3, 2026
a951173
test: add test for ttyWrite line splitting with unicode separators
FrancescoCastaldi Oct 3, 2026
2460294
benchmark: add benchmark for readline stream data line splitting
FrancescoCastaldi Oct 3, 2026
99defbd
doc: document unicodeLineSeparators in readline.createInterface
FrancescoCastaldi Oct 3, 2026
d5483ab
doc: document unicodeLineSeparators in readlinePromises.createInterface
FrancescoCastaldi Oct 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
readline: update _ttyWrite to use instance line ending pattern
Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
  • Loading branch information
FrancescoCastaldi committed Oct 3, 2026
commit 0d756c77f5c461000ab1426d7df8885946bd617a
9 changes: 4 additions & 5 deletions lib/internal/readline/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const kMincrlfDelay = 100;
*/
const lineEndingWithUnicode = /\r?\n|\r(?!\n)|\u2028|\u2029/g;
const lineEndingWithoutUnicode = /\r?\n|\r(?!\n)/g;
const lineEnding = lineEndingWithUnicode;

const kLineObjectStream = Symbol('line object stream');
const kQuestionCancel = Symbol('kQuestionCancel');
Expand Down Expand Up @@ -1572,16 +1571,16 @@ class Interface extends InterfaceConstructor {
default:
if (typeof s === 'string' && s) {
// Erase state of previous searches.
lineEnding.lastIndex = 0;
this[kLineEnding].lastIndex = 0;
let nextMatch;
// Keep track of the end of the last match.
let lastIndex = 0;
while ((nextMatch = RegExpPrototypeExec(lineEnding, s)) !== null) {
while ((nextMatch = RegExpPrototypeExec(this[kLineEnding], s)) !== null) {
this[kInsertString](StringPrototypeSlice(s, lastIndex, nextMatch.index));
({ lastIndex } = lineEnding);
({ lastIndex } = this[kLineEnding]);
this[kLine]();
// Restore lastIndex as the call to kLine could have mutated it.
lineEnding.lastIndex = lastIndex;
this[kLineEnding].lastIndex = lastIndex;
}
// This ensures that the last line is written if it doesn't end in a newline.
// Note that the last line may be the first line, in which case this still works.
Expand Down