$ npm install buffered-reader
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.
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 ();
Via npm:
npm install buffered-reader
✔ Node *
Reference
Examples
Change Log
MIT License
© 2010 - cnpmjs.org x YWFE | Home | YWFE