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

tar-stream

Package Overview
Dependencies
Maintainers
1
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tar-stream - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

11

extract.js

@@ -6,2 +6,5 @@ var stream = require('stream');

var Writable = stream.Writable || require('readable-stream').Writable;
var PassThrough = stream.PassThrough || require('readable-stream').PassThrough;
var noop = function() {};

@@ -15,3 +18,3 @@

var emptyStream = function() {
var s = new stream.PassThrough();
var s = new PassThrough();
s.end();

@@ -29,3 +32,3 @@ return s;

if (!(this instanceof Extract)) return new Extract(opts);
stream.Writable.call(this, opts);
Writable.call(this, opts);

@@ -105,3 +108,3 @@ this._buffer = bl();

self._stream = new stream.PassThrough();
self._stream = new PassThrough();

@@ -116,3 +119,3 @@ self.emit('entry', header, self._stream, onunlock);

util.inherits(Extract, stream.Writable);
util.inherits(Extract, Writable);

@@ -119,0 +122,0 @@ Extract.prototype.destroy = function(err) {

@@ -5,2 +5,12 @@ var ZEROS = '0000000000000000000';

var clamp = function(index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue;
index = ~~index; // Coerce to integer.
if (index >= len) return len;
if (index >= 0) return index;
index += len;
if (index >= 0) return index;
return 0;
};
var toType = function(flag) {

@@ -23,3 +33,3 @@ switch (flag) {

case 7:
return 'contiguous-file'
return 'contiguous-file';
case 72:

@@ -83,3 +93,3 @@ return 'pax-header';

var decodeOct = function(val, offset) {
return parseInt(val.slice(offset, indexOf(val, 32, offset)).toString(), 8);
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset), val.length, val.length)).toString(), 8);
};

@@ -86,0 +96,0 @@

@@ -6,2 +6,5 @@ var stream = require('stream');

var Readable = stream.Readable || require('readable-stream').Readable;
var Writable = stream.Writable || require('readable-stream').Writable;
var END_OF_TAR = new Buffer(1024);

@@ -18,3 +21,3 @@ END_OF_TAR.fill(0);

var Sink = function(to) {
stream.Writable.call(this);
Writable.call(this);
this.written = 0;

@@ -25,3 +28,3 @@ this._to = to;

util.inherits(Sink, stream.Writable);
util.inherits(Sink, Writable);

@@ -42,3 +45,3 @@ Sink.prototype._write = function(data, enc, cb) {

if (!(this instanceof Pack)) return new Pack(opts);
stream.Readable.call(this, opts);
Readable.call(this, opts);

@@ -52,3 +55,3 @@ this._drain = noop;

util.inherits(Pack, stream.Readable);
util.inherits(Pack, Readable);

@@ -55,0 +58,0 @@ Pack.prototype.entry = function(header, buffer, callback) {

{
"name": "tar-stream",
"version": "0.2.3",
"version": "0.2.4",
"description": "tar-stream is a streaming tar parser and generator and nothing else. It is streams2 and operates purely using streams which means you can easily extract/parse tarballs without ever hitting the file system.",
"repository": "git://github.com:mafintosh/tar-stream.git",
"author": "Mathias Buus <mathiasbuus@gmail.com>",
"engines": {
"node": ">= 0.8.0"
},
"dependencies": {

@@ -13,3 +16,4 @@ "end-of-stream": "~0.1.3",

"tap": "~0.4.6",
"concat-stream": "~1.2.1"
"concat-stream": "~1.2.1",
"readable-stream": "~1.1.9"
},

@@ -16,0 +20,0 @@ "scripts": {

@@ -115,10 +115,6 @@ # tar-stream

Packing/extracting a 6.1 GB with 2496 directories and 2398 files yields the following results on my Macbook Air
[See tar-fs for a performance comparison with node-tar](https://github.com/mafintosh/tar-fs/blob/master/README.md#performance)
* tar-stream (using [tar-fs](https://github.com/mafintosh/tar-fs)): 34.261 ms
* [node-tar](https://github.com/isaacs/node-tar): 366.123 ms
* native tar command: 47.241 ms (this one is a bit unfair as it is piping through processes)
# License
MIT

@@ -7,2 +7,12 @@ var test = require('tap').test;

var clamp = function(index, len, defaultValue) {
if (typeof index !== 'number') return defaultValue;
index = ~~index; // Coerce to integer.
if (index >= len) return len;
if (index >= 0) return index;
index += len;
if (index >= 0) return index;
return 0;
};
test('one-file', function(t) {

@@ -80,3 +90,3 @@ t.plan(3);

for (var i = 0; i < b.length; i += 321) {
extract.write(b.slice(i, i+321));
extract.write(b.slice(i, clamp(i+321, b.length, b.length)));
}

@@ -208,3 +218,3 @@ extract.end();

for (var i = 0; i < b.length; i += 321) {
extract.write(b.slice(i, i+321));
extract.write(b.slice(i, clamp(i+321, b.length, b.length)));
}

@@ -211,0 +221,0 @@ extract.end();

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