Socket
Socket
Sign inDemoInstall

archiver

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

archiver - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

27

lib/modules/core/index.js

@@ -9,4 +9,3 @@ /**

var inherits = require('util').inherits;
var Transform = require('stream').Transform || require('readable-stream').Transform;
var PassThrough = require('stream').PassThrough || require('readable-stream').PassThrough;
var Transform = require('readable-stream').Transform;

@@ -50,2 +49,3 @@ var util = require('../../util');

date: null,
mode: null,
sourcePath: null

@@ -67,2 +67,8 @@ });

if (typeof data.mode === 'number') {
data.mode &= 0777;
} else {
data.mode = isDir ? 0755 : 0644;
}
data.date = util.dateify(data.date);

@@ -73,17 +79,2 @@

Archiver.prototype._normalizeSource = function(source) {
if (source === null) {
return new Buffer(0);
} else if (typeof source === 'string') {
return new Buffer(source);
} else if (util.isStream(source) && !source._readableState) {
var normalized = new PassThrough();
source.pipe(normalized);
return normalized;
}
return source;
};
Archiver.prototype._onModuleError = function(err) {

@@ -156,3 +147,3 @@ this.emit('error', err);

source = this._normalizeSource(source);
source = util.normalizeInputSource(source);

@@ -159,0 +150,0 @@ if (Buffer.isBuffer(source)) {

@@ -9,3 +9,3 @@ /**

var inherits = require('util').inherits;
var Transform = require('stream').Transform || require('readable-stream').Transform;
var Transform = require('readable-stream').Transform;

@@ -41,4 +41,3 @@ var crc32 = require('buffer-crc32');

var file = data;
file.crc32 = null;
data.crc32 = 0;

@@ -51,18 +50,13 @@ function onend(err, sourceBuffer) {

sourceBuffer = sourceBuffer || false;
file.size = sourceBuffer.length || 0;
data.size = sourceBuffer.length || 0;
data.crc32 = crc32.unsigned(sourceBuffer);
self.files.push(data);
if (file.size > 0) {
file.crc32 = crc32.unsigned(sourceBuffer);
}
self.files.push(file);
callback(null, file);
callback(null, data);
}
if (file.sourceType === 'buffer') {
if (data.sourceType === 'buffer') {
onend(null, source);
} else if (file.sourceType === 'stream') {
} else if (data.sourceType === 'stream') {
util.collectStream(source, onend);

@@ -69,0 +63,0 @@ }

@@ -8,7 +8,5 @@ /**

*/
var inherits = require('util').inherits;
var Transform = require('stream').Transform || require('readable-stream').Transform;
var zlib = require('zlib');
var headers = require('./headers');
var engine = require('tar-stream');
var util = require('../../util');

@@ -18,4 +16,2 @@

options = this.options = util.defaults(options, {
recordSize: 512,
recordsPerBlock: 20,
gzip: false

@@ -28,4 +24,2 @@ });

