Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A module to read / write binary data and streams.
npm install buffy
Let's say you want to parse a simple C struct, buffy can help:
var buffy = require('buffy');
var buffer = new Buffer([23, 0, 0, 0, 15, 116, 101, 115, 116]);
var reader = buffy.createReader(buffer);
var record = {
version : reader.uint8(),
id : reader.uint32(),
name : reader.ascii(4),
};
// {version: 23, id: 15, name: 'test'}
Parsing a buffer is nice, but what about streams? Well, buffy has your back:
var buffy = require('buffy');
var net = require('net');
var connection = net.createConnection(1337, 'example.org');
var reader = buffy.createReader();
connection.pipe(reader);
reader.on('data', function() {
while (reader.bytesAhead() >= 9) {
var record = {
version : reader.uint8(),
id : reader.uint32(),
name : reader.ascii(4),
};
}
});
Future version may also support a declarative syntax for defining structs and their sequences.
Creates a reader with an optional buffer or options hash.
When using the options hash, you can still supply a buffer with key buffer
.
buffer
start with the supplied bufferoffset
start reading at the specified offset of the buffercompact
if true, the internal buffer will be garbage collected on
every write operation. See also: method compact()Appends the given buffer
to the internal buffer. Whenever possible, existing
space inside the internal buffer will be reused, otherwise a new / bigger buffer
will be created.
Returns the number of unread bytes available to the reader.
Returns the number of bytes that are buffered by the Reader internally.
Returns the next (un)signed 8 bit integer.
Returns the next (un)signed 16 bit integer in the chosen endianness.
Returns the next (un)signed 32 bit integer in the chosen endianness.
Returns the next 32 bit float in the chosen endianness.
Returns the next 64 bit double in the chosen endianness.
Returns the next bytes
as a string of the chosen encoding. If bytes
is
omitted, a null terminated string is assumed.
Returns the next bytes
as a buffer.
Skips bytes
bytes of the buffer.
Force a compaction of the internal buffer to the minimum size needed, discarding data already read.
The Writer has not been implemented yet.
The reader will throw an exception whenever an operation exceeds the boundary of the internal buffer.
FAQs
A module to read / write binary data and streams.
The npm package buffy receives a total of 20 weekly downloads. As such, buffy popularity was classified as not popular.
We found that buffy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.