Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
T-PWK committed Nov 15, 2014
1 parent a75970c commit b336232
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@

================
[![Build Status](https://travis-ci.org/T-PWK/node-line-reader.svg)](https://travis-ci.org/T-PWK/node-line-reader) [![Code Climate](https://codeclimate.com/github/T-PWK/node-line-reader/badges/gpa.svg)](https://codeclimate.com/github/T-PWK/node-line-reader) [![Test Coverage](https://codeclimate.com/github/T-PWK/node-line-reader/badges/coverage.svg)](https://codeclimate.com/github/T-PWK/node-line-reader)

## Node Line Reader

Node Line Reader is a [Node.js](http://nodejs.org/) module that helps you reading lines of text from files.

Features:
- Reads lines of text from Readable streams e.g. files
- Reads lines that match one or more patterns
- Skips lines that match one or more patterns e.g. empty lines
- Reads part of files

Installation:
```
npm install TBD?
npm install node-line-reader
```

### Usage:
Using LineTransform
##### Using `LineReader`

```javascript
var fs = require('fs');
var join = require('path').join;
var path = require('path');
var reader = new LineReader(path.join('/home/user', 'some-file.txt'));
reader.nextLine(function (err, line) {
if (!err) {
console.log('file line: ', line);
}
});
```

##### Using `LineTransform`

var stream = fs.createReadStream(join(__dirname, 'input.txt')); // Create read stream
var LineTransform = require('???').LineTransform;
```javascript
var stream = getSomeReadableStream(); // Create read stream
var LineTransform = require('node-line-reader').LineTransform; // LineTransform constructor
var transform = new LineTransform();

stream.pipe(transform); // Pipe input from a file stream over to line transform
Expand All @@ -35,6 +48,7 @@ transform.on('end', function(line) {
### API:

#### Class: LineTransform
`LineTransform` is a duplex stream converting input text into lines of text. `LineTransform` instance can be piped into antoher [Writable](http://nodejs.org/api/stream.html#stream_class_stream_writable) instance.

##### Event: 'readable'
When a line of text can be read from the transform, it will emit a 'readable' event.
Expand Down

0 comments on commit b336232

Please sign in to comment.