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

bufferedstream

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bufferedstream - npm Package Compare versions

Comparing version

to
1.4.0

31

buffered-stream.js

@@ -116,2 +116,6 @@ var util = require('util');

if (this.ended) {
throw new Error('Stream is already ended');
}
if (typeof chunk === 'string') {

@@ -123,2 +127,3 @@ chunk = new Buffer(chunk, encoding);

this.size += chunk.length;
flushOnNextTick(this);

@@ -145,13 +150,8 @@

if (arguments.length > 0) {
this.write(chunk, encoding);
}
if (chunk != null) this.write(chunk, encoding);
this.ended = true;
// If the stream isn't already scheduled to flush on the next tick we can
// safely end it now. Otherwise it will end after the next flush.
if (!this._flushing) {
end(this);
}
// Trigger the flush cycle one last time to emit any data that was written
// before we called end.
flushOnNextTick(this);
};

@@ -192,8 +192,2 @@

// If the stream was full at one point but isn't now, emit "drain".
if (stream._wasFull && !stream.full) {
stream._wasFull = false;
stream.emit('drain');
}
// If the stream was paused in some data event handler, break.

@@ -207,3 +201,10 @@ if (stream.paused) {

end(stream);
return;
}
// If the stream was full at one point but isn't now, emit "drain".
if (stream._wasFull && !stream.full) {
stream._wasFull = false;
stream.emit('drain');
}
}

@@ -210,0 +211,0 @@

@@ -5,3 +5,3 @@ {

"description": "A base stream class for node that reliably buffers until next tick",
"version": "1.3.0",
"version": "1.4.0",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

@@ -103,2 +103,18 @@ var assert = require('assert');

});
it('only emits "end" after it is resumed', function (done) {
var endWasCalled = false;
stream.on('end', function () {
endWasCalled = true;
});
stream.end();
assert.equal(endWasCalled, false);
stream.resume();
setTimeout(function () {
assert.equal(endWasCalled, true);
done();
}, 1);
});
});

@@ -138,2 +154,10 @@ });

it('throws when a stream is already ended', function () {
var stream = new BufferedStream;
stream.end();
assert.throws(function () {
stream.write('test');
}, /already ended/);
});
describe('when called with a string in base64 encoding', function () {

@@ -140,0 +164,0 @@ it('uses the proper encoding', function (callback) {

Sorry, the diff of this file is not supported yet