<commit_before># stream2lines
A node.js module for extracting lines of text from a readable stream.

- Provides an EventEmitter, emitting `'readable'`, `'end'`, `'error'`, and `'close'`
- Each read() returns one entire line or null
- Allows setting limit on line length
- Allows closing/detaching from the source before it's fully consumed
- Allows choice of character set encoding
- Allows choice of end-of-line marker recognition
- Allows auto-destruction of source stream (where applicable)

## Install

```sh
$ npm install stream2lines
```

## Usage
```js
var stream2lines = require('stream2lines');

var rs = getReadableStreamSomehow();
var pattern = /SECRET/i; // We're going to search for a matching line

var reader = stream2lines(rs) // Alternatively: stream2lines(rs, options)
  .once('error', function(err) {
    // Reader automatically closes. Maybe do something with err.
  })
  .on('readable', function() {
    var ln;
    while ((ln = this.read()) != null) {
      if (pattern.test(ln)) this.close() // Input stream can be dismissed early<commit_msg>Added a line to readme<commit_after># stream2lines
A node.js module for extracting lines of text from a readable stream.

- Provides an EventEmitter, emitting `'readable'`, `'end'`, `'error'`, and `'close'`
- Each read() returns one entire line or null
- Allows setting limit on line length
- Allows closing/detaching from the source before it's fully consumed
- Allows choice of character set encoding
- Allows choice of end-of-line marker recognition
- Allows auto-destruction of source stream (where applicable)
- No dependencies

## Install

```sh
$ npm install stream2lines
```

## Usage
```js
var stream2lines = require('stream2lines');

var rs = getReadableStreamSomehow();
var pattern = /SECRET/i; // We're going to search for a matching line

var reader = stream2lines(rs) // Alternatively: stream2lines(rs, options)
  .once('error', function(err) {
    // Reader automatically closes. Maybe do something with err.
  })
  .on('readable', function() {
    var ln;
    while ((ln = this.read()) != null) {
      if (pattern.test(ln)) this.close() // Input stream can be dismissed early
{'fraction_non_alphanumeric': 0.11729253592953176, 'fraction_numerical': 0.005563282336578581, 'mean_word_length': 4.1258907363420425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7261213', 'n_tokens_mistral': 644, 'n_tokens_neox': 613, 'n_words': 249}