on-new-line
Version:
Hijacks NodeJS Stream and emits events when newline(s) written to the output.
43 lines (24 loc) • 1 kB
Markdown
> Hijacks NodeJS Stream and emits events when newline(s) written to the output.
[](https://github.com/bubkoo/on-new-line/blob/master/LICENSE)
[](https://www.npmjs.com/packages/on-new-line)
## Install
```
$ npm install on-new-line --save
```
## Usage
```js
require('on-new-line')(stream); // Any type of NodeJS stream, such as: filestream, process.stdout etc.
// emitted on every newline detected
stream.on('newline', function() {
});
// emitted before data written to the output.
stream.on('before:newlines', function(lineCount) {
});
// emitted after data written to the output.
stream.on('after:newlines', function(lineCount) {
});
```
Pull requests and stars are highly welcome.
For bugs and feature requests, please [create an issue](https://github.com/bubkoo/on-new-line/issues/new).