Transform.call(this, options);
this.supports = {

@@ -35,9 +29,5 @@ directory: true

this.engine = engine.pack(options);
this.compressor = false;
this.offset = 0;
this.files = [];
this.recordSize = options.recordSize;
this.blockSize = options.recordsPerBlock * options.recordSize;
if (options.gzip) {

@@ -49,29 +39,12 @@ this.compressor = zlib.createGzip(options.gzipOptions);

inherits(Tar, Transform);
Tar.prototype._onCompressorError = function(err) {
this.emit('error', err);
this.engine.emit('error', err);
};
Tar.prototype._transform = function(chunk, encoding, callback) {
callback(null, chunk);
};
Tar.prototype._writeEndBytes = function() {
var endBytes = this.blockSize - (this.offset % this.blockSize);
this.write(util.cleanBuffer(endBytes));
};
Tar.prototype.append = function(source, data, callback) {
var self = this;
data.offset = self.offset;
data.mtime = data.date;
if (data.name.length > 255) {
callback(new Error('entry name "' + data.name + '" is too long even with prefix support [' + data.name.length + '/255]'));
return;
}
function onend(err, sourceBuffer) {
function append(err, sourceBuffer) {
if (err) {

@@ -82,42 +55,20 @@ callback(err);

sourceBuffer = sourceBuffer || false;
data.size = sourceBuffer.length || 0;
var extraBytes = self.recordSize - (data.size % self.recordSize || self.recordSize);
self.write(headers.encode('file', data));
if (data.size > 0) {
self.write(sourceBuffer);
}
self.write(util.cleanBuffer(extraBytes));
self.files.push(data);
callback(null, data);
self.engine.entry(data, sourceBuffer, function(err) {
callback(err, data);
});
}
if (data.sourceType === 'buffer') {
onend(null, source);
append(null, source);
} else if (data.sourceType === 'stream') {
util.collectStream(source, onend);
util.collectStream(source, append);
}
};
Tar.prototype.finalize = function(callback) {
callback = callback || function() {};
this._writeEndBytes();
this.end();
callback();
Tar.prototype.finalize = function() {
this.engine.finalize();
};
Tar.prototype.write = function(chunk, cb) {
if (chunk) {
this.offset += chunk.length;
}
return Transform.prototype.write.call(this, chunk, cb);
Tar.prototype.on = function() {
return this.engine.on.apply(this.engine, arguments);
};

@@ -127,6 +78,6 @@

if (this.compressor) {
return Transform.prototype.pipe.call(this, this.compressor).pipe(destination, options);
return this.engine.pipe.apply(this.engine, [this.compressor]).pipe(destination, options);
} else {
return Transform.prototype.pipe.call(this, destination, options);
return this.engine.pipe.apply(this.engine, arguments);
}
};

@@ -9,3 +9,3 @@ /**

var inherits = require('util').inherits;
var Transform = require('stream').Transform || require('readable-stream').Transform;
var Transform = require('readable-stream').Transform;

@@ -12,0 +12,0 @@ var crc32 = require('buffer-crc32');

@@ -10,4 +10,6 @@ /**

var path = require('path');
var stream = require('stream');
var Stream = require('stream').Stream;
var PassThrough = require('readable-stream').PassThrough;
var util = module.exports = {};

@@ -19,10 +21,2 @@

util.cleanBuffer = function(length) {
var buf = new Buffer(length);
buf.fill(0);
return buf;
};
util.collectStream = function(source, callback) {

@@ -52,14 +46,2 @@ var collection = [];

util.convertDateTimeEpoch = function(input) {
input = input * 1000;
return new Date(input);
};
util.convertDateTimeOctal = function(input) {
input = parseInt(input, 8) * 1000;
return new Date(input);
};
util.dateify = function(dateish) {

@@ -87,10 +69,4 @@ dateish = dateish || new Date();

util.epochDateTime = function(d) {
d = (d instanceof Date) ? d : new Date();
return Math.round(d / 1000);
};
util.isStream = function(source) {
return (source instanceof stream.Stream);
return source instanceof Stream;
};

@@ -184,30 +160,15 @@

util.octalDateTime = function(d) {
d = (d instanceof Date) ? d : new Date();
util.normalizeInputSource = function(source) {
if (source === null) {
return new Buffer(0);
} else if (typeof source === 'string') {
return new Buffer(source);
} else if (util.isStream(source) && !source._readableState) {
var normalized = new PassThrough();
source.pipe(normalized);
return Math.round(d / 1000).toString(8);
};
util.padNumber = function(num, bytes, base) {
num = num.toString(base || 8);
return util.repeat('0', bytes - num.length) + num;
};
util.repeat = function(pattern, count) {
if (count < 1) {
return '';
return normalized;
}
var result = '';
while (count > 0) {
if (count & 1) {
result += pattern;
}
count >>= 1;
pattern += pattern;
}
return result;
return source;
};

@@ -220,59 +181,2 @@

util.scanBuffer = function(buf, search, offset) {
if (!Buffer.isBuffer(buf)) {
return false;
}
var origBufLength = buf.length;
var negative = false;
var wasOffset = false;
if (offset) {
if (offset < 0) {
offset = offset * -1;
negative = true;
}
if (offset <= origBufLength) {
if (negative) {
offset = offset * -1;
}
wasOffset = true;
buf = buf.slice(offset);
}
}
if (typeof search === 'string') {
search = new Buffer(search);
} else if (!Buffer.isBuffer(search)) {
return false;
}
// simple but slow string search
for (var i = 0; i <= buf.length - search.length + 1; i++) {
for (var j = 0; j < search.length && buf[i + j] === search[j]; j++);
if (j === search.length) {
if (wasOffset) {
return origBufLength - (buf.length - i);
}
return i;
}
}
return false;
};
util.scanBufferUInt32LE = function(buf, search, offset) {
if (!search) {
return false;
}
var searchBuf = new Buffer(4);
searchBuf.writeUInt32LE(search, 0);
return util.scanBuffer(buf, searchBuf, offset);
};
util.stat = function() {

@@ -279,0 +183,0 @@ var filepath = path.join.apply(path, arguments);

{
"name": "archiver",
"version": "0.8.1",
"description": "Creates Archives (ZIP) via Node Streams.",
"version": "0.9.0",
"description": "a streaming interface for archive generation",
"homepage": "https://github.com/ctalkington/node-archiver",

@@ -24,2 +24,6 @@ "author": {

"main": "lib/archiver.js",
"files": [
"lib",
"LICENSE-MIT"
],
"engines": {

@@ -35,2 +39,3 @@ "node": ">= 0.8.0"

"readable-stream": "~1.0.24",
"tar-stream": "~0.3.0",
"zip-stream": "~0.3.0",

@@ -51,2 +56,3 @@ "lazystream": "~0.1.0",

"archiver",
"stream",
"zip",

@@ -53,0 +59,0 @@ "tar"

@@ -1,4 +0,4 @@

# Archiver v0.8.1 [![Build Status](https://travis-ci.org/ctalkington/node-archiver.svg?branch=master)](https://travis-ci.org/ctalkington/node-archiver)
# Archiver v0.9.0 [![Build Status](https://travis-ci.org/ctalkington/node-archiver.svg?branch=master)](https://travis-ci.org/ctalkington/node-archiver)
Creates Archives (Zip, Tar) via Node Streams.
a streaming interface for archive generation

@@ -120,3 +120,3 @@ [![NPM](https://nodei.co/npm/archiver.png)](https://nodei.co/npm/archiver/)

Sets the entry permissions. (experimental)
Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).

@@ -127,10 +127,2 @@ ## Tar

#### recordSize `number`
Sets the size (in bytes) of each record in a block, default is 512 (for advanced users only).
#### recordsPerBlock `number`
Sets the number of records in a block, default is 20 (for advanced users only).
#### gzip `boolean`

@@ -156,4 +148,11 @@

Sets the entry permissions. Defaults to octal 0664.
Sets the entry permissions. Defaults to octal 0755 (directory) or 0644 (file).
## Libraries
Archiver makes use of several libraries/modules to avoid duplication of efforts.
- [zip-stream](https://npmjs.org/package/zip-stream)
- [tar-stream](https://npmjs.org/package/tar-stream)
## Things of Interest

@@ -163,10 +162,3 @@

- [Changelog](https://github.com/ctalkington/node-archiver/releases)
- [Archive Formats](https://github.com/ctalkington/node-archiver/blob/master/formats)
- [Contributing](https://github.com/ctalkington/node-archiver/blob/master/CONTRIBUTING.md)
- [MIT License](https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT)
## Credits
Concept inspired by Antoine van Wel's [node-zipstream](https://github.com/wellawaretech/node-zipstream).
Tar inspired by isaacs's [node-tar](https://github.com/isaacs/node-tar).
- [MIT License](https://github.com/ctalkington/node-archiver/blob/master/LICENSE-MIT)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc