Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bufferlist

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferlist

Create linked lists of Buffer objects

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
385
decreased by-36.68%
Maintainers
0
Weekly downloads
 
Created
Source

BufferList

BufferList provides an interface to treat a linked list of buffers as a single stream. This is useful for events that produce a many small Buffers, such as network streams.

Installation

Install using npm: npm install bufferlist

Or, check out the repository and have npm link to your development copy. This is useful for developing the library, and is necessary when running the tests, since they refer to the installed names of the library files. git clone http://github.com/substack/node-bufferlist.git cd node-bufferlist npm link .

Simple Bufferlist Example

#!/usr/bin/env node
var sys = require('sys');
var Buffer = require('buffer').Buffer;
var BufferList = require('bufferlist').BufferList;

var b = new BufferList;
['abcde','xyz','11358'].forEach(function (s) {
    var buf = new Buffer(s.length);
    buf.write(s);
    b.push(buf);
});

sys.puts(b.take(10)); // abcdexyz11

Binary

This distribution also contains a Binary module for parsing these bufferlists.

Simple Binary Example

#!/usr/bin/env node

var sys = require('sys');
var Buffer = require('buffer').Buffer;
var BufferList = require('bufferlist').BufferList;
var Binary = require('bufferlist/binary').Binary;

var bufferList = new BufferList;
var binary = Binary(bufferList)
    .getWord16be('xLen')
    .getBuffer('xs', 'xLen')
    .tap(function (vars) {
        vars.moo = 'xs:' + vars.xLen + ':' + vars.xs;
    })
    .end()
;

var buf = new Buffer(6);
buf.write('\x00\x04meow', 'binary');
bufferList.push(buf);

sys.puts(binary.vars.moo); // xs:4:meow

See Also

See the examples/ directory for more involved examples.

See http://github.com/substack/node-rfb for a practical application of this distribution.

FAQs

Package last updated on 17 Apr 2011

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc