Git Product home page Git Product logo

easy-zip2's Introduction

easy-zip2

A fork of npm module easy-zip

Installation

npm install --save easy-zip2

Examples

var EasyZip = require('easy-zip2').EasyZip;

// add text
console.log("add text");
var zip = new EasyZip();
zip.file('hello.txt', 'Hello World!');
zip.writeToFile('text.zip'); //write zip data to disk

// add folder
console.log("add folder");
var zip2 = new EasyZip();
var jsFolder = zip2.folder('js');
jsFolder.file('hello.js', 'alert("hello world")');
zip2.writeToFile('folder.zip');

// add file
console.log("add file");
var zip3 = new EasyZip();
zip3.addFile('main.js', 'easy-zip.js', function() {
    zip3.writeToFile('file.zip');
});

// batch add files
console.log("batch add files");
var files = [{
        source: 'easy-zip.js',
        target: 'easy-zip.js'
    }, {
        target: 'img'
    }, //if source is null,means make a folder
    {
        source: 'jszip.js',
        target: 'lib/tmp.js'
    }
];
var zip4 = new EasyZip();
zip4.batchAdd(files, function() {
    zip4.writeToFile('batchadd.zip');
});

// zip a folder
console.log("zip a folder");
var zip5 = new EasyZip();
zip5.zipFolder('../easy-zip2', function() {
    zip5.writeToFile('folderall.zip');
});

// zip a folder and change folder destination name
console.log("zip a folder and change folder destination name");
var zip6 = new EasyZip();
zip6.zipFolder('../easy-zip2', function() {
    zip6.writeToFile('folderall.zip');
}, {
    rootFolder: 'easy-zip6'
});

// write data to http.Response
//zip.writeToResponse(response,'attachment.zip');

// write to file sync
//zip.writeToFileSycn(filePath);

License

MIT License

easy-zip2's People

Contributors

colinmathews avatar jrnewell avatar

Watchers

 avatar

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.