split-stream-lines-preserve-eol-pmb
v0.1.1
Published
Split a stream into lines that include their line terminator if they had one.
Downloads
1,336
Maintainers
Readme
split-stream-lines-preserve-eol-pmb
Split a stream into lines that include their line terminator if they had one.
API
This module exports one function:
makeLineSplitter(opt)
Returns a duplex stream that splits the input by lines.
opt
is an optional options object that supports these keys:
sep
: RegExp for what you consider a line terminator. Default:/(\n)/
nEolGroups
: The number of match groups insep
. Default:1
discardRemainder
: Boolean, whether to silently discard the last line if it was not properly terminated. Default:false
These experimental options are planned but do not work reliably yet:
throughOpt
: Options to pass through tothrough2
. Default: empty object.obj
: A shortcut for enablingobjectMode
inthroughOpt
. Boolean. Default:false
combine
: A function that merges the line with the match group(s) of its terminator. It will be called with one argument, a flat array of all these parts. Can also befalse
to pass on said array, auto-enabling theobj
option. Defaults to a function that can concat either buffers and strings.
Known issues
- Needs more/better tests and docs.
License
ISC