1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
'use strict';
var base64 = require('./base64');
/**
Usage:
zip = new JSZip();
zip.file("hello.txt", "Hello, World!").file("tempfile", "nothing");
zip.folder("images").file("smile.gif", base64Data, {base64: true});
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
zip.remove("tempfile");
base64zip = zip.generate();
**/
/**
* Representation a of zip file in js
* @constructor
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
* @param {Object=} options the options for creating this objects (optional).
*/
function JSZip(data, options) {
// if this constructor is used without `new`, it adds `new` before itself:
if(!(this instanceof JSZip)) return new JSZip(data, options);
// object containing the files :
// {
// "folder/" : {...},
// "folder/data.txt" : {...}
// }
this.files = {};
this.comment = null;
// Where we are in the hierarchy
this.root = "";
if (data) {
this.load(data, options);
}
this.clone = function() {
var newObj = new JSZip();
for (var i in this) {
if (typeof this[i] !== "function") {
newObj[i] = this[i];
}
}
return newObj;
};
}
JSZip.prototype = require('./object');
JSZip.prototype.load = require('./load');
JSZip.support = require('./support');
JSZip.defaults = require('./defaults');
/**
* @deprecated
* This namespace will be removed in a future version without replacement.
*/
JSZip.utils = require('./deprecatedPublicUtils');
JSZip.base64 = {
/**
* @deprecated
* This method will be removed in a future version without replacement.
*/
encode : function(input) {
return base64.encode(input);
},
/**
* @deprecated
* This method will be removed in a future version without replacement.
*/
decode : function(input) {
return base64.decode(input);
}
};
JSZip.compressions = require('./compressions');
module.exports = JSZip;
|