Socket
Socket
Sign inDemoInstall

zip-local

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zip-local - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

tests/assets/folders.zip

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v0.3.3
Released 4/22/2016
* Defaulted the `createFolders` options in JSZip to `true` everywhere to ensure the conversion of logical directories in zip files to real ones, thus avoiding errors in extracting.
# v0.3.2

@@ -2,0 +6,0 @@ Released 4/15/2016

@@ -9,2 +9,36 @@ var fs = require('graceful-fs');

/*
* factory method to create jszip objects where 'createFolders'
* option is the default behavior everywhere
*/
JSZip.make = function(data, options) {
// augments the options object with a 'createFolders' option
function augment(_opts) {
var opts = _opts || {};
opts.createFolders = opts.createFolders || true;
return opts;
}
var instance = new JSZip(data, augment(options));
var originals = {};
originals.load = instance.load;
originals.file = instance.file;
instance.load = function(data, options) {
return originals.load.call(instance, data, augment(options));
};
instance.file = function(name, data, options) {
if(!data) {
return originals.file.call(instance, name);
}
return originals.file.call(instance, name, data, augment(options));
};
return instance;
};
/*****************************************************************************************

@@ -152,3 +186,3 @@ ******************************** PRIVATE HELPER FUNCTIONS ********************************

var zipped_obj = new JSZip();
var zipped_obj = JSZip.make();

@@ -238,3 +272,3 @@ if (typeof entity === "string") {

var callback = _callback || function () { };
var zipped_obj = new JSZip();
var zipped_obj = JSZip.make();

@@ -284,3 +318,3 @@ if (typeof file === "string") {

var zipped_obj = new JSZip();
var zipped_obj = JSZip.make();

@@ -337,3 +371,3 @@ if (typeof entity === "string") {

var zipped_obj = new JSZip();
var zipped_obj = JSZip.make();

@@ -340,0 +374,0 @@ if (typeof file === "string") {

2

package.json
{
"name": "zip-local",
"version": "0.3.2",
"version": "0.3.3",
"description": "very simple zipping/uzipping of local files and directories in node.js",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -36,14 +36,14 @@ # zip-local

if(!error) {
zipped.compress(); // compress before exporting
if(!error) {
zipped.compress(); // compress before exporting
var buff = zipped.memory(); // get the zipped file as a Buffer
var buff = zipped.memory(); // get the zipped file as a Buffer
// or save the zipped file to disk
zipped.save("../package.zip", function(error) {
if(!error) {
console.log("saved successfully !");
}
});
}
// or save the zipped file to disk
zipped.save("../package.zip", function(error) {
if(!error) {
console.log("saved successfully !");
}
});
}
});

@@ -81,17 +81,17 @@ ```

if(!error) {
// extract to the current working directory
unzipped.save(null, function() { });
if(!error) {
// extract to the current working directory
unzipped.save(null, function() { });
var unzippedfs = unzipped.memory();
var unzippedfs = unzipped.memory();
// print an array of file paths in the unzipped file
console.log(unzippedfs.contents()); // prints [ 'hello-world.cpp' ]
// print an array of file paths in the unzipped file
console.log(unzippedfs.contents()); // prints [ 'hello-world.cpp' ]
// read the file as text
var txt = unzippedfs.read("hello-world.cpp", 'text');
// read the file as text
var txt = unzippedfs.read("hello-world.cpp", 'text');
// or read it as Buffer
var buff = unzippedfs.read("hello-world.cpp", 'buffer');
}
// or read it as Buffer
var buff = unzippedfs.read("hello-world.cpp", 'buffer');
}
});

@@ -136,14 +136,14 @@ ```

if(error) {
console.log("ERROR: %s", error.message);
return;
}
if(error) {
console.log("ERROR: %s", error.message);
return;
}
// cache a copy of the zipped file on the server
zipped.save("zipped_from" + socket.remoteAddress + ".zip", function(error) {
if(error) {
console.log("ERROR: %s", error.message);
return;
}
});
if(error) {
console.log("ERROR: %s", error.message);
return;
}
});

@@ -170,6 +170,6 @@ // send the zipped file back to the client

if(error) {
console.log("ERROR: %s", error.message);
return;
}
if(error) {
console.log("ERROR: %s", error.message);
return;
}

@@ -191,8 +191,8 @@ var unzippedFS = unzipped.memory();

zipped.save("package.zip", function(error) {
if(error) {
console.log("ERROR: %s", error.message);
}
else {
console.log("The file is scanned and cleaned of executables");
}
if(error) {
console.log("ERROR: %s", error.message);
}
else {
console.log("The file is scanned and cleaned of executables");
}
});

@@ -199,0 +199,0 @@ });

@@ -26,3 +26,3 @@ var fs = require('fs');

var zipped = new JSZip(localMemory.T1ZippedBuffer);
var zipped = JSZip.make(localMemory.T1ZippedBuffer);

@@ -64,3 +64,3 @@ expect(zipped.files).to.have.property("world/").with.property('dir', true) &&

var zipped = new JSZip(data);
var zipped = JSZip.make(data);

@@ -67,0 +67,0 @@ expect(zipped.files).to.have.property("world/").with.property('dir', true) &&

@@ -19,3 +19,3 @@ var fs = require('fs');

var zipped = new JSZip(localMemory.T1ZippedBuffer);
var zipped = JSZip.make(localMemory.T1ZippedBuffer);

@@ -46,3 +46,3 @@ expect(zipped.files).to.have.property("world/").with.property('dir', true) &&

var zipped = new JSZip(data);
var zipped = JSZip.make(data);

@@ -49,0 +49,0 @@ expect(zipped.files).to.have.property("world/").with.property('dir', true) &&

@@ -26,3 +26,3 @@ var fs = require('fs');

var zipped = new JSZip(localMemory.T1ZippedBuffer);
var zipped = JSZip.make(localMemory.T1ZippedBuffer);

@@ -61,3 +61,3 @@ expect(zipped.files).to.have.property("hello-world") &&

var zipped = new JSZip(data);
var zipped = JSZip.make(data);

@@ -89,3 +89,3 @@ expect(zipped.files).to.have.property("hello-world") &&

var zipped = new JSZip(localMemory.T5ZippedBuffer);
var zipped = JSZip.make(localMemory.T5ZippedBuffer);

@@ -92,0 +92,0 @@ expect(zipped.files).to.have.property("hello-world") &&

@@ -19,3 +19,3 @@ var fs = require('fs');

var zipped = new JSZip(localMemory.T1ZippedBuffer);
var zipped = JSZip.make(localMemory.T1ZippedBuffer);

@@ -43,3 +43,3 @@ expect(zipped.files).to.have.property("hello-world") &&

var zipped = new JSZip(data);
var zipped = JSZip.make(data);

@@ -64,3 +64,3 @@ expect(zipped.files).to.have.property("hello-world") &&

var zipped = new JSZip(localMemory.T5ZippedBuffer);
var zipped = JSZip.make(localMemory.T5ZippedBuffer);

@@ -67,0 +67,0 @@ expect(zipped.files).to.have.property("hello-world") &&

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