minipass-split
Splits a minipass
text stream into a line stream.
The equivalent of a line-splitting Transform
stream, similar to split2
, but based on minipass
.
It is intentionally NOT API-compatible with split
or split2
.
Installation
npm install --save minipass minipass-split
Usage
const fsm = const SplitStream = const readStream = 'input.txt'const splitSteam = const writeStream = 'output.txt' // Read a file, break it into chunks by line, write those chunks to a new file//// NOTE: In this example, the new file will NOT contain:// - any of the line breaks!// - any lines that are empty without their line breaksreadStream
Options
An options
argument may be passed into the constructor.
Valid options include:
separator
Optional. (String
or RegExp
): The pattern describing where each split should occur, identical to the separator
parameter of String.prototype.split
. Defaults to /\r?\n/
.
// Split on every ';' character separator: ';' // Split on every 'BREAK' string separator: 'BREAK' // Split on every ';' character, optionally followed by whitespace separator: /,\s*/
License
MIT License (c) 2020 James M. Greene