GithubHelp home page GithubHelp logo

moxie-zip's Introduction

moxie-zip

This is another zip library for node js. We decided to write our own since we had issues with the current once that exists.

It's a very simple library:

var ZipWriter = require("moxie-zip").ZipWriter;
var zip = new ZipWriter();

zip.addFile("myfile.txt", "./myfile.txt");
zip.addData("myfile.txt", "Hello world!");
zip.addDir("mydir");

zip.toBuffer(function(buf) {
});

zip.saveAs("my.zip", function() {
   console.log("zip written.");
});

moxie-zip's People

Contributors

spocke avatar timemachine3030 avatar townxelliot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

moxie-zip's Issues

npm publish

Hi, the new changes to the library look great. Can you publish them to npm?

Thank you.

saveAs function donnot catch file read failed error

Problem:
saveAs function throws file read failed error
Reason:
toBuffer function use 'fs' module sync function to read file, but donnot try/catch the error or other error handler.
Although there is a callback(error) function in arguments, but still need developer to try/catch the saveAs function.

I think it's maybe a bug.

getHours() problem

the sample code on the home page doesn't work as
mtime become a number after
entry.mtime.getHours(); // line 155

calling zip.toBuffer() will call entry.mtime.getHours() again
will throw an error

UTF Characters

I ran into issues zipping some .js files that have characters such as λ in them. Are these indeed not supported at the moment? If so, while I don't speak ZIP, I will try to add this and PR it -- IF you can confirm that it wouldn't be a can of worms and that you would accept such PR.

Please let me know...

Thanks!

Empty files are converted into directories

If you try to include an empty file in a zip file, the file becomes a directory instead.

This is because
https://github.com/spocke/moxie-zip/blob/master/lib/ZipWriter.js#L287
checks the length of the file data, which may be zero for an empty file.

I suggest you change the check to:

if (entry.isFile !== false)

as isFile is set explicitly to false by addDirectory(). This will allow files with no data to be added to the output zip file correctly (as files).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.