Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haraldrudell/linewise
Splits a stream line-by-line with moderation of the input. By Harald Rudell. Replaced by Node.js readline
https://github.com/haraldrudell/linewise
Last synced: 1 day ago
JSON representation
Splits a stream line-by-line with moderation of the input. By Harald Rudell. Replaced by Node.js readline
- Host: GitHub
- URL: https://github.com/haraldrudell/linewise
- Owner: haraldrudell
- Created: 2012-08-13T11:28:05.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-08-13T11:56:21.000Z (over 12 years ago)
- Last Synced: 2024-10-13T06:29:18.496Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Linewise
The linewise module splits a stream line-by-line with moderation of the input.
## Benefits
* An unlimited amount of text can be processed
* A line or sequence of lines can for example be scanned for patterns
* Suitable for processing logs## Features
* Node stream interface
* Moderation of the input stream limits memory use
* Any read stream can be parsed, likewise output can be sent to any stream# Usage
```js
var linewise = require('linewise')
var fs = require('fs')var inStream = fs.createReadStream('/home/hugefile.log', {encoding:'utf-8'})
var parsedStream = linewise.getPerLineBuffer()
parsedStream.on('data', line)
parsedStream.on('end', end)
parsedStream.on('error', error)
inStream.pipe(parsedStream)
parsedStream.resume()function line(text) {
console.log(text)
}function end() {
console.log('End of file.')
}function error(err) {
throw Error(err)
}
```# TODO
* Make it work for Windowsy Macy systems: '\r\n', '\r'
# Notes
(c) [Harald Rudell](http://www.haraldrudell.com) wrote this for the love of node in August, 2012
No warranty expressed or implied. Use at your own risk.
Please suggest better ways, new features, and possible difficulties on [github](https://github.com/haraldrudell/webfiller)