buffered-reader
Fully configurable buffered reader.
Last updated 12 years ago by Gagle .
MIT · Repository · Original npm · Tarball · package.json
$ npm install buffered-reader 
SYNC missed versions from official npm registry.

Node BufferedReader

Fully configurable buffered reader for node.js

Show me! | Availability | Compatibility | Documentation

Version: 0.2.7

When you need to read a file you typically read a chunk of bytes called "buffer" to avoid multiple calls to the underlying I/O layer, so instead of reading directly from the disk, you read from the previous filled buffer. Doing this you win performance.

This library allows you to read files using internal buffers, so you don't have to worry about them. In addition, you can read a text file line by line.

Show me!

var BufferedReader = require ("buffered-reader");

var offset;

new BufferedReader ("file", { encoding: "utf8" })
	.on ("error", function (error){
		console.log (error);
	})
	.on ("line", function (line, byteOffset){
		if (line === "Phasellus ultrices ligula sed odio ultricies egestas."){
			offset = byteOffset;
			this.interrupt ();
		}
	})
	.on ("end", function (){
		this.seek (offset, function (error){
			if (error) return console.log (error);
			
			this.readBytes (9, function (error, bytes, bytesRead){
				if (error) return console.log (error);
				
				console.log (bytes.toString ());
				
				this.close (function (error){
					if (error) console.log (error);
				});
			});
		});
	})
	.read ();

Availability

Via npm:

npm install buffered-reader

Compatibility

✔ Node *


Documentation

Reference
Examples
Change Log
MIT License

Current Tags

  • 1.0.1                                ...           latest (12 years ago)

18 Versions

  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
  • 0.2.7                                ...           12 years ago
  • 0.2.6                                ...           12 years ago
  • 0.2.5                                ...           12 years ago
  • 0.2.4                                ...           12 years ago
  • 0.2.3                                ...           12 years ago
  • 0.2.2                                ...           13 years ago
  • 0.2.1                                ...           13 years ago
  • 0.2.0                                ...           13 years ago
  • 0.1.2                                ...           13 years ago
  • 0.1.1                                ...           13 years ago
  • 0.1.0                                ...           13 years ago
  • 0.0.6                                ...           13 years ago
  • 0.0.5                                ...           13 years ago
  • 0.0.4                                ...           13 years ago
  • 0.0.3                                ...           13 years ago
  • 0.0.2                                ...           13 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE