Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisaacson/linerstream
Split a readable stream by newline characters
https://github.com/nisaacson/linerstream
Last synced: about 1 month 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 (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T16:51:45.000Z (over 7 years ago)
- Last Synced: 2024-10-03T20:01:10.893Z (about 1 month ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 5
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# linerstream
Split a readable stream by newline characters
[![NPM](https://nodei.co/npm/linerstream.png)](https://nodei.co/npm/linerstream/)
[![Build Status](https://travis-ci.org/nisaacson/linerstream.png)](https://travis-ci.org/nisaacson/linerstream)
[![Dependency Status](https://david-dm.org/nisaacson/linerstream/status.png)](https://david-dm.org/nisaacson/linerstream)
[![Code Climate](https://codeclimate.com/github/nisaacson/linerstream.png)](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'})
```