3 var Buffer = require('buffer').Buffer;
5 var bufferShim = require('buffer-shims');
8 module.exports = BufferList;
10 function BufferList() {
16 BufferList.prototype.push = function (v) {
17 var entry = { data: v, next: null };
18 if (this.length > 0) this.tail.next = entry;else this.head = entry;
23 BufferList.prototype.unshift = function (v) {
24 var entry = { data: v, next: this.head };
25 if (this.length === 0) this.tail = entry;
30 BufferList.prototype.shift = function () {
31 if (this.length === 0) return;
32 var ret = this.head.data;
33 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
38 BufferList.prototype.clear = function () {
39 this.head = this.tail = null;
43 BufferList.prototype.join = function (s) {
44 if (this.length === 0) return '';
46 var ret = '' + p.data;
52 BufferList.prototype.concat = function (n) {
53 if (this.length === 0) return bufferShim.alloc(0);
54 if (this.length === 1) return this.head.data;
55 var ret = bufferShim.allocUnsafe(n >>> 0);