No Description

index.js 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. 'use strict';
  2. /**
  3. * Representation a of zip file in js
  4. * @constructor
  5. */
  6. function JSZip() {
  7. // if this constructor is used without `new`, it adds `new` before itself:
  8. if(!(this instanceof JSZip)) {
  9. return new JSZip();
  10. }
  11. if(arguments.length) {
  12. throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");
  13. }
  14. // object containing the files :
  15. // {
  16. // "folder/" : {...},
  17. // "folder/data.txt" : {...}
  18. // }
  19. this.files = {};
  20. this.comment = null;
  21. // Where we are in the hierarchy
  22. this.root = "";
  23. this.clone = function() {
  24. var newObj = new JSZip();
  25. for (var i in this) {
  26. if (typeof this[i] !== "function") {
  27. newObj[i] = this[i];
  28. }
  29. }
  30. return newObj;
  31. };
  32. }
  33. JSZip.prototype = require('./object');
  34. JSZip.prototype.loadAsync = require('./load');
  35. JSZip.support = require('./support');
  36. JSZip.defaults = require('./defaults');
  37. // TODO find a better way to handle this version,
  38. // a require('package.json').version doesn't work with webpack, see #327
  39. JSZip.version = "3.2.0";
  40. JSZip.loadAsync = function (content, options) {
  41. return new JSZip().loadAsync(content, options);
  42. };
  43. JSZip.external = require("./external");
  44. module.exports = JSZip;