Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

read-all-stream

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

read-all-stream - npm Package Compare versions

Comparing version 2.1.1 to 2.1.2

42

index.js
'use strict';
var concat = require('concat-stream');
var Writable = require('readable-stream').Writable;
var inherits = require('util').inherits;
function BufferStream() {
Writable.call(this, { objectMode: true });
this.buffer = [];
this.length = 0;
}
inherits(BufferStream, Writable);
BufferStream.prototype._write = function(chunk, enc, next) {
if (!Buffer.isBuffer(chunk)) {
chunk = new Buffer(chunk);
}
this.buffer.push(chunk);
this.length += chunk.length;
next();
};
module.exports = function read(stream, options, cb) {

@@ -25,11 +43,17 @@ if (!stream) {

stream
.once('error', cb)
.pipe(concat({encoding: 'buffer'}, function (data) {
if (options.encoding) {
data = data.toString(options.encoding);
}
var sink = new BufferStream();
cb(null, data);
}));
sink.on('finish', function () {
var data = Buffer.concat(this.buffer, this.length);
if (options.encoding) {
data = data.toString(options.encoding);
}
cb(null, data);
});
stream.once('error', cb);
stream.pipe(sink);
};
{
"name": "read-all-stream",
"version": "2.1.1",
"version": "2.1.2",
"description": "Read all stream content and pass it to callback",

@@ -15,4 +15,3 @@ "license": "MIT",

"scripts": {
"test": "mocha",
"coverage": "istanbul cover _mocha -- -R spec"
"test": "mocha"
},

@@ -29,9 +28,7 @@ "files": [

"devDependencies": {
"fast-apply": "0.0.3",
"istanbul": "^0.3.2",
"mocha": "*"
},
"dependencies": {
"concat-stream": "^1.4.8"
"readable-stream": "~1.1.13"
}
}
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