Socket
Socket
Sign inDemoInstall

compress-commons

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compress-commons - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

lib/archivers/zip/zip-archive-entry.js

@@ -52,3 +52,3 @@ /**

ZipArchiveEntry.prototype.getComment = function() {
return this.comment !== null ? this.comment : constants.EMPTY;
return this.comment !== null ? this.comment : '';
};

@@ -55,0 +55,0 @@

@@ -57,24 +57,24 @@ /**

ZipArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) {
ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) {
if (source.length === 0) {
zae.setMethod(constants.METHOD_STORED);
ae.setMethod(constants.METHOD_STORED);
}
var method = zae.getMethod();
var method = ae.getMethod();
if (method === constants.METHOD_STORED) {
zae.setSize(source.length);
zae.setCompressedSize(source.length);
zae.setCrc(crc32.unsigned(source));
ae.setSize(source.length);
ae.setCompressedSize(source.length);
ae.setCrc(crc32.unsigned(source));
}
this._writeLocalFileHeader(zae);
this._writeLocalFileHeader(ae);
if (method === constants.METHOD_STORED) {
this.write(source);
this._afterAppend(zae);
callback(null, zae);
this._afterAppend(ae);
callback(null, ae);
return;
} else if (method === constants.METHOD_DEFLATED) {
this._smartStream(zae, callback).end(source);
this._smartStream(ae, callback).end(source);
return;

@@ -87,8 +87,8 @@ } else {

ZipArchiveOutputStream.prototype._appendStream = function(zae, source, callback) {
zae.getGeneralPurposeBit().useDataDescriptor(true);
ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) {
ae.getGeneralPurposeBit().useDataDescriptor(true);
this._writeLocalFileHeader(zae);
this._writeLocalFileHeader(ae);
var smart = this._smartStream(zae, callback);
var smart = this._smartStream(ae, callback);
source.pipe(smart);

@@ -100,4 +100,4 @@ };

this._entries.forEach(function(zae) {
this._writeCentralFileHeader(zae);
this._entries.forEach(function(ae) {
this._writeCentralFileHeader(ae);
}.bind(this));

@@ -136,12 +136,12 @@

ZipArchiveOutputStream.prototype._smartStream = function(zae, callback) {
var deflate = zae.getMethod() === constants.METHOD_DEFLATED;
ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) {
var deflate = ae.getMethod() === constants.METHOD_DEFLATED;
var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new ChecksumStream();
function handleStuff(err) {
zae.setCrc(process.digest());
zae.setSize(process.size());
zae.setCompressedSize(process.size(true));
this._afterAppend(zae);
callback(null, zae);
ae.setCrc(process.digest());
ae.setSize(process.size());
ae.setCompressedSize(process.size(true));
this._afterAppend(ae);
callback(null, ae);
}

@@ -175,9 +175,10 @@

var comment = this.getComment();
this.write(zipUtil.getShortBytes(comment.length));
var commentLength = Buffer.byteLength(comment);
this.write(zipUtil.getShortBytes(commentLength));
this.write(comment);
};
ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(zae) {
var method = zae.getMethod();
var offsets = zae._offsets;
ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) {
var method = ae.getMethod();
var offsets = ae._offsets;

@@ -189,7 +190,7 @@ // signature

this.write(zipUtil.getShortBytes(
(zae.getPlatform() << 8) | constants.DATA_DESCRIPTOR_MIN_VERSION
(ae.getPlatform() << 8) | constants.DATA_DESCRIPTOR_MIN_VERSION
));
// version to extract and general bit flag
this._writeVersionGeneral(zae);
this._writeVersionGeneral(ae);

@@ -200,23 +201,26 @@ // compression method

// datetime
this.write(zipUtil.getLongBytes(zae.getTimeDos()));
this.write(zipUtil.getLongBytes(ae.getTimeDos()));
// crc32 checksum
this.write(zipUtil.getLongBytes(zae.getCrc()));
this.write(zipUtil.getLongBytes(ae.getCrc()));
// sizes
this.write(zipUtil.getLongBytes(zae.getCompressedSize()));
this.write(zipUtil.getLongBytes(zae.getSize()));
this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
this.write(zipUtil.getLongBytes(ae.getSize()));
var name = zae.getName();
var comment = zae.getComment();
var extra = zae.getCentralDirectoryExtra();
var name = ae.getName();
var nameLength = Buffer.byteLength(name);
var comment = ae.getComment();
var commentLength = Buffer.byteLength(comment);
var extra = ae.getCentralDirectoryExtra();
var extraLength = extra.length;
// name length
this.write(zipUtil.getShortBytes(name.length));
this.write(zipUtil.getShortBytes(nameLength));
// extra length
this.write(zipUtil.getShortBytes(extra.length));
this.write(zipUtil.getShortBytes(extraLength));
// comments length
this.write(zipUtil.getShortBytes(comment.length));
this.write(zipUtil.getShortBytes(commentLength));

@@ -227,6 +231,6 @@ // disk number start

// internal attributes
this.write(zipUtil.getShortBytes(zae.getInternalAttributes()));
this.write(zipUtil.getShortBytes(ae.getInternalAttributes()));
// external attributes
this.write(zipUtil.getLongBytes(zae.getExternalAttributes()));
this.write(zipUtil.getLongBytes(ae.getExternalAttributes()));

@@ -246,4 +250,4 @@ // relative offset of LFH

ZipArchiveOutputStream.prototype._writeDataDescriptor = function(zae) {
if (zae.getGeneralPurposeBit().usesDataDescriptor()) {
ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) {
if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
return;

@@ -256,15 +260,17 @@ }

// crc32 checksum
this.write(zipUtil.getLongBytes(zae.getCrc()));
this.write(zipUtil.getLongBytes(ae.getCrc()));
// sizes
this.write(zipUtil.getLongBytes(zae.getCompressedSize()));
this.write(zipUtil.getLongBytes(zae.getSize()));
this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
this.write(zipUtil.getLongBytes(ae.getSize()));
};
ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(zae) {
var method = zae.getMethod();
var name = zae.getName();
var extra = zae.getLocalFileDataExtra();
ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) {
var method = ae.getMethod();
var name = ae.getName();
var nameLength = Buffer.byteLength(name);
var extra = ae.getLocalFileDataExtra();
var extraLength = extra.length;
zae._offsets.file = this.offset;
ae._offsets.file = this.offset;

@@ -275,3 +281,3 @@ // signature

// version to extract and general bit flag
this._writeVersionGeneral(zae);
this._writeVersionGeneral(ae);

@@ -282,7 +288,7 @@ // compression method

// datetime
this.write(zipUtil.getLongBytes(zae.getTimeDos()));
this.write(zipUtil.getLongBytes(ae.getTimeDos()));
zae._offsets.data = this.offset;
ae._offsets.data = this.offset;
if (zae.getGeneralPurposeBit().usesDataDescriptor()) {
if (ae.getGeneralPurposeBit().usesDataDescriptor()) {
// zero fill and set later

@@ -294,12 +300,12 @@ this.write(constants.LONG_ZERO);

// crc32 checksum and sizes
this.write(zipUtil.getLongBytes(zae.getCrc()));
this.write(zipUtil.getLongBytes(zae.getCompressedSize()));
this.write(zipUtil.getLongBytes(zae.getSize()));
this.write(zipUtil.getLongBytes(ae.getCrc()));
this.write(zipUtil.getLongBytes(ae.getCompressedSize()));
this.write(zipUtil.getLongBytes(ae.getSize()));
}
// name length
this.write(zipUtil.getShortBytes(name.length));
this.write(zipUtil.getShortBytes(nameLength));
// extra length
this.write(zipUtil.getShortBytes(extra.length));
this.write(zipUtil.getShortBytes(extraLength));

@@ -312,8 +318,8 @@ // name

zae._offsets.contents = this.offset;
ae._offsets.contents = this.offset;
};
ZipArchiveOutputStream.prototype._writeVersionGeneral = function(zae) {
this.write(zipUtil.getShortBytes(zae.getVersionNeededToExtract()));
this.write(zae.getGeneralPurposeBit().encode());
ZipArchiveOutputStream.prototype._writeVersionGeneral = function(ae) {
this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract()));
this.write(ae.getGeneralPurposeBit().encode());
};

@@ -334,3 +340,3 @@

ZipArchiveOutputStream.prototype.getComment = function(comment) {
return this._archive.comment === null ? '' : this._archive.comment;
return this._archive.comment !== null ? this._archive.comment : '';
};

@@ -337,0 +343,0 @@

{
"name": "compress-commons",
"version": "0.1.1",
"version": "0.1.2",
"description": "a library that defines a common interface for working with archives within node",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/ctalkington/node-compress-commons",

@@ -1,2 +0,2 @@

# Compress Commons v0.1.1 [![Build Status](https://travis-ci.org/ctalkington/node-compress-commons.svg?branch=master)](https://travis-ci.org/ctalkington/node-compress-commons)
# Compress Commons v0.1.2 [![Build Status](https://travis-ci.org/ctalkington/node-compress-commons.svg?branch=master)](https://travis-ci.org/ctalkington/node-compress-commons)

@@ -3,0 +3,0 @@ Compress Commons is a library that defines a common interface for working with archives within node.

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