Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
buffered-reader
Advanced tools
Node.js project
Show me! | Availability | Compatibility | Documentation
Version: 1.0.1
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 without worry about the buffers. There are two ways to read the files. The first can only read binary data and has a pointer to move along the file (seek, skip, read). The second performs a read from the beginning to the end of the file and emits different events (byte, character, line, buffer...).
var reader = require ("buffered-reader");
var BinaryReader = reader.BinaryReader;
var DataReader = reader.DataReader;
var close = function (binaryReader, error){
if (error) console.log (error);
binaryReader.close (function (error){
if (error) console.log (error);
});
};
var file = "file";
var offset;
new DataReader (file, { encoding: "utf8" })
.on ("error", function (error){
console.log (error);
})
.on ("line", function (line, nextByteOffset){
if (line === "Phasellus ultrices ligula sed odio ultricies egestas."){
offset = nextByteOffset;
this.interrupt ();
}
})
.on ("end", function (){
new BinaryReader (file)
.seek (offset, function (error){
if (error) return close (this, error);
this.read (9, function (error, bytes, bytesRead){
if (error) return close (this, error);
console.log (bytes.toString ()); //Prints: Curabitur
close (this);
});
});
})
.read ();
file:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Morbi convallis nibh massa, eu varius felis.
Phasellus ultrices ligula sed odio ultricies egestas.
Curabitur pretium magna in diam accumsan dignissim.
Phasellus et tortor eu orci suscipit vehicula.
Phasellus pulvinar mauris in purus consequat vel congue orci hendrerit.
Pellentesque eget arcu magna, suscipit imperdiet eros.
Via npm:
npm install buffered-reader
✔ Node *
FAQs
Binary and event-based data buffered readers.
The npm package buffered-reader receives a total of 76 weekly downloads. As such, buffered-reader popularity was classified as not popular.
We found that buffered-reader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.