{"ast":null,"code":"'use strict';\n\nvar utf8 = require('./utf8');\n\nvar utils = require('./utils');\n\nvar GenericWorker = require('./stream/GenericWorker');\n\nvar StreamHelper = require('./stream/StreamHelper');\n\nvar defaults = require('./defaults');\n\nvar CompressedObject = require('./compressedObject');\n\nvar ZipObject = require('./zipObject');\n\nvar generate = require(\"./generate\");\n\nvar nodejsUtils = require(\"./nodejsUtils\");\n\nvar NodejsStreamInputAdapter = require(\"./nodejs/NodejsStreamInputAdapter\");\n/**\n * Add a file in the current folder.\n * @private\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file\n * @param {Object} originalOptions the options of the file\n * @return {Object} the new file.\n */\n\n\nvar fileAdd = function (name, data, originalOptions) {\n  // be sure sub folders exist\n  var dataType = utils.getTypeOf(data),\n      parent;\n  /*\n   * Correct options.\n   */\n\n  var o = utils.extend(originalOptions || {}, defaults);\n  o.date = o.date || new Date();\n\n  if (o.compression !== null) {\n    o.compression = o.compression.toUpperCase();\n  }\n\n  if (typeof o.unixPermissions === \"string\") {\n    o.unixPermissions = parseInt(o.unixPermissions, 8);\n  } // UNX_IFDIR  0040000 see zipinfo.c\n\n\n  if (o.unixPermissions && o.unixPermissions & 0x4000) {\n    o.dir = true;\n  } // Bit 4    Directory\n\n\n  if (o.dosPermissions && o.dosPermissions & 0x0010) {\n    o.dir = true;\n  }\n\n  if (o.dir) {\n    name = forceTrailingSlash(name);\n  }\n\n  if (o.createFolders && (parent = parentFolder(name))) {\n    folderAdd.call(this, parent, true);\n  }\n\n  var isUnicodeString = dataType === \"string\" && o.binary === false && o.base64 === false;\n\n  if (!originalOptions || typeof originalOptions.binary === \"undefined\") {\n    o.binary = !isUnicodeString;\n  }\n\n  var isCompressedEmpty = data instanceof CompressedObject && data.uncompressedSize === 0;\n\n  if (isCompressedEmpty || o.dir || !data || data.length === 0) {\n    o.base64 = false;\n    o.binary = true;\n    data = \"\";\n    o.compression = \"STORE\";\n    dataType = \"string\";\n  }\n  /*\n   * Convert content to fit.\n   */\n\n\n  var zipObjectContent = null;\n\n  if (data instanceof CompressedObject || data instanceof GenericWorker) {\n    zipObjectContent = data;\n  } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n    zipObjectContent = new NodejsStreamInputAdapter(name, data);\n  } else {\n    zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);\n  }\n\n  var object = new ZipObject(name, zipObjectContent, o);\n  this.files[name] = object;\n  /*\n  TODO: we can't throw an exception because we have async promises\n  (we can have a promise of a Date() for example) but returning a\n  promise is useless because file(name, data) returns the JSZip\n  object for chaining. Should we break that to allow the user\n  to catch the error ?\n   return external.Promise.resolve(zipObjectContent)\n  .then(function () {\n      return object;\n  });\n  */\n};\n/**\n * Find the parent folder of the path.\n * @private\n * @param {string} path the path to use\n * @return {string} the parent folder, or \"\"\n */\n\n\nvar parentFolder = function (path) {\n  if (path.slice(-1) === '/') {\n    path = path.substring(0, path.length - 1);\n  }\n\n  var lastSlash = path.lastIndexOf('/');\n  return lastSlash > 0 ? path.substring(0, lastSlash) : \"\";\n};\n/**\n * Returns the path with a slash at the end.\n * @private\n * @param {String} path the path to check.\n * @return {String} the path with a trailing slash.\n */\n\n\nvar forceTrailingSlash = function (path) {\n  // Check the name ends with a /\n  if (path.slice(-1) !== \"/\") {\n    path += \"/\"; // IE doesn't like substr(-1)\n  }\n\n  return path;\n};\n/**\n * Add a (sub) folder in the current folder.\n * @private\n * @param {string} name the folder's name\n * @param {boolean=} [createFolders] If true, automatically create sub\n *  folders. Defaults to false.\n * @return {Object} the new folder.\n */\n\n\nvar folderAdd = function (name, createFolders) {\n  createFolders = typeof createFolders !== 'undefined' ? createFolders : defaults.createFolders;\n  name = forceTrailingSlash(name); // Does this folder already exist?\n\n  if (!this.files[name]) {\n    fileAdd.call(this, name, null, {\n      dir: true,\n      createFolders: createFolders\n    });\n  }\n\n  return this.files[name];\n};\n/**\n* Cross-window, cross-Node-context regular expression detection\n* @param  {Object}  object Anything\n* @return {Boolean}        true if the object is a regular expression,\n* false otherwise\n*/\n\n\nfunction isRegExp(object) {\n  return Object.prototype.toString.call(object) === \"[object RegExp]\";\n} // return the actual prototype of JSZip\n\n\nvar out = {\n  /**\n   * @see loadAsync\n   */\n  load: function () {\n    throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n  },\n\n  /**\n   * Call a callback function for each entry at this folder level.\n   * @param {Function} cb the callback function:\n   * function (relativePath, file) {...}\n   * It takes 2 arguments : the relative path and the file.\n   */\n  forEach: function (cb) {\n    var filename, relativePath, file;\n\n    for (filename in this.files) {\n      if (!this.files.hasOwnProperty(filename)) {\n        continue;\n      }\n\n      file = this.files[filename];\n      relativePath = filename.slice(this.root.length, filename.length);\n\n      if (relativePath && filename.slice(0, this.root.length) === this.root) {\n        // the file is in the current root\n        cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...\n      }\n    }\n  },\n\n  /**\n   * Filter nested files/folders with the specified function.\n   * @param {Function} search the predicate to use :\n   * function (relativePath, file) {...}\n   * It takes 2 arguments : the relative path and the file.\n   * @return {Array} An array of matching elements.\n   */\n  filter: function (search) {\n    var result = [];\n    this.forEach(function (relativePath, entry) {\n      if (search(relativePath, entry)) {\n        // the file matches the function\n        result.push(entry);\n      }\n    });\n    return result;\n  },\n\n  /**\n   * Add a file to the zip file, or search a file.\n   * @param   {string|RegExp} name The name of the file to add (if data is defined),\n   * the name of the file to find (if no data) or a regex to match files.\n   * @param   {String|ArrayBuffer|Uint8Array|Buffer} data  The file data, either raw or base64 encoded\n   * @param   {Object} o     File options\n   * @return  {JSZip|Object|Array} this JSZip object (when adding a file),\n   * a file (when searching by string) or an array of files (when searching by regex).\n   */\n  file: function (name, data, o) {\n    if (arguments.length === 1) {\n      if (isRegExp(name)) {\n        var regexp = name;\n        return this.filter(function (relativePath, file) {\n          return !file.dir && regexp.test(relativePath);\n        });\n      } else {\n        // text\n        var obj = this.files[this.root + name];\n\n        if (obj && !obj.dir) {\n          return obj;\n        } else {\n          return null;\n        }\n      }\n    } else {\n      // more than one argument : we have data !\n      name = this.root + name;\n      fileAdd.call(this, name, data, o);\n    }\n\n    return this;\n  },\n\n  /**\n   * Add a directory to the zip file, or search.\n   * @param   {String|RegExp} arg The name of the directory to add, or a regex to search folders.\n   * @return  {JSZip} an object with the new directory as the root, or an array containing matching folders.\n   */\n  folder: function (arg) {\n    if (!arg) {\n      return this;\n    }\n\n    if (isRegExp(arg)) {\n      return this.filter(function (relativePath, file) {\n        return file.dir && arg.test(relativePath);\n      });\n    } // else, name is a new folder\n\n\n    var name = this.root + arg;\n    var newFolder = folderAdd.call(this, name); // Allow chaining by returning a new object with this folder as the root\n\n    var ret = this.clone();\n    ret.root = newFolder.name;\n    return ret;\n  },\n\n  /**\n   * Delete a file, or a directory and all sub-files, from the zip\n   * @param {string} name the name of the file to delete\n   * @return {JSZip} this JSZip object\n   */\n  remove: function (name) {\n    name = this.root + name;\n    var file = this.files[name];\n\n    if (!file) {\n      // Look for any folders\n      if (name.slice(-1) !== \"/\") {\n        name += \"/\";\n      }\n\n      file = this.files[name];\n    }\n\n    if (file && !file.dir) {\n      // file\n      delete this.files[name];\n    } else {\n      // maybe a folder, delete recursively\n      var kids = this.filter(function (relativePath, file) {\n        return file.name.slice(0, name.length) === name;\n      });\n\n      for (var i = 0; i < kids.length; i++) {\n        delete this.files[kids[i].name];\n      }\n    }\n\n    return this;\n  },\n\n  /**\n   * Generate the complete zip file\n   * @param {Object} options the options to generate the zip file :\n   * - compression, \"STORE\" by default.\n   * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n   * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file\n   */\n  generate: function (options) {\n    throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n  },\n\n  /**\n   * Generate the complete zip file as an internal stream.\n   * @param {Object} options the options to generate the zip file :\n   * - compression, \"STORE\" by default.\n   * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n   * @return {StreamHelper} the streamed zip file.\n   */\n  generateInternalStream: function (options) {\n    var worker,\n        opts = {};\n\n    try {\n      opts = utils.extend(options || {}, {\n        streamFiles: false,\n        compression: \"STORE\",\n        compressionOptions: null,\n        type: \"\",\n        platform: \"DOS\",\n        comment: null,\n        mimeType: 'application/zip',\n        encodeFileName: utf8.utf8encode\n      });\n      opts.type = opts.type.toLowerCase();\n      opts.compression = opts.compression.toUpperCase(); // \"binarystring\" is prefered but the internals use \"string\".\n\n      if (opts.type === \"binarystring\") {\n        opts.type = \"string\";\n      }\n\n      if (!opts.type) {\n        throw new Error(\"No output type specified.\");\n      }\n\n      utils.checkSupport(opts.type); // accept nodejs `process.platform`\n\n      if (opts.platform === 'darwin' || opts.platform === 'freebsd' || opts.platform === 'linux' || opts.platform === 'sunos') {\n        opts.platform = \"UNIX\";\n      }\n\n      if (opts.platform === 'win32') {\n        opts.platform = \"DOS\";\n      }\n\n      var comment = opts.comment || this.comment || \"\";\n      worker = generate.generateWorker(this, opts, comment);\n    } catch (e) {\n      worker = new GenericWorker(\"error\");\n      worker.error(e);\n    }\n\n    return new StreamHelper(worker, opts.type || \"string\", opts.mimeType);\n  },\n\n  /**\n   * Generate the complete zip file asynchronously.\n   * @see generateInternalStream\n   */\n  generateAsync: function (options, onUpdate) {\n    return this.generateInternalStream(options).accumulate(onUpdate);\n  },\n\n  /**\n   * Generate the complete zip file asynchronously.\n   * @see generateInternalStream\n   */\n  generateNodeStream: function (options, onUpdate) {\n    options = options || {};\n\n    if (!options.type) {\n      options.type = \"nodebuffer\";\n    }\n\n    return this.generateInternalStream(options).toNodejsStream(onUpdate);\n  }\n};\nmodule.exports = out;","map":{"version":3,"sources":["D:/Development/Work/CENOS/cenos-ui/node_modules/vtk.js/node_modules/jszip/lib/object.js"],"names":["utf8","require","utils","GenericWorker","StreamHelper","defaults","CompressedObject","ZipObject","generate","nodejsUtils","NodejsStreamInputAdapter","fileAdd","name","data","originalOptions","dataType","getTypeOf","parent","o","extend","date","Date","compression","toUpperCase","unixPermissions","parseInt","dir","dosPermissions","forceTrailingSlash","createFolders","parentFolder","folderAdd","call","isUnicodeString","binary","base64","isCompressedEmpty","uncompressedSize","length","zipObjectContent","isNode","isStream","prepareContent","optimizedBinaryString","object","files","path","slice","substring","lastSlash","lastIndexOf","isRegExp","Object","prototype","toString","out","load","Error","forEach","cb","filename","relativePath","file","hasOwnProperty","root","filter","search","result","entry","push","arguments","regexp","test","obj","folder","arg","newFolder","ret","clone","remove","kids","i","options","generateInternalStream","worker","opts","streamFiles","compressionOptions","type","platform","comment","mimeType","encodeFileName","utf8encode","toLowerCase","checkSupport","generateWorker","e","error","generateAsync","onUpdate","accumulate","generateNodeStream","toNodejsStream","module","exports"],"mappings":"AAAA;;AACA,IAAIA,IAAI,GAAGC,OAAO,CAAC,QAAD,CAAlB;;AACA,IAAIC,KAAK,GAAGD,OAAO,CAAC,SAAD,CAAnB;;AACA,IAAIE,aAAa,GAAGF,OAAO,CAAC,wBAAD,CAA3B;;AACA,IAAIG,YAAY,GAAGH,OAAO,CAAC,uBAAD,CAA1B;;AACA,IAAII,QAAQ,GAAGJ,OAAO,CAAC,YAAD,CAAtB;;AACA,IAAIK,gBAAgB,GAAGL,OAAO,CAAC,oBAAD,CAA9B;;AACA,IAAIM,SAAS,GAAGN,OAAO,CAAC,aAAD,CAAvB;;AACA,IAAIO,QAAQ,GAAGP,OAAO,CAAC,YAAD,CAAtB;;AACA,IAAIQ,WAAW,GAAGR,OAAO,CAAC,eAAD,CAAzB;;AACA,IAAIS,wBAAwB,GAAGT,OAAO,CAAC,mCAAD,CAAtC;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAIU,OAAO,GAAG,UAASC,IAAT,EAAeC,IAAf,EAAqBC,eAArB,EAAsC;AAChD;AACA,MAAIC,QAAQ,GAAGb,KAAK,CAACc,SAAN,CAAgBH,IAAhB,CAAf;AAAA,MACII,MADJ;AAIA;A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B;AACfN,MAAAA,OAAO,CAACM,IAAR,GAAe,YAAf;AACH;;AACD,WAAO,KAAKL,sBAAL,CAA4BD,OAA5B,EAAqCqB,cAArC,CAAoDH,QAApD,CAAP;AACH;AA9NK,CAAV;AAgOAI,MAAM,CAACC,OAAP,GAAiBlD,GAAjB","sourcesContent":["'use strict';\nvar utf8 = require('./utf8');\nvar utils = require('./utils');\nvar GenericWorker = require('./stream/GenericWorker');\nvar StreamHelper = require('./stream/StreamHelper');\nvar defaults = require('./defaults');\nvar CompressedObject = require('./compressedObject');\nvar ZipObject = require('./zipObject');\nvar generate = require(\"./generate\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar NodejsStreamInputAdapter = require(\"./nodejs/NodejsStreamInputAdapter\");\n\n\n/**\n * Add a file in the current folder.\n * @private\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file\n * @param {Object} originalOptions the options of the file\n * @return {Object} the new file.\n */\nvar fileAdd = function(name, data, originalOptions) {\n    // be sure sub folders exist\n    var dataType = utils.getTypeOf(data),\n        parent;\n\n\n    /*\n     * Correct options.\n     */\n\n    var o = utils.extend(originalOptions || {}, defaults);\n    o.date = o.date || new Date();\n    if (o.compression !== null) {\n        o.compression = o.compression.toUpperCase();\n    }\n\n    if (typeof o.unixPermissions === \"string\") {\n        o.unixPermissions = parseInt(o.unixPermissions, 8);\n    }\n\n    // UNX_IFDIR  0040000 see zipinfo.c\n    if (o.unixPermissions && (o.unixPermissions & 0x4000)) {\n        o.dir = true;\n    }\n    // Bit 4    Directory\n    if (o.dosPermissions && (o.dosPermissions & 0x0010)) {\n        o.dir = true;\n    }\n\n    if (o.dir) {\n        name = forceTrailingSlash(name);\n    }\n    if (o.createFolders && (parent = parentFolder(name))) {\n        folderAdd.call(this, parent, true);\n    }\n\n    var isUnicodeString = dataType === \"string\" && o.binary === false && o.base64 === false;\n    if (!originalOptions || typeof originalOptions.binary === \"undefined\") {\n        o.binary = !isUnicodeString;\n    }\n\n\n    var isCompressedEmpty = (data instanceof CompressedObject) && data.uncompressedSize === 0;\n\n    if (isCompressedEmpty || o.dir || !data || data.length === 0) {\n        o.base64 = false;\n        o.binary = true;\n        data = \"\";\n        o.compression = \"STORE\";\n        dataType = \"string\";\n    }\n\n    /*\n     * Convert content to fit.\n     */\n\n    var zipObjectContent = null;\n    if (data instanceof CompressedObject || data instanceof GenericWorker) {\n        zipObjectContent = data;\n    } else if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n        zipObjectContent = new NodejsStreamInputAdapter(name, data);\n    } else {\n        zipObjectContent = utils.prepareContent(name, data, o.binary, o.optimizedBinaryString, o.base64);\n    }\n\n    var object = new ZipObject(name, zipObjectContent, o);\n    this.files[name] = object;\n    /*\n    TODO: we can't throw an exception because we have async promises\n    (we can have a promise of a Date() for example) but returning a\n    promise is useless because file(name, data) returns the JSZip\n    object for chaining. Should we break that to allow the user\n    to catch the error ?\n\n    return external.Promise.resolve(zipObjectContent)\n    .then(function () {\n        return object;\n    });\n    */\n};\n\n/**\n * Find the parent folder of the path.\n * @private\n * @param {string} path the path to use\n * @return {string} the parent folder, or \"\"\n */\nvar parentFolder = function (path) {\n    if (path.slice(-1) === '/') {\n        path = path.substring(0, path.length - 1);\n    }\n    var lastSlash = path.lastIndexOf('/');\n    return (lastSlash > 0) ? path.substring(0, lastSlash) : \"\";\n};\n\n/**\n * Returns the path with a slash at the end.\n * @private\n * @param {String} path the path to check.\n * @return {String} the path with a trailing slash.\n */\nvar forceTrailingSlash = function(path) {\n    // Check the name ends with a /\n    if (path.slice(-1) !== \"/\") {\n        path += \"/\"; // IE doesn't like substr(-1)\n    }\n    return path;\n};\n\n/**\n * Add a (sub) folder in the current folder.\n * @private\n * @param {string} name the folder's name\n * @param {boolean=} [createFolders] If true, automatically create sub\n *  folders. Defaults to false.\n * @return {Object} the new folder.\n */\nvar folderAdd = function(name, createFolders) {\n    createFolders = (typeof createFolders !== 'undefined') ? createFolders : defaults.createFolders;\n\n    name = forceTrailingSlash(name);\n\n    // Does this folder already exist?\n    if (!this.files[name]) {\n        fileAdd.call(this, name, null, {\n            dir: true,\n            createFolders: createFolders\n        });\n    }\n    return this.files[name];\n};\n\n/**\n* Cross-window, cross-Node-context regular expression detection\n* @param  {Object}  object Anything\n* @return {Boolean}        true if the object is a regular expression,\n* false otherwise\n*/\nfunction isRegExp(object) {\n    return Object.prototype.toString.call(object) === \"[object RegExp]\";\n}\n\n// return the actual prototype of JSZip\nvar out = {\n    /**\n     * @see loadAsync\n     */\n    load: function() {\n        throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n    },\n\n\n    /**\n     * Call a callback function for each entry at this folder level.\n     * @param {Function} cb the callback function:\n     * function (relativePath, file) {...}\n     * It takes 2 arguments : the relative path and the file.\n     */\n    forEach: function(cb) {\n        var filename, relativePath, file;\n        for (filename in this.files) {\n            if (!this.files.hasOwnProperty(filename)) {\n                continue;\n            }\n            file = this.files[filename];\n            relativePath = filename.slice(this.root.length, filename.length);\n            if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root\n                cb(relativePath, file); // TODO reverse the parameters ? need to be clean AND consistent with the filter search fn...\n            }\n        }\n    },\n\n    /**\n     * Filter nested files/folders with the specified function.\n     * @param {Function} search the predicate to use :\n     * function (relativePath, file) {...}\n     * It takes 2 arguments : the relative path and the file.\n     * @return {Array} An array of matching elements.\n     */\n    filter: function(search) {\n        var result = [];\n        this.forEach(function (relativePath, entry) {\n            if (search(relativePath, entry)) { // the file matches the function\n                result.push(entry);\n            }\n\n        });\n        return result;\n    },\n\n    /**\n     * Add a file to the zip file, or search a file.\n     * @param   {string|RegExp} name The name of the file to add (if data is defined),\n     * the name of the file to find (if no data) or a regex to match files.\n     * @param   {String|ArrayBuffer|Uint8Array|Buffer} data  The file data, either raw or base64 encoded\n     * @param   {Object} o     File options\n     * @return  {JSZip|Object|Array} this JSZip object (when adding a file),\n     * a file (when searching by string) or an array of files (when searching by regex).\n     */\n    file: function(name, data, o) {\n        if (arguments.length === 1) {\n            if (isRegExp(name)) {\n                var regexp = name;\n                return this.filter(function(relativePath, file) {\n                    return !file.dir && regexp.test(relativePath);\n                });\n            }\n            else { // text\n                var obj = this.files[this.root + name];\n                if (obj && !obj.dir) {\n                    return obj;\n                } else {\n                    return null;\n                }\n            }\n        }\n        else { // more than one argument : we have data !\n            name = this.root + name;\n            fileAdd.call(this, name, data, o);\n        }\n        return this;\n    },\n\n    /**\n     * Add a directory to the zip file, or search.\n     * @param   {String|RegExp} arg The name of the directory to add, or a regex to search folders.\n     * @return  {JSZip} an object with the new directory as the root, or an array containing matching folders.\n     */\n    folder: function(arg) {\n        if (!arg) {\n            return this;\n        }\n\n        if (isRegExp(arg)) {\n            return this.filter(function(relativePath, file) {\n                return file.dir && arg.test(relativePath);\n            });\n        }\n\n        // else, name is a new folder\n        var name = this.root + arg;\n        var newFolder = folderAdd.call(this, name);\n\n        // Allow chaining by returning a new object with this folder as the root\n        var ret = this.clone();\n        ret.root = newFolder.name;\n        return ret;\n    },\n\n    /**\n     * Delete a file, or a directory and all sub-files, from the zip\n     * @param {string} name the name of the file to delete\n     * @return {JSZip} this JSZip object\n     */\n    remove: function(name) {\n        name = this.root + name;\n        var file = this.files[name];\n        if (!file) {\n            // Look for any folders\n            if (name.slice(-1) !== \"/\") {\n                name += \"/\";\n            }\n            file = this.files[name];\n        }\n\n        if (file && !file.dir) {\n            // file\n            delete this.files[name];\n        } else {\n            // maybe a folder, delete recursively\n            var kids = this.filter(function(relativePath, file) {\n                return file.name.slice(0, name.length) === name;\n            });\n            for (var i = 0; i < kids.length; i++) {\n                delete this.files[kids[i].name];\n            }\n        }\n\n        return this;\n    },\n\n    /**\n     * Generate the complete zip file\n     * @param {Object} options the options to generate the zip file :\n     * - compression, \"STORE\" by default.\n     * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n     * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file\n     */\n    generate: function(options) {\n        throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n    },\n\n    /**\n     * Generate the complete zip file as an internal stream.\n     * @param {Object} options the options to generate the zip file :\n     * - compression, \"STORE\" by default.\n     * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n     * @return {StreamHelper} the streamed zip file.\n     */\n    generateInternalStream: function(options) {\n      var worker, opts = {};\n      try {\n          opts = utils.extend(options || {}, {\n              streamFiles: false,\n              compression: \"STORE\",\n              compressionOptions : null,\n              type: \"\",\n              platform: \"DOS\",\n              comment: null,\n              mimeType: 'application/zip',\n              encodeFileName: utf8.utf8encode\n          });\n\n          opts.type = opts.type.toLowerCase();\n          opts.compression = opts.compression.toUpperCase();\n\n          // \"binarystring\" is prefered but the internals use \"string\".\n          if(opts.type === \"binarystring\") {\n            opts.type = \"string\";\n          }\n\n          if (!opts.type) {\n            throw new Error(\"No output type specified.\");\n          }\n\n          utils.checkSupport(opts.type);\n\n          // accept nodejs `process.platform`\n          if(\n              opts.platform === 'darwin' ||\n              opts.platform === 'freebsd' ||\n              opts.platform === 'linux' ||\n              opts.platform === 'sunos'\n          ) {\n              opts.platform = \"UNIX\";\n          }\n          if (opts.platform === 'win32') {\n              opts.platform = \"DOS\";\n          }\n\n          var comment = opts.comment || this.comment || \"\";\n          worker = generate.generateWorker(this, opts, comment);\n      } catch (e) {\n        worker = new GenericWorker(\"error\");\n        worker.error(e);\n      }\n      return new StreamHelper(worker, opts.type || \"string\", opts.mimeType);\n    },\n    /**\n     * Generate the complete zip file asynchronously.\n     * @see generateInternalStream\n     */\n    generateAsync: function(options, onUpdate) {\n        return this.generateInternalStream(options).accumulate(onUpdate);\n    },\n    /**\n     * Generate the complete zip file asynchronously.\n     * @see generateInternalStream\n     */\n    generateNodeStream: function(options, onUpdate) {\n        options = options || {};\n        if (!options.type) {\n            options.type = \"nodebuffer\";\n        }\n        return this.generateInternalStream(options).toNodejsStream(onUpdate);\n    }\n};\nmodule.exports = out;\n"]},"metadata":{},"sourceType":"script"}