New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bufferstream

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferstream - npm Package Compare versions

Comparing version 0.5.1 to 0.5.2

..travis.yml.un~

145

lib/buffer-stream.js
(function() {
var BufferStream, Stream, fn, isArray, isBuffer, split, _ref;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }, __slice = Array.prototype.slice;
var BufferStream, Stream, fn, isArray, isBuffer, split, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__slice = [].slice;

@@ -12,4 +15,6 @@ Stream = require('stream').Stream;

split = function() {
var buflen, can_split, cur, found, i, pos, rest, splitter, _i, _len, _ref2, _ref3, _results;
if (!this.buffer.length) return;
var buflen, can_split, cur, found, i, pos, rest, splitter, _i, _len, _ref1, _ref2, _results;
if (!this.buffer.length) {
return;
}
can_split = this.enabled && this.splitters.length;

@@ -20,6 +25,8 @@ _results = [];

pos = buflen = this.buffer.length;
_ref2 = this.splitters;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
splitter = _ref2[_i];
if (buflen < splitter.length) continue;
_ref1 = this.splitters;
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
splitter = _ref1[_i];
if (buflen < splitter.length) {
continue;
}
i = fn.indexOf.call(this.buffer, splitter);

@@ -32,4 +39,6 @@ if (i !== -1 && i < pos && i < buflen) {

can_split = cur !== null;
if (!can_split) break;
_ref3 = fn.split(this.buffer, pos, cur.length), found = _ref3[0], rest = _ref3[1];
if (!can_split) {
break;
}
_ref2 = fn.split(this.buffer, pos, cur.length), found = _ref2[0], rest = _ref2[1];
this.buffer = rest;

@@ -46,10 +55,10 @@ this.emit('split', found, cur);

BufferStream = (function() {
BufferStream = (function(_super) {
__extends(BufferStream, _super);
__extends(BufferStream, Stream);
function BufferStream(opts) {
var _ref2, _ref3, _ref4;
var _this = this;
if (opts == null) opts = {};
if (opts == null) {
opts = {};
}
this.reset = __bind(this.reset, this);

@@ -70,5 +79,11 @@ this.clear = __bind(this.clear, this);

}
if ((_ref2 = opts.size) == null) opts.size = 'none';
if ((_ref3 = opts.encoding) == null) opts.encoding = null;
if ((_ref4 = opts.blocking) == null) opts.blocking = true;
if (opts.size == null) {
opts.size = 'none';
}
if (opts.encoding == null) {
opts.encoding = null;
}
if (opts.blocking == null) {
opts.blocking = true;
}
this.size = opts.size;

@@ -97,3 +112,5 @@ this.blocking = opts.blocking;

}
if (opts.disabled) this.disable();
if (opts.disabled) {
this.disable();
}
}

@@ -106,4 +123,4 @@

BufferStream.prototype.toString = function() {
var _ref2;
return (_ref2 = this.buffer).toString.apply(_ref2, arguments);
var _ref1;
return (_ref1 = this.buffer).toString.apply(_ref1, arguments);
};

@@ -117,3 +134,5 @@

this.size = size;
if (!this.paused && this.size === 'none') return this.clear();
if (!this.paused && this.size === 'none') {
return this.clear();
}
};

@@ -128,14 +147,24 @@

args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length === 1 && isArray(args[0])) args = args[0];
if (args.length === 1 && isArray(args[0])) {
args = args[0];
}
for (_i = 0, _len = args.length; _i < _len; _i++) {
splitter = args[_i];
i = this.splitters.indexOf(splitter);
if (i === -1) continue;
if (i === -1) {
continue;
}
this.splitters.splice(i, 1);
if (!this.splitters.length) break;
if (!this.splitters.length) {
break;
}
}
if (!this.splitters.length) this.enabled = false;
if (!this.splitters.length) {
this.enabled = false;
}
if (!args.length) {
this.enabled = false;
if (!this.paused) return this.clear();
if (!this.paused) {
return this.clear();
}
}

@@ -147,3 +176,5 @@ };

args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (args.length === 1 && isArray(args[0])) args = args[0];
if (args.length === 1 && isArray(args[0])) {
args = args[0];
}
if (args.length === 2 && typeof args[1] === 'function') {

@@ -153,3 +184,5 @@ splitter = args[0], callback = args[1];

return this.on('split', function(_, token) {
if (token === splitter) return callback.apply(this, arguments);
if (token === splitter) {
return callback.apply(this, arguments);
}
});

@@ -166,3 +199,5 @@ }

}
if (isBuffer(buffer)) {} else if (typeof buffer === 'string') {
if (isBuffer(buffer)) {
} else if (typeof buffer === 'string') {
buffer = new Buffer(buffer, encoding != null ? encoding : this.encoding);

@@ -177,11 +212,21 @@ } else {

}
if (this.paused) return false;
if (this.paused) {
return false;
}
if (this.size === 'none') {
if (this.enabled) split.call(this);
if (this.enabled) {
split.call(this);
}
return this.clear();
} else if (this.size === 'flexible') {
if (this.enabled) split.call(this);
if (this.finished) return this.clear();
if (this.enabled) {
split.call(this);
}
if (this.finished) {
return this.clear();
}
if (this.blocking) {
if (!this.enabled) this.clear();
if (!this.enabled) {
this.clear();
}
return true;

@@ -201,3 +246,5 @@ } else {

var buffer;
if (!this.buffer.length) return true;
if (!this.buffer.length) {
return true;
}
buffer = this.buffer;

@@ -218,3 +265,5 @@ this.reset();

BufferStream.prototype.pause = function() {
if (this.paused) return;
if (this.paused) {
return;
}
this.paused = true;

@@ -225,9 +274,15 @@ return this.emit('pause');

BufferStream.prototype.resume = function() {
if (!this.paused) return;
if (!this.paused) {
return;
}
if (!this.enabled || this.size === 'none' || this.finished) {
this.paused = false;
if (!this.clear()) return;
if (!this.clear()) {
return;
}
}
this.emit('drain');
if (this.size === 'none') this.emit('resume');
if (this.size === 'none') {
this.emit('resume');
}
if (this.finished) {

@@ -240,5 +295,9 @@ this.emit('end');

BufferStream.prototype.end = function(data, encoding) {
if (this.finished) return;
if (this.finished) {
return;
}
this.finished = true;
if (data != null) this.write(data, encoding);
if (data != null) {
this.write(data, encoding);
}
this.writable = false;

@@ -253,3 +312,3 @@ if (!this.paused) {

})();
})(Stream);

@@ -256,0 +315,0 @@ BufferStream.fn = fn;

(function() {
var isBuffer, max, min;
var __slice = Array.prototype.slice;
var isBuffer, max, min,
__slice = [].slice;

@@ -11,31 +11,49 @@ isBuffer = Buffer.isBuffer;

exports.concat = function() {
var args, buffer, buffers, i, idx, input, length, pos, result, _i, _len, _len2;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
idx = -1;
length = 0;
buffers = [];
for (i = 0, _len = args.length; i < _len; i++) {
input = args[i];
if (isBuffer(input)) {
if (input.length) idx = i;
length += input.length;
buffers.push(input);
if (Buffer.concat != null) {
exports.concat = (function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return Buffer.concat(args);
});
}
if (exports.concat == null) {
exports.concat = function() {
var args, buffer, buffers, i, idx, input, length, pos, result, _i, _j, _len, _len1;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
idx = -1;
length = 0;
buffers = [];
for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) {
input = args[i];
if (isBuffer(input)) {
if (input.length) {
idx = i;
}
length += input.length;
buffers.push(input);
}
}
}
if (idx !== -1 && length === args[idx].length) return args[idx];
pos = 0;
result = new Buffer(length);
for (_i = 0, _len2 = buffers.length; _i < _len2; _i++) {
buffer = buffers[_i];
if (!buffer.length) continue;
buffer.copy(result, pos);
pos += buffer.length;
}
return result;
};
if (idx !== -1 && length === args[idx].length) {
return args[idx];
}
pos = 0;
result = new Buffer(length);
for (_j = 0, _len1 = buffers.length; _j < _len1; _j++) {
buffer = buffers[_j];
if (!buffer.length) {
continue;
}
buffer.copy(result, pos);
pos += buffer.length;
}
return result;
};
}
exports.split = function(buffer, pos, offset) {
var buflen, found, rest;
if (offset == null) offset = 0;
if (offset == null) {
offset = 0;
}
buflen = buffer.length;

@@ -42,0 +60,0 @@ found = new Buffer(min(buflen, pos));

(function() {
var BufferStream, PostBuffer;
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var BufferStream, PostBuffer,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

@@ -8,7 +8,7 @@ BufferStream = require('./buffer-stream');

PostBuffer = (function() {
function PostBuffer(req, opts) {
var _ref;
var _this = this;
if (opts == null) opts = {};
if (opts == null) {
opts = {};
}
this.pipe = __bind(this.pipe, this);

@@ -18,3 +18,5 @@ this.onEnd = __bind(this.onEnd, this);

this.got_all_data = false;
if ((_ref = opts.size) == null) opts.size = 'flexible';
if (opts.size == null) {
opts.size = 'flexible';
}
this.stream = new BufferStream(opts);

@@ -30,3 +32,5 @@ req.on('end', function() {

this.callback = callback;
if (this.got_all_data) return this.callback(this.stream.buffer);
if (this.got_all_data) {
return this.callback(this.stream.buffer);
}
};

@@ -33,0 +37,0 @@

{ "name": "bufferstream"
, "description": "painless stream buffering and cutting"
, "version": "0.5.1"
, "version": "0.5.2"
, "homepage": "https://github.com/dodo/node-bufferstream"

@@ -21,2 +21,5 @@ , "author": "dodo (https://github.com/dodo)"

"express": ">= 2.4.5"}
, "licenses" : [
{ "type": "MIT" ,
"url": "http://github.com/dodo/node-bufferstream/raw/master/LICENSE"} ]
}

@@ -14,3 +14,3 @@ (function() {

defaults: function(æ) {
var buffer, result, results, _i, _len, _ref2;
var buffer, result, results, _i, _len, _ref1;
buffer = new BufferStream({

@@ -33,5 +33,5 @@ size: 'flexible'

});
_ref2 = Array.prototype.slice(results);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
result = _ref2[_i];
_ref1 = Array.prototype.slice(results);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
result = _ref1[_i];
buffer.write(result);

@@ -38,0 +38,0 @@ }

@@ -14,3 +14,3 @@ (function() {

defaults: function(æ) {
var buffer, result, results, _i, _len, _ref2;
var buffer, result, results, _i, _len, _ref1;
buffer = new BufferStream;

@@ -34,5 +34,5 @@ æ.equal(buffer.finished, false);

});
_ref2 = Array.prototype.slice(results);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
result = _ref2[_i];
_ref1 = Array.prototype.slice(results);
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
result = _ref1[_i];
buffer.write(result);

@@ -39,0 +39,0 @@ }

Sorry, the diff of this file is not supported yet

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