Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (18 sloc) 816 Bytes
Hackneyed Example:
var sys = require('sys');
var Buffer = require('buffer').Buffer;
var BufferList = require('bufferlist').BufferList;
var buf1 = new Buffer(5); buf1.write('abcde');
var buf2 = new Buffer(3); buf2.write('xyz');
var buf3 = new Buffer(5); buf3.write('11358');
var b = new BufferList;
b.push(buf1,buf2,buf3);
sys.puts(b.take(10)); // abcdexyz11
sys.puts(b.take(3)); // abc
sys.puts(b.take(100)); // abcdexyz11358
Buffer objects don't need to be buffer objects necessarily, but they should
implement methods that act like Buffer's toString, length, and copy.
To use a different kind of buffer object, set the constructor property:
var b = new BufferList({ construct : Bluffer });
var b = new BufferList;
b.construct = Buffur;
Something went wrong with that request. Please try again.