Sha256: edd8c3f695fe75d563da3353d3f1afe1c0a33b8492d278bf3f4bd35873acea66

Contents?: true

Size: 1.42 KB

Versions: 28

Compression:

Stored size: 1.42 KB

Contents

'use strict';

var Buffer = require('buffer').Buffer;
/*<replacement>*/
var bufferShim = require('buffer-shims');
/*</replacement>*/

module.exports = BufferList;

function BufferList() {
  this.head = null;
  this.tail = null;
  this.length = 0;
}

BufferList.prototype.push = function (v) {
  var entry = { data: v, next: null };
  if (this.length > 0) this.tail.next = entry;else this.head = entry;
  this.tail = entry;
  ++this.length;
};

BufferList.prototype.unshift = function (v) {
  var entry = { data: v, next: this.head };
  if (this.length === 0) this.tail = entry;
  this.head = entry;
  ++this.length;
};

BufferList.prototype.shift = function () {
  if (this.length === 0) return;
  var ret = this.head.data;
  if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
  --this.length;
  return ret;
};

BufferList.prototype.clear = function () {
  this.head = this.tail = null;
  this.length = 0;
};

BufferList.prototype.join = function (s) {
  if (this.length === 0) return '';
  var p = this.head;
  var ret = '' + p.data;
  while (p = p.next) {
    ret += s + p.data;
  }return ret;
};

BufferList.prototype.concat = function (n) {
  if (this.length === 0) return bufferShim.alloc(0);
  if (this.length === 1) return this.head.data;
  var ret = bufferShim.allocUnsafe(n >>> 0);
  var p = this.head;
  var i = 0;
  while (p) {
    p.data.copy(ret, i);
    i += p.data.length;
    p = p.next;
  }
  return ret;
};

Version data entries

28 entries across 21 versions & 5 rubygems

Version Path
affiliator-0.2.1 node_modules/fsevents/node_modules/readable-stream/lib/internal/streams/BufferList.js
guard-sass-lint-0.1.2 node_modules/readable-stream/lib/internal/streams/BufferList.js
guard-sass-lint-0.1.1 node_modules/readable-stream/lib/internal/streams/BufferList.js
lanes-0.8.0 node_modules/tar-pack/node_modules/readable-stream/lib/internal/streams/BufferList.js
lanes-0.8.0 node_modules/fsevents/node_modules/readable-stream/lib/internal/streams/BufferList.js
lanes-0.8.0 node_modules/fsevents/node_modules/tar-pack/node_modules/readable-stream/lib/internal/streams/BufferList.js
lanes-0.8.0 node_modules/readable-stream/lib/internal/streams/BufferList.js
node-compiler-0.9.1 vendor/node/deps/npm/node_modules/readable-stream/lib/internal/streams/BufferList.js
node-compiler-0.9.0 vendor/node-v7.2.1/deps/npm/node_modules/readable-stream/lib/internal/streams/BufferList.js
node-compiler-0.8.0 vendor/node-v7.2.0/deps/npm/node_modules/readable-stream/lib/internal/streams/BufferList.js
node-compiler-0.7.0 vendor/node-v7.1.0/deps/npm/node_modules/readable-stream/lib/internal/streams/BufferList.js
node-compiler-0.7.0 vendor/node-v6.9.1/deps/npm/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.10 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.9 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.8 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.7 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.6 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.5 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.4 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js
tck-lambdas-0.3.3 lib/tck/lambdas/chistacojs/source/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/lib/internal/streams/BufferList.js