You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
385 B
26 lines
385 B
3 years ago
|
|
||
|
module.exports = BufferList;
|
||
|
function BufferList() {
|
||
|
this.bufs = [];
|
||
|
this.size = 0;
|
||
|
}
|
||
|
|
||
|
BufferList.prototype.shift = function shift() {
|
||
|
var buf = this.bufs.shift();
|
||
|
|
||
|
if (buf) {
|
||
|
this.size -= buf.length;
|
||
|
}
|
||
|
|
||
|
return buf;
|
||
|
};
|
||
|
|
||
|
BufferList.prototype.push = function push(buf) {
|
||
|
if (!buf || !buf.length) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
this.bufs.push(buf);
|
||
|
this.size += buf.length;
|
||
|
};
|