Skip to content

Commit 75639ed

Browse files
committed
support Unicode line boundaries
1 parent 5652e7f commit 75639ed

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- node v0.10 `streams2` (transform stream)
88
- supports `pipe`
99
- supports both UNIX and Windows line endings
10+
- supports [Unicode UTS #18 line boundaries](http://www.unicode.org/reports/tr18/#Line_Boundaries)
1011
- can wrap any readable stream
1112
- can be used as a readable-writable "through-stream" (transform stream)
1213
- super-simple: `stream = byline(stream);`

lib/byline.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ LineStream.prototype._transform = function(chunk, encoding, done) {
9999
}
100100
this._chunkEncoding = encoding;
101101

102-
var lines = chunk.split(/\r\n|\r|\n/g);
102+
// see: http://www.unicode.org/reports/tr18/#Line_Boundaries
103+
var lines = chunk.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/g);
103104

104105
// don't split CRLF which spans chunks
105106
if (this._lastChunkEndedWithCR && chunk[0] == '\n') {

0 commit comments

Comments
 (0)