New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

buffer-group

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buffer-group

Group Node.js Buffers together and extract the parts you need.

0.0.2
latest
npm
Version published
Maintainers
1
Created
Source

buffer-group

Build Status

Group Node.js Buffers together and extract the parts you need. This is useful, for example, when dealing with framing data and the frame size isn't known in advance.

Example

Get access to the BufferGroup:

var BufferGroup = require('buffer-group'),
    bg = new BufferGroup();

Add buffers to the group:

bg.push(new Buffer(10));    // bg.length === 10
bg.push(new Buffer(5));     // bg.length === 15

As you add Buffers to the group, the BufferGroup length grows accordingly to account for all the buffers in it.

You can then extract a fixed size of data from the group:

var eb = bg.extract(12); // Extract 12 bytes from the BufferGroup.
// eb.length === 12
// bg.length === 3

Note that the BufferGroup will remove the number of bytes requested and keep any existing data there. You can then go ahead and push more data in or extract more data as you see fit. The length property should reflect the current size.

Install

npm install buffer-group

Tests

npm test

License

MIT License

Keywords

group

FAQs

Package last updated on 28 Aug 2013

Did you know?

Socket

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.

Install

Related posts