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