https://github.com/nisaacson/linerstream
Split a readable stream by newline characters
https://github.com/nisaacson/linerstream
Last synced: 3 months ago
JSON representation
Split a readable stream by newline characters
- Host: GitHub
- URL: https://github.com/nisaacson/linerstream
- Owner: nisaacson
- Created: 2014-01-07T20:14:02.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T16:51:45.000Z (over 8 years ago)
- Last Synced: 2025-04-12T18:05:29.918Z (3 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 5
- Watchers: 2
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# linerstream
Split a readable stream by newline characters
[](https://nodei.co/npm/linerstream/)
[](https://travis-ci.org/nisaacson/linerstream)
[](https://david-dm.org/nisaacson/linerstream)
[](https://codeclimate.com/github/nisaacson/linerstream)# Installation
```bash
npm install -S linerstream
```# Usage
Create an instance of linestream and pipe a readable stream into that instance
```javascript
var Linerstream = require('linerstream')
// splitter is an instance of require('stream').Transform
var opts = {
highWaterMark: 2
}
var splitter = new Linerstream(opts) // opts is optionalvar readStream = fs.createReadStream('/file/with/line/breaks.txt')
var lineByLineStream = readStream.pipe(splitter)
lineByLineStream.on('data', function(chunk) {
console.dir(chunk) // no line breaks here :)
})
```## Override EOL
If you don't want to use the OS default `EOL` character, you can ovverride it when creating the stream
```
var stream2 = new LinerStream({EOL: '\n'})
//force windows EOL
var stream3 = new LinerStream({EOL: '\r\n'})
```