[
  {
    "path": ".codeclimate.yml",
    "content": "---\nengines:\n  duplication:\n    enabled: true\n    config:\n      languages:\n      - javascript\n  eslint:\n    enabled: true\n  fixme:\n    enabled: true\nratings:\n  paths:\n  - \"lib/*.js\"\nexclude_paths:\n- \"dist/*\"\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nend_of_line = lf\ninsert_final_newline = true\ncharset = utf-8\nindent_style = space\nindent_size = 4\n"
  },
  {
    "path": ".eslintrc.js",
    "content": "\"use strict\";\n\nmodule.exports = {\n    \"env\": {\n        \"browser\": true,\n        \"commonjs\": true,\n        \"es2021\": true,\n        \"node\": true\n    },\n    \"extends\": \"eslint:recommended\",\n    \"parserOptions\": {\n        \"ecmaVersion\": \"latest\"\n    },\n    \"ignorePatterns\": [\"vendor/*.js\", \"dist/*.js\", \"test/jquery-1.8.3.min.js\"],\n    \"rules\": {\n        \"indent\": [\n            \"error\",\n            4\n        ],\n        \"linebreak-style\": [\n            \"error\",\n            \"unix\"\n        ],\n        \"quotes\": [\n            \"error\",\n            \"double\"\n        ],\n        \"semi\": [\n            \"error\",\n            \"always\"\n        ],\n        \"curly\": \"error\",\n        \"eqeqeq\": \"error\",\n        \"no-new\": \"error\",\n        \"no-caller\": \"error\",\n        \"guard-for-in\": \"error\",\n        \"no-extend-native\": \"error\",\n        \"strict\": [\n            \"error\",\n            \"global\"\n        ],\n    }\n};\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "github: Stuk\n"
  },
  {
    "path": ".github/actions/setup/action.yml",
    "content": "name: Set up workspace\ndescription: Sets up the workspace by installing Node.js and dependencies.\n\ninputs:\n  node-version:\n    description: The Node.js version to install.\n    required: false\n    default: \"lts/*\"\n\nruns:\n  using: composite\n  steps:\n    - name: Install Node.js\n      uses: actions/setup-node@v4\n      with:\n          node-version: ${{ inputs.node-version }}\n          cache: npm\n\n    - name: Install dependencies\n      # Because the lockfile is not compatible between all supported Node.js versions we need to run `npm install`.\n      # When support for older versions of Node.js is dropped, this can be changed to `npm ci`.\n      run: npm install\n      shell: bash\n"
  },
  {
    "path": ".github/workflows/benchmark.yml",
    "content": "name: Benchmark\non:\n  push:\n    branches: [main]\njobs:\n  benchmark:\n    name: Run benchmark\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Set up workspace\n        uses: ./.github/actions/setup\n\n      - name: Install browsers\n        run: npx playwright install --with-deps\n\n      - name: Run benchmark\n        run: npm run benchmark | tee benchmark.txt\n\n      - name: Download previous benchmark data\n        uses: actions/cache@v4\n        with:\n          path: ./cache\n          key: ${{ runner.os }}-benchmark\n\n      - name: Store benchmark result\n        uses: benchmark-action/github-action-benchmark@v1\n        with:\n          tool: benchmarkjs\n          output-file-path: benchmark.txt\n          external-data-json-path: ./cache/benchmark-data.json\n          github-token: ${{ secrets.GITHUB_TOKEN }}\n          alert-threshold: 150%\n          comment-on-alert: true\n          fail-on-alert: true\n          alert-comment-cc-users: \"@Stuk\"\n"
  },
  {
    "path": ".github/workflows/main.yml",
    "content": "name: CI\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\njobs:\n  lint:\n    name: Lint\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Set up workspace\n        uses: ./.github/actions/setup\n\n      - name: Run linter\n        run: npm run lint\n\n  test-node:\n    name: Test on Node.js ${{ matrix.node-version }}\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        node-version: [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Set up workspace\n        uses: ./.github/actions/setup\n        with:\n          node-version: ${{ matrix.node-version }}\n\n      - name: Run tests\n        run: npm run test-node\n\n  test-browser:\n    name: Test in browser\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v4\n\n      - name: Set up workspace\n        uses: ./.github/actions/setup\n\n      - name: Install browsers\n        run: npx playwright install --with-deps\n\n      - name: Run tests\n        run: npm run test-browser\n\n"
  },
  {
    "path": ".gitignore",
    "content": "_site\n.c9revisions\n.DS_Store\n.jekyll-metadata\n*~\nnode_modules\nsauce_connect.log\n"
  },
  {
    "path": ".npmignore",
    "content": "_config.yml\nbower.json\ncomponent.json\ndocs\ndocumentation\nGruntfile.js\nindex.html\ntest\n"
  },
  {
    "path": "CHANGES.md",
    "content": "---\ntitle: Changelog\nlayout: default\nsection: main\n---\n\n### v3.10.1 2022-08-02\n\n- Add sponsorship files.\n    + If you appreciate the time spent maintaining JSZip then I would really appreciate [your sponsorship](https://github.com/sponsors/Stuk).\n- Consolidate metadata types and expose OnUpdateCallback [#851](https://github.com/Stuk/jszip/pull/851) and [#852](https://github.com/Stuk/jszip/pull/852)\n- use `const` instead `var` in example from README.markdown [#828](https://github.com/Stuk/jszip/pull/828)\n- Switch manual download link to HTTPS [#839](https://github.com/Stuk/jszip/pull/839)\n\nInternals:\n\n- Replace jshint with eslint [#842](https://github.com/Stuk/jszip/pull/842)\n- Add performance tests [#834](https://github.com/Stuk/jszip/pull/834)\n\n### v3.10.0 2022-05-20\n\n- Change setimmediate dependency to more efficient one. Fixes https://github.com/Stuk/jszip/issues/617 (see [#829](https://github.com/Stuk/jszip/pull/829))\n- Update types of `currentFile` metadata to include `null` (see [#826](https://github.com/Stuk/jszip/pull/826))\n\n### v3.9.1 2022-04-06\n\n- Fix recursive definition of `InputFileFormat` introduced in 3.9.0.\n\n### v3.9.0 2022-04-04\n\n- Update types JSZip#loadAsync to accept a promise for data, and remove arguments from `new JSZip()` (see [#752](https://github.com/Stuk/jszip/pull/752))\n- Update types for `compressionOptions` to JSZipFileOptions and JSZipGeneratorOptions (see [#722](https://github.com/Stuk/jszip/pull/722))\n- Add types for `generateInternalStream` (see [#774](https://github.com/Stuk/jszip/pull/774))\n\n### v3.8.0 2022-03-30\n\n- Santize filenames when files are loaded with `loadAsync`, to avoid [\"zip slip\" attacks](https://snyk.io/research/zip-slip-vulnerability). The original filename is available on each zip entry as `unsafeOriginalName`. See the [documentation](https://stuk.github.io/jszip/documentation/api_jszip/load_async.html). Many thanks to McCaulay Hudson for reporting.\n\n### v3.7.1 2021-08-05\n\n- Fix build of `dist` files.\n    + Note: this version ensures the changes from 3.7.0 are actually included in the `dist` files. Thanks to Evan W for reporting.\n\n### v3.7.0 2021-07-23\n\n- Fix: Use a null prototype object for this.files  (see [#766](https://github.com/Stuk/jszip/pull/766))\n    + This change might break existing code if it uses prototype methods on the `.files` property of a zip object, for example `zip.files.toString()`. This approach is taken to prevent files in the zip overriding object methods that would exist on a normal object.\n\n### v3.6.0 2021-02-09\n\n- Fix: redirect main to dist on browsers (see [#742](https://github.com/Stuk/jszip/pull/742))\n- Fix duplicate require DataLengthProbe, utils (see [#734](https://github.com/Stuk/jszip/pull/734))\n- Fix small error in read_zip.md (see [#703](https://github.com/Stuk/jszip/pull/703))\n\n### v3.5.0 2020-05-31\n\n- Fix 'End of data reached' error when file extra field is invalid (see [#544](https://github.com/Stuk/jszip/pull/544)).\n- Typescript definitions: Add null to return types of functions that may return null (see [#669](https://github.com/Stuk/jszip/pull/669)).\n- Typescript definitions: Correct nodeStream's type (see [#682](https://github.com/Stuk/jszip/pull/682))\n- Typescript definitions: Add string output type (see [#666](https://github.com/Stuk/jszip/pull/666))\n\n### v3.4.0 2020-04-19\n\n- Add Typescript type definitions (see [#601](https://github.com/Stuk/jszip/pull/601)).\n\n### v3.3.0 2020-04-1\n\n- Change browser module resolution to support Angular packager (see [#614](https://github.com/Stuk/jszip/pull/614)).\n\n### v3.2.2 2019-07-04\n- No public changes, but a number of testing dependencies have been updated.\n- Tested browsers are now: Internet Explorer 11, Chrome (most recent) and Firefox (most recent). Other browsers (specifically Safari) are still supported however testing them on Saucelabs is broken and so they were removed from the test matrix.\n\n### v3.2.1 2019-03-22\n- Corrected built dist files\n\n### v3.2.0 2019-02-21\n- Update dependencies to reduce bundle size (see [#532](https://github.com/Stuk/jszip/pull/532)).\n- Fix deprecated Buffer constructor usage and add safeguards (see [#506](https://github.com/Stuk/jszip/pull/506)).\n\n### v3.1.5 2017-11-09\n- Fix IE11 memory leak (see [#429](https://github.com/Stuk/jszip/pull/429)).\n- Handle 2 nodejs deprecations (see [#459](https://github.com/Stuk/jszip/pull/459)).\n- Improve the \"unsupported format\" error message (see [#461](https://github.com/Stuk/jszip/pull/461)).\n- Improve webworker compatibility (see [#468](https://github.com/Stuk/jszip/pull/468)).\n- Fix nodejs 0.10 compatibility (see [#480](https://github.com/Stuk/jszip/pull/480)).\n- Improve the error without type in async() (see [#481](https://github.com/Stuk/jszip/pull/481)).\n\n### v3.1.4 2017-08-24\n- consistently use our own utils object for inheritance (see [#395](https://github.com/Stuk/jszip/pull/395)).\n- lower the memory consumption in `generate*` with a lot of files (see [#449](https://github.com/Stuk/jszip/pull/449)).\n\n### v3.1.3 2016-10-06\n- instanceof failing in window / iframe contexts (see [#350](https://github.com/Stuk/jszip/pull/350)).\n- remove a copy with blob output (see [#357](https://github.com/Stuk/jszip/pull/357)).\n- fix crc32 check for empty entries (see [#358](https://github.com/Stuk/jszip/pull/358)).\n- fix the base64 error message with data uri (see [#359](https://github.com/Stuk/jszip/pull/359)).\n\n### v3.1.2 2016-08-23\n- fix support of nodejs `process.platform` in `generate*` methods (see [#335](https://github.com/Stuk/jszip/pull/335)).\n- improve browserify/webpack support (see [#333](https://github.com/Stuk/jszip/pull/333)).\n- partial support of a promise of text (see [#337](https://github.com/Stuk/jszip/pull/337)).\n- fix streamed zip files containing folders (see [#342](https://github.com/Stuk/jszip/pull/342)).\n\n### v3.1.1 2016-08-08\n- Use a hard-coded JSZip.version, fix an issue with webpack (see [#328](https://github.com/Stuk/jszip/pull/328)).\n\n### v3.1.0 2016-08-03\n- utils.delay: use macro tasks instead of micro tasks (see [#288](https://github.com/Stuk/jszip/pull/288)).\n- Harden base64 decode (see [#316](https://github.com/Stuk/jszip/pull/316)).\n- Add JSZip.version and the version in the header (see [#317](https://github.com/Stuk/jszip/pull/317)).\n- Support Promise(Blob) (see [#318](https://github.com/Stuk/jszip/pull/318)).\n- Change JSZip.external.Promise implementation (see [#321](https://github.com/Stuk/jszip/pull/321)).\n- Update pako to v1.0.2 to fix a DEFLATE bug (see [#322](https://github.com/Stuk/jszip/pull/322)).\n\n### v3.0.0 2016-04-13\nThis release changes a lot of methods, please see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html).\n\n- replace sync getters and `generate()` with async methods (see [#195](https://github.com/Stuk/jszip/pull/195)).\n- support nodejs streams (in `file()` and `generateAsync()`).\n- support Blob and Promise in `file()` and `loadAsync()` (see [#275](https://github.com/Stuk/jszip/pull/275)).\n- add `support.nodestream`.\n- zip.filter: remove the defensive copy.\n- remove the deprecated API (see [#253](https://github.com/Stuk/jszip/pull/253)).\n- `type` is now mandatory in `generateAsync()`.\n- change the createFolders default value (now `true`).\n- Dates: use UTC instead of the local timezone.\n- Add `base64` and `array` as possible output type.\n- Add a forEach method.\n- Drop node 0.8 support (see [#270](https://github.com/Stuk/jszip/pull/270)).\n\n### v2.6.1 2016-07-28\n- update pako to v1.0.2 to fix a DEFLATE bug (see [#322](https://github.com/Stuk/jszip/pull/322)).\n\n### v2.6.0 2016-03-23\n- publish `dist/` files in the npm package (see [#225](https://github.com/Stuk/jszip/pull/225)).\n- update pako to v1.0.0 (see [#261](https://github.com/Stuk/jszip/pull/261)).\n- add support of Array in JSZip#load (see [#252](https://github.com/Stuk/jszip/pull/252)).\n- improve file name / comment encoding support (see [#211](https://github.com/Stuk/jszip/pull/211)).\n- handle prepended data (see [#266](https://github.com/Stuk/jszip/pull/266)).\n- improve platform coverage in tests (see [#233](https://github.com/Stuk/jszip/pull/233) and [#269](https://github.com/Stuk/jszip/pull/269)).\n\n### v2.5.0 2015-03-10\n- add support for custom mime-types (see [#199](https://github.com/Stuk/jszip/issues/199)).\n- add an option to set the DEFLATE level (see [#201](https://github.com/Stuk/jszip/issues/201)).\n- improve the error message with corrupted zip (see [#202](https://github.com/Stuk/jszip/issues/202)).\n- add support for UNIX / DOS permissions (see [#200](https://github.com/Stuk/jszip/issues/200) and [#205](https://github.com/Stuk/jszip/issues/205)).\n\n### v2.4.0 2014-07-24\n- update pako to 0.2.5 (see [#156](https://github.com/Stuk/jszip/issues/156)).\n- make JSZip work in a Firefox addon context (see [#151](https://github.com/Stuk/jszip/issues/151)).\n- add an option (`createFolders`) to control the subfolder generation (see [#154](https://github.com/Stuk/jszip/issues/154)).\n- allow `Buffer` polyfill in the browser (see [#139](https://github.com/Stuk/jszip/issues/139)).\n\n### v2.3.0 2014-06-18\n- don't generate subfolders (see [#130](https://github.com/Stuk/jszip/issues/130)).\n- add comment support (see [#134](https://github.com/Stuk/jszip/issues/134)).\n- on `ZipObject#options`, the attributes `date` and `dir` have been deprecated and are now on `ZipObject` (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).\n- on `ZipObject#options`, the attributes `base64` and `binary` have been deprecated (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).\n- deprecate internal functions exposed in the public API (see [#123](https://github.com/Stuk/jszip/issues/123)).\n- improve UTF-8 support (see [#142](https://github.com/Stuk/jszip/issues/142)).\n\n### v2.2.2, 2014-05-01\n - update pako to v0.2.1, fix an error when decompressing some files (see [#126](https://github.com/Stuk/jszip/issues/126)).\n\n### v2.2.1, 2014-04-23\n - fix unreadable generated file on Windows 8 (see [#112](https://github.com/Stuk/jszip/issues/112)).\n - replace zlibjs with pako.\n\n### v2.2.0, 2014-02-25\n - make the `new` operator optional before the `JSZip` constructor (see [#93](https://github.com/Stuk/jszip/pull/93)).\n - update zlibjs to v0.2.0.\n\n### v2.1.1, 2014-02-13\n - use the npm package for zlib.js instead of the github url.\n\n### v2.1.0, 2014-02-06\n - split the files and use Browserify to generate the final file (see [#74](https://github.com/Stuk/jszip/pull/74))\n - packaging change : instead of 4 files (jszip.js, jszip-load.js, jszip-inflate.js, jszip-deflate.js) we now have 2 files : dist/jszip.js and dist/jszip.min.js\n - add component/bower support\n - rename variable: 'byte' is a reserved word (see [#76](https://github.com/Stuk/jszip/pull/76))\n - add support for the unicode path extra field (see [#82](https://github.com/Stuk/jszip/pull/82))\n - ensure that the generated files have a header with the licenses (see [#80](https://github.com/Stuk/jszip/pull/80))\n\n# v2.0.0, 2013-10-20\n\n - `JSZipBase64` has been renamed to `JSZip.base64`.\n - The `data` attribute on the object returned by `zip.file(name)` has been removed. Use `asText()`, `asBinary()`, `asUint8Array()`, `asArrayBuffer()` or `asNodeBuffer()`.\n\n - [Fix issue with Android browser](https://github.com/Stuk/jszip/pull/60)\n\n - The compression/decompression methods now give their input type with the `compressInputType` and `uncompressInputType` attributes.\n - Lazily decompress data when needed and [improve performance in general](https://github.com/Stuk/jszip/pull/56)\n - [Add support for `Buffer` in Node.js](https://github.com/Stuk/jszip/pull/57).\n - Package for CommonJS/npm.\n\n### v1.0.1, 2013-03-04\n\n - Fixed an issue when generating a compressed zip file with empty files or folders, see #33.\n - With bad data (null or undefined), asText/asBinary/asUint8Array/asArrayBuffer methods now return an empty string, see #36.\n\n# v1.0.0, 2013-02-14\n\n- First release after a long period without version.\n"
  },
  {
    "path": "Gruntfile.js",
    "content": "\"use strict\";\n\nmodule.exports = function(grunt) {\n    var version = require(\"./package.json\").version;\n\n    grunt.initConfig({\n        browserify: {\n            all: {\n                files: {\n                    \"dist/jszip.js\": [\"lib/index.js\"]\n                },\n                options: {\n                    browserifyOptions: {\n                        standalone: \"JSZip\",\n                        transform: [\"package-json-versionify\"],\n                        insertGlobalVars: {\n                            process: undefined,\n                            Buffer: undefined,\n                            __filename: undefined,\n                            __dirname: undefined\n                        },\n                        builtins: false\n                    },\n                    banner: grunt.file.read(\"lib/license_header.js\").replace(/__VERSION__/, version)\n                }\n            }\n        },\n        uglify: {\n            options: {\n                mangle: true,\n                preserveComments: false,\n                banner: grunt.file.read(\"lib/license_header.js\").replace(/__VERSION__/, version)\n            },\n            all: {\n                src: \"dist/jszip.js\",\n                dest: \"dist/jszip.min.js\"\n            }\n        }\n    });\n\n    grunt.loadNpmTasks(\"grunt-browserify\");\n    grunt.loadNpmTasks(\"grunt-contrib-uglify\");\n\n    grunt.registerTask(\"build\", [\"browserify\", \"uglify\"]);\n    grunt.registerTask(\"default\", [\"build\"]);\n};\n"
  },
  {
    "path": "LICENSE.markdown",
    "content": "JSZip is dual licensed. At your choice you may use it under the MIT license *or* the GPLv3\nlicense.\n\nThe MIT License\n===============\n\nCopyright (c) 2009-2016 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n\nGPL version 3\n=============\n\n                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n"
  },
  {
    "path": "README.markdown",
    "content": "JSZip\n=====\n\nA library for creating, reading and editing .zip files with JavaScript, with a\nlovely and simple API.\n\nSee https://stuk.github.io/jszip for all the documentation.\n\n```javascript\nconst zip = new JSZip();\n\nzip.file(\"Hello.txt\", \"Hello World\\n\");\n\nconst img = zip.folder(\"images\");\nimg.file(\"smile.gif\", imgData, {base64: true});\n\nzip.generateAsync({type:\"blob\"}).then(function(content) {\n    // see FileSaver.js\n    saveAs(content, \"example.zip\");\n});\n\n/*\nResults in a zip containing\nHello.txt\nimages/\n    smile.gif\n*/\n```\nLicense\n-------\n\nJSZip is dual-licensed. You may use it under the MIT license *or* the GPLv3\nlicense. See [LICENSE.markdown](LICENSE.markdown).\n"
  },
  {
    "path": "_config.yml",
    "content": "# will be overwritten by github, see https://help.github.com/articles/using-jekyll-with-pages\nlsi: false\nsafe: true\nsource: ./\nincremental: false\nhighlighter: rouge\ngist:\n    noscript: false\n# /overwritten\n\nbaseurl: /jszip\n\nlayouts_dir: ./documentation/_layouts\npermalink: none\nexclude: ['bin', 'README.md', 'node_modules']\n\n\nkramdown:\n    input: GFM\n    hard_wrap: false\ngems:\n    - jekyll-coffeescript\n    - jekyll-paginate\n\n"
  },
  {
    "path": "bower.json",
    "content": "{\n  \"name\": \"jszip\",\n  \"homepage\": \"http://stuartk.com/jszip\",\n  \"authors\": [\n    \"Stuart Knightley <stuart@stuartk.com>\"\n  ],\n  \"description\": \"Create, read and edit .zip files with JavaScript http://stuartk.com/jszip\",\n  \"main\": \"dist/jszip.js\",\n  \"keywords\": [\n    \"zip\",\n    \"deflate\",\n    \"inflate\"\n  ],\n  \"license\": \"MIT or GPLv3\",\n  \"ignore\": [\n    \"**/.*\",\n    \"node_modules\",\n    \"bower_components\",\n    \"test\",\n    \"tests\"\n  ]\n}\n"
  },
  {
    "path": "component.json",
    "content": "{\n  \"name\": \"jszip\",\n  \"repo\": \"Stuk/jszip\",\n  \"description\": \"Create, read and edit .zip files with JavaScript http://stuartk.com/jszip\",\n  \"version\": \"3.2.0\",\n  \"keywords\": [\n    \"zip\",\n    \"deflate\",\n    \"inflate\"\n  ],\n  \"main\": \"dist/jszip.js\",\n  \"license\": \"MIT or GPLv3\",\n  \"scripts\": [\n    \"dist/jszip.js\"\n  ]\n}\n"
  },
  {
    "path": "dist/jszip.js",
    "content": "/*!\n\nJSZip v3.10.1 - A JavaScript class for generating and reading zip files\n<http://stuartk.com/jszip>\n\n(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>\nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n\n(function(f){if(typeof exports===\"object\"&&typeof module!==\"undefined\"){module.exports=f()}else if(typeof define===\"function\"&&define.amd){define([],f)}else{var g;if(typeof window!==\"undefined\"){g=window}else if(typeof global!==\"undefined\"){g=global}else if(typeof self!==\"undefined\"){g=self}else{g=this}g.JSZip = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require==\"function\"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error(\"Cannot find module '\"+o+\"'\");throw f.code=\"MODULE_NOT_FOUND\",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require==\"function\"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){\n\"use strict\";\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\n// private property\nvar _keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n\n// public method for encoding\nexports.encode = function(input) {\n    var output = [];\n    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n    var i = 0, len = input.length, remainingBytes = len;\n\n    var isArray = utils.getTypeOf(input) !== \"string\";\n    while (i < input.length) {\n        remainingBytes = len - i;\n\n        if (!isArray) {\n            chr1 = input.charCodeAt(i++);\n            chr2 = i < len ? input.charCodeAt(i++) : 0;\n            chr3 = i < len ? input.charCodeAt(i++) : 0;\n        } else {\n            chr1 = input[i++];\n            chr2 = i < len ? input[i++] : 0;\n            chr3 = i < len ? input[i++] : 0;\n        }\n\n        enc1 = chr1 >> 2;\n        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n        enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64;\n        enc4 = remainingBytes > 2 ? (chr3 & 63) : 64;\n\n        output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));\n\n    }\n\n    return output.join(\"\");\n};\n\n// public method for decoding\nexports.decode = function(input) {\n    var chr1, chr2, chr3;\n    var enc1, enc2, enc3, enc4;\n    var i = 0, resultIndex = 0;\n\n    var dataUrlPrefix = \"data:\";\n\n    if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {\n        // This is a common error: people give a data url\n        // (data:image/png;base64,iVBOR...) with a {base64: true} and\n        // wonders why things don't work.\n        // We can detect that the string input looks like a data url but we\n        // *can't* be sure it is one: removing everything up to the comma would\n        // be too dangerous.\n        throw new Error(\"Invalid base64 input, it looks like a data url.\");\n    }\n\n    input = input.replace(/[^A-Za-z0-9+/=]/g, \"\");\n\n    var totalLength = input.length * 3 / 4;\n    if(input.charAt(input.length - 1) === _keyStr.charAt(64)) {\n        totalLength--;\n    }\n    if(input.charAt(input.length - 2) === _keyStr.charAt(64)) {\n        totalLength--;\n    }\n    if (totalLength % 1 !== 0) {\n        // totalLength is not an integer, the length does not match a valid\n        // base64 content. That can happen if:\n        // - the input is not a base64 content\n        // - the input is *almost* a base64 content, with a extra chars at the\n        //   beginning or at the end\n        // - the input uses a base64 variant (base64url for example)\n        throw new Error(\"Invalid base64 input, bad content length.\");\n    }\n    var output;\n    if (support.uint8array) {\n        output = new Uint8Array(totalLength|0);\n    } else {\n        output = new Array(totalLength|0);\n    }\n\n    while (i < input.length) {\n\n        enc1 = _keyStr.indexOf(input.charAt(i++));\n        enc2 = _keyStr.indexOf(input.charAt(i++));\n        enc3 = _keyStr.indexOf(input.charAt(i++));\n        enc4 = _keyStr.indexOf(input.charAt(i++));\n\n        chr1 = (enc1 << 2) | (enc2 >> 4);\n        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n        chr3 = ((enc3 & 3) << 6) | enc4;\n\n        output[resultIndex++] = chr1;\n\n        if (enc3 !== 64) {\n            output[resultIndex++] = chr2;\n        }\n        if (enc4 !== 64) {\n            output[resultIndex++] = chr3;\n        }\n\n    }\n\n    return output;\n};\n\n},{\"./support\":30,\"./utils\":32}],2:[function(require,module,exports){\n\"use strict\";\n\nvar external = require(\"./external\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar DataLengthProbe = require(\"./stream/DataLengthProbe\");\n\n/**\n * Represent a compressed object, with everything needed to decompress it.\n * @constructor\n * @param {number} compressedSize the size of the data compressed.\n * @param {number} uncompressedSize the size of the data after decompression.\n * @param {number} crc32 the crc32 of the decompressed file.\n * @param {object} compression the type of compression, see lib/compressions.js.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.\n */\nfunction CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {\n    this.compressedSize = compressedSize;\n    this.uncompressedSize = uncompressedSize;\n    this.crc32 = crc32;\n    this.compression = compression;\n    this.compressedContent = data;\n}\n\nCompressedObject.prototype = {\n    /**\n     * Create a worker to get the uncompressed content.\n     * @return {GenericWorker} the worker.\n     */\n    getContentWorker: function () {\n        var worker = new DataWorker(external.Promise.resolve(this.compressedContent))\n            .pipe(this.compression.uncompressWorker())\n            .pipe(new DataLengthProbe(\"data_length\"));\n\n        var that = this;\n        worker.on(\"end\", function () {\n            if (this.streamInfo[\"data_length\"] !== that.uncompressedSize) {\n                throw new Error(\"Bug : uncompressed data size mismatch\");\n            }\n        });\n        return worker;\n    },\n    /**\n     * Create a worker to get the compressed content.\n     * @return {GenericWorker} the worker.\n     */\n    getCompressedWorker: function () {\n        return new DataWorker(external.Promise.resolve(this.compressedContent))\n            .withStreamInfo(\"compressedSize\", this.compressedSize)\n            .withStreamInfo(\"uncompressedSize\", this.uncompressedSize)\n            .withStreamInfo(\"crc32\", this.crc32)\n            .withStreamInfo(\"compression\", this.compression)\n        ;\n    }\n};\n\n/**\n * Chain the given worker with other workers to compress the content with the\n * given compression.\n * @param {GenericWorker} uncompressedWorker the worker to pipe.\n * @param {Object} compression the compression object.\n * @param {Object} compressionOptions the options to use when compressing.\n * @return {GenericWorker} the new worker compressing the content.\n */\nCompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {\n    return uncompressedWorker\n        .pipe(new Crc32Probe())\n        .pipe(new DataLengthProbe(\"uncompressedSize\"))\n        .pipe(compression.compressWorker(compressionOptions))\n        .pipe(new DataLengthProbe(\"compressedSize\"))\n        .withStreamInfo(\"compression\", compression);\n};\n\nmodule.exports = CompressedObject;\n\n},{\"./external\":6,\"./stream/Crc32Probe\":25,\"./stream/DataLengthProbe\":26,\"./stream/DataWorker\":27}],3:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nexports.STORE = {\n    magic: \"\\x00\\x00\",\n    compressWorker : function () {\n        return new GenericWorker(\"STORE compression\");\n    },\n    uncompressWorker : function () {\n        return new GenericWorker(\"STORE decompression\");\n    }\n};\nexports.DEFLATE = require(\"./flate\");\n\n},{\"./flate\":7,\"./stream/GenericWorker\":28}],4:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"./utils\");\n\n/**\n * The following functions come from pako, from pako/lib/zlib/crc32.js\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n    var c, table = [];\n\n    for(var n =0; n < 256; n++){\n        c = n;\n        for(var k =0; k < 8; k++){\n            c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n        }\n        table[n] = c;\n    }\n\n    return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n    var t = crcTable, end = pos + len;\n\n    crc = crc ^ (-1);\n\n    for (var i = pos; i < end; i++ ) {\n        crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n    }\n\n    return (crc ^ (-1)); // >>> 0;\n}\n\n// That's all for the pako functions.\n\n/**\n * Compute the crc32 of a string.\n * This is almost the same as the function crc32, but for strings. Using the\n * same function for the two use cases leads to horrible performances.\n * @param {Number} crc the starting value of the crc.\n * @param {String} str the string to use.\n * @param {Number} len the length of the string.\n * @param {Number} pos the starting position for the crc32 computation.\n * @return {Number} the computed crc32.\n */\nfunction crc32str(crc, str, len, pos) {\n    var t = crcTable, end = pos + len;\n\n    crc = crc ^ (-1);\n\n    for (var i = pos; i < end; i++ ) {\n        crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];\n    }\n\n    return (crc ^ (-1)); // >>> 0;\n}\n\nmodule.exports = function crc32wrapper(input, crc) {\n    if (typeof input === \"undefined\" || !input.length) {\n        return 0;\n    }\n\n    var isArray = utils.getTypeOf(input) !== \"string\";\n\n    if(isArray) {\n        return crc32(crc|0, input, input.length, 0);\n    } else {\n        return crc32str(crc|0, input, input.length, 0);\n    }\n};\n\n},{\"./utils\":32}],5:[function(require,module,exports){\n\"use strict\";\nexports.base64 = false;\nexports.binary = false;\nexports.dir = false;\nexports.createFolders = true;\nexports.date = null;\nexports.compression = null;\nexports.compressionOptions = null;\nexports.comment = null;\nexports.unixPermissions = null;\nexports.dosPermissions = null;\n\n},{}],6:[function(require,module,exports){\n\"use strict\";\n\n// load the global object first:\n// - it should be better integrated in the system (unhandledRejection in node)\n// - the environment may have a custom Promise implementation (see zone.js)\nvar ES6Promise = null;\nif (typeof Promise !== \"undefined\") {\n    ES6Promise = Promise;\n} else {\n    ES6Promise = require(\"lie\");\n}\n\n/**\n * Let the user use/change some implementations.\n */\nmodule.exports = {\n    Promise: ES6Promise\n};\n\n},{\"lie\":37}],7:[function(require,module,exports){\n\"use strict\";\nvar USE_TYPEDARRAY = (typeof Uint8Array !== \"undefined\") && (typeof Uint16Array !== \"undefined\") && (typeof Uint32Array !== \"undefined\");\n\nvar pako = require(\"pako\");\nvar utils = require(\"./utils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nvar ARRAY_TYPE = USE_TYPEDARRAY ? \"uint8array\" : \"array\";\n\nexports.magic = \"\\x08\\x00\";\n\n/**\n * Create a worker that uses pako to inflate/deflate.\n * @constructor\n * @param {String} action the name of the pako function to call : either \"Deflate\" or \"Inflate\".\n * @param {Object} options the options to use when (de)compressing.\n */\nfunction FlateWorker(action, options) {\n    GenericWorker.call(this, \"FlateWorker/\" + action);\n\n    this._pako = null;\n    this._pakoAction = action;\n    this._pakoOptions = options;\n    // the `meta` object from the last chunk received\n    // this allow this worker to pass around metadata\n    this.meta = {};\n}\n\nutils.inherits(FlateWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nFlateWorker.prototype.processChunk = function (chunk) {\n    this.meta = chunk.meta;\n    if (this._pako === null) {\n        this._createPako();\n    }\n    this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);\n};\n\n/**\n * @see GenericWorker.flush\n */\nFlateWorker.prototype.flush = function () {\n    GenericWorker.prototype.flush.call(this);\n    if (this._pako === null) {\n        this._createPako();\n    }\n    this._pako.push([], true);\n};\n/**\n * @see GenericWorker.cleanUp\n */\nFlateWorker.prototype.cleanUp = function () {\n    GenericWorker.prototype.cleanUp.call(this);\n    this._pako = null;\n};\n\n/**\n * Create the _pako object.\n * TODO: lazy-loading this object isn't the best solution but it's the\n * quickest. The best solution is to lazy-load the worker list. See also the\n * issue #446.\n */\nFlateWorker.prototype._createPako = function () {\n    this._pako = new pako[this._pakoAction]({\n        raw: true,\n        level: this._pakoOptions.level || -1 // default compression\n    });\n    var self = this;\n    this._pako.onData = function(data) {\n        self.push({\n            data : data,\n            meta : self.meta\n        });\n    };\n};\n\nexports.compressWorker = function (compressionOptions) {\n    return new FlateWorker(\"Deflate\", compressionOptions);\n};\nexports.uncompressWorker = function () {\n    return new FlateWorker(\"Inflate\", {});\n};\n\n},{\"./stream/GenericWorker\":28,\"./utils\":32,\"pako\":38}],8:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\nvar utf8 = require(\"../utf8\");\nvar crc32 = require(\"../crc32\");\nvar signature = require(\"../signature\");\n\n/**\n * Transform an integer into a string in hexadecimal.\n * @private\n * @param {number} dec the number to convert.\n * @param {number} bytes the number of bytes to generate.\n * @returns {string} the result.\n */\nvar decToHex = function(dec, bytes) {\n    var hex = \"\", i;\n    for (i = 0; i < bytes; i++) {\n        hex += String.fromCharCode(dec & 0xff);\n        dec = dec >>> 8;\n    }\n    return hex;\n};\n\n/**\n * Generate the UNIX part of the external file attributes.\n * @param {Object} unixPermissions the unix permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :\n *\n * TTTTsstrwxrwxrwx0000000000ADVSHR\n * ^^^^____________________________ file type, see zipinfo.c (UNX_*)\n *     ^^^_________________________ setuid, setgid, sticky\n *        ^^^^^^^^^________________ permissions\n *                 ^^^^^^^^^^______ not used ?\n *                           ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only\n */\nvar generateUnixExternalFileAttr = function (unixPermissions, isDir) {\n\n    var result = unixPermissions;\n    if (!unixPermissions) {\n        // I can't use octal values in strict mode, hence the hexa.\n        //  040775 => 0x41fd\n        // 0100664 => 0x81b4\n        result = isDir ? 0x41fd : 0x81b4;\n    }\n    return (result & 0xFFFF) << 16;\n};\n\n/**\n * Generate the DOS part of the external file attributes.\n * @param {Object} dosPermissions the dos permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * Bit 0     Read-Only\n * Bit 1     Hidden\n * Bit 2     System\n * Bit 3     Volume Label\n * Bit 4     Directory\n * Bit 5     Archive\n */\nvar generateDosExternalFileAttr = function (dosPermissions) {\n    // the dir flag is already set for compatibility\n    return (dosPermissions || 0)  & 0x3F;\n};\n\n/**\n * Generate the various parts used in the construction of the final zip file.\n * @param {Object} streamInfo the hash with information about the compressed file.\n * @param {Boolean} streamedContent is the content streamed ?\n * @param {Boolean} streamingEnded is the stream finished ?\n * @param {number} offset the current offset from the start of the zip file.\n * @param {String} platform let's pretend we are this platform (change platform dependents fields)\n * @param {Function} encodeFileName the function to encode the file name / comment.\n * @return {Object} the zip parts.\n */\nvar generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {\n    var file = streamInfo[\"file\"],\n        compression = streamInfo[\"compression\"],\n        useCustomEncoding = encodeFileName !== utf8.utf8encode,\n        encodedFileName = utils.transformTo(\"string\", encodeFileName(file.name)),\n        utfEncodedFileName = utils.transformTo(\"string\", utf8.utf8encode(file.name)),\n        comment = file.comment,\n        encodedComment = utils.transformTo(\"string\", encodeFileName(comment)),\n        utfEncodedComment = utils.transformTo(\"string\", utf8.utf8encode(comment)),\n        useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,\n        useUTF8ForComment = utfEncodedComment.length !== comment.length,\n        dosTime,\n        dosDate,\n        extraFields = \"\",\n        unicodePathExtraField = \"\",\n        unicodeCommentExtraField = \"\",\n        dir = file.dir,\n        date = file.date;\n\n\n    var dataInfo = {\n        crc32 : 0,\n        compressedSize : 0,\n        uncompressedSize : 0\n    };\n\n    // if the content is streamed, the sizes/crc32 are only available AFTER\n    // the end of the stream.\n    if (!streamedContent || streamingEnded) {\n        dataInfo.crc32 = streamInfo[\"crc32\"];\n        dataInfo.compressedSize = streamInfo[\"compressedSize\"];\n        dataInfo.uncompressedSize = streamInfo[\"uncompressedSize\"];\n    }\n\n    var bitflag = 0;\n    if (streamedContent) {\n        // Bit 3: the sizes/crc32 are set to zero in the local header.\n        // The correct values are put in the data descriptor immediately\n        // following the compressed data.\n        bitflag |= 0x0008;\n    }\n    if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {\n        // Bit 11: Language encoding flag (EFS).\n        bitflag |= 0x0800;\n    }\n\n\n    var extFileAttr = 0;\n    var versionMadeBy = 0;\n    if (dir) {\n        // dos or unix, we set the dos dir flag\n        extFileAttr |= 0x00010;\n    }\n    if(platform === \"UNIX\") {\n        versionMadeBy = 0x031E; // UNIX, version 3.0\n        extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);\n    } else { // DOS or other, fallback to DOS\n        versionMadeBy = 0x0014; // DOS, version 2.0\n        extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);\n    }\n\n    // date\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html\n\n    dosTime = date.getUTCHours();\n    dosTime = dosTime << 6;\n    dosTime = dosTime | date.getUTCMinutes();\n    dosTime = dosTime << 5;\n    dosTime = dosTime | date.getUTCSeconds() / 2;\n\n    dosDate = date.getUTCFullYear() - 1980;\n    dosDate = dosDate << 4;\n    dosDate = dosDate | (date.getUTCMonth() + 1);\n    dosDate = dosDate << 5;\n    dosDate = dosDate | date.getUTCDate();\n\n    if (useUTF8ForFileName) {\n        // set the unicode path extra field. unzip needs at least one extra\n        // field to correctly handle unicode path, so using the path is as good\n        // as any other information. This could improve the situation with\n        // other archive managers too.\n        // This field is usually used without the utf8 flag, with a non\n        // unicode path in the header (winrar, winzip). This helps (a bit)\n        // with the messy Windows' default compressed folders feature but\n        // breaks on p7zip which doesn't seek the unicode path extra field.\n        // So for now, UTF-8 everywhere !\n        unicodePathExtraField =\n            // Version\n            decToHex(1, 1) +\n            // NameCRC32\n            decToHex(crc32(encodedFileName), 4) +\n            // UnicodeName\n            utfEncodedFileName;\n\n        extraFields +=\n            // Info-ZIP Unicode Path Extra Field\n            \"\\x75\\x70\" +\n            // size\n            decToHex(unicodePathExtraField.length, 2) +\n            // content\n            unicodePathExtraField;\n    }\n\n    if(useUTF8ForComment) {\n\n        unicodeCommentExtraField =\n            // Version\n            decToHex(1, 1) +\n            // CommentCRC32\n            decToHex(crc32(encodedComment), 4) +\n            // UnicodeName\n            utfEncodedComment;\n\n        extraFields +=\n            // Info-ZIP Unicode Path Extra Field\n            \"\\x75\\x63\" +\n            // size\n            decToHex(unicodeCommentExtraField.length, 2) +\n            // content\n            unicodeCommentExtraField;\n    }\n\n    var header = \"\";\n\n    // version needed to extract\n    header += \"\\x0A\\x00\";\n    // general purpose bit flag\n    header += decToHex(bitflag, 2);\n    // compression method\n    header += compression.magic;\n    // last mod file time\n    header += decToHex(dosTime, 2);\n    // last mod file date\n    header += decToHex(dosDate, 2);\n    // crc-32\n    header += decToHex(dataInfo.crc32, 4);\n    // compressed size\n    header += decToHex(dataInfo.compressedSize, 4);\n    // uncompressed size\n    header += decToHex(dataInfo.uncompressedSize, 4);\n    // file name length\n    header += decToHex(encodedFileName.length, 2);\n    // extra field length\n    header += decToHex(extraFields.length, 2);\n\n\n    var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;\n\n    var dirRecord = signature.CENTRAL_FILE_HEADER +\n        // version made by (00: DOS)\n        decToHex(versionMadeBy, 2) +\n        // file header (common to file and central directory)\n        header +\n        // file comment length\n        decToHex(encodedComment.length, 2) +\n        // disk number start\n        \"\\x00\\x00\" +\n        // internal file attributes TODO\n        \"\\x00\\x00\" +\n        // external file attributes\n        decToHex(extFileAttr, 4) +\n        // relative offset of local header\n        decToHex(offset, 4) +\n        // file name\n        encodedFileName +\n        // extra field\n        extraFields +\n        // file comment\n        encodedComment;\n\n    return {\n        fileRecord: fileRecord,\n        dirRecord: dirRecord\n    };\n};\n\n/**\n * Generate the EOCD record.\n * @param {Number} entriesCount the number of entries in the zip file.\n * @param {Number} centralDirLength the length (in bytes) of the central dir.\n * @param {Number} localDirLength the length (in bytes) of the local dir.\n * @param {String} comment the zip file comment as a binary string.\n * @param {Function} encodeFileName the function to encode the comment.\n * @return {String} the EOCD record.\n */\nvar generateCentralDirectoryEnd = function (entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {\n    var dirEnd = \"\";\n    var encodedComment = utils.transformTo(\"string\", encodeFileName(comment));\n\n    // end of central dir signature\n    dirEnd = signature.CENTRAL_DIRECTORY_END +\n        // number of this disk\n        \"\\x00\\x00\" +\n        // number of the disk with the start of the central directory\n        \"\\x00\\x00\" +\n        // total number of entries in the central directory on this disk\n        decToHex(entriesCount, 2) +\n        // total number of entries in the central directory\n        decToHex(entriesCount, 2) +\n        // size of the central directory   4 bytes\n        decToHex(centralDirLength, 4) +\n        // offset of start of central directory with respect to the starting disk number\n        decToHex(localDirLength, 4) +\n        // .ZIP file comment length\n        decToHex(encodedComment.length, 2) +\n        // .ZIP file comment\n        encodedComment;\n\n    return dirEnd;\n};\n\n/**\n * Generate data descriptors for a file entry.\n * @param {Object} streamInfo the hash generated by a worker, containing information\n * on the file entry.\n * @return {String} the data descriptors.\n */\nvar generateDataDescriptors = function (streamInfo) {\n    var descriptor = \"\";\n    descriptor = signature.DATA_DESCRIPTOR +\n        // crc-32                          4 bytes\n        decToHex(streamInfo[\"crc32\"], 4) +\n        // compressed size                 4 bytes\n        decToHex(streamInfo[\"compressedSize\"], 4) +\n        // uncompressed size               4 bytes\n        decToHex(streamInfo[\"uncompressedSize\"], 4);\n\n    return descriptor;\n};\n\n\n/**\n * A worker to concatenate other workers to create a zip file.\n * @param {Boolean} streamFiles `true` to stream the content of the files,\n * `false` to accumulate it.\n * @param {String} comment the comment to use.\n * @param {String} platform the platform to use, \"UNIX\" or \"DOS\".\n * @param {Function} encodeFileName the function to encode file names and comments.\n */\nfunction ZipFileWorker(streamFiles, comment, platform, encodeFileName) {\n    GenericWorker.call(this, \"ZipFileWorker\");\n    // The number of bytes written so far. This doesn't count accumulated chunks.\n    this.bytesWritten = 0;\n    // The comment of the zip file\n    this.zipComment = comment;\n    // The platform \"generating\" the zip file.\n    this.zipPlatform = platform;\n    // the function to encode file names and comments.\n    this.encodeFileName = encodeFileName;\n    // Should we stream the content of the files ?\n    this.streamFiles = streamFiles;\n    // If `streamFiles` is false, we will need to accumulate the content of the\n    // files to calculate sizes / crc32 (and write them *before* the content).\n    // This boolean indicates if we are accumulating chunks (it will change a lot\n    // during the lifetime of this worker).\n    this.accumulate = false;\n    // The buffer receiving chunks when accumulating content.\n    this.contentBuffer = [];\n    // The list of generated directory records.\n    this.dirRecords = [];\n    // The offset (in bytes) from the beginning of the zip file for the current source.\n    this.currentSourceOffset = 0;\n    // The total number of entries in this zip file.\n    this.entriesCount = 0;\n    // the name of the file currently being added, null when handling the end of the zip file.\n    // Used for the emitted metadata.\n    this.currentFile = null;\n\n\n\n    this._sources = [];\n}\nutils.inherits(ZipFileWorker, GenericWorker);\n\n/**\n * @see GenericWorker.push\n */\nZipFileWorker.prototype.push = function (chunk) {\n\n    var currentFilePercent = chunk.meta.percent || 0;\n    var entriesCount = this.entriesCount;\n    var remainingFiles = this._sources.length;\n\n    if(this.accumulate) {\n        this.contentBuffer.push(chunk);\n    } else {\n        this.bytesWritten += chunk.data.length;\n\n        GenericWorker.prototype.push.call(this, {\n            data : chunk.data,\n            meta : {\n                currentFile : this.currentFile,\n                percent : entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100\n            }\n        });\n    }\n};\n\n/**\n * The worker started a new source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the new source.\n */\nZipFileWorker.prototype.openedSource = function (streamInfo) {\n    this.currentSourceOffset = this.bytesWritten;\n    this.currentFile = streamInfo[\"file\"].name;\n\n    var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n\n    // don't stream folders (because they don't have any content)\n    if(streamedContent) {\n        var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n        this.push({\n            data : record.fileRecord,\n            meta : {percent:0}\n        });\n    } else {\n        // we need to wait for the whole file before pushing anything\n        this.accumulate = true;\n    }\n};\n\n/**\n * The worker finished a source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the finished source.\n */\nZipFileWorker.prototype.closedSource = function (streamInfo) {\n    this.accumulate = false;\n    var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n    var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n\n    this.dirRecords.push(record.dirRecord);\n    if(streamedContent) {\n        // after the streamed file, we put data descriptors\n        this.push({\n            data : generateDataDescriptors(streamInfo),\n            meta : {percent:100}\n        });\n    } else {\n        // the content wasn't streamed, we need to push everything now\n        // first the file record, then the content\n        this.push({\n            data : record.fileRecord,\n            meta : {percent:0}\n        });\n        while(this.contentBuffer.length) {\n            this.push(this.contentBuffer.shift());\n        }\n    }\n    this.currentFile = null;\n};\n\n/**\n * @see GenericWorker.flush\n */\nZipFileWorker.prototype.flush = function () {\n\n    var localDirLength = this.bytesWritten;\n    for(var i = 0; i < this.dirRecords.length; i++) {\n        this.push({\n            data : this.dirRecords[i],\n            meta : {percent:100}\n        });\n    }\n    var centralDirLength = this.bytesWritten - localDirLength;\n\n    var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);\n\n    this.push({\n        data : dirEnd,\n        meta : {percent:100}\n    });\n};\n\n/**\n * Prepare the next source to be read.\n */\nZipFileWorker.prototype.prepareNextSource = function () {\n    this.previous = this._sources.shift();\n    this.openedSource(this.previous.streamInfo);\n    if (this.isPaused) {\n        this.previous.pause();\n    } else {\n        this.previous.resume();\n    }\n};\n\n/**\n * @see GenericWorker.registerPrevious\n */\nZipFileWorker.prototype.registerPrevious = function (previous) {\n    this._sources.push(previous);\n    var self = this;\n\n    previous.on(\"data\", function (chunk) {\n        self.processChunk(chunk);\n    });\n    previous.on(\"end\", function () {\n        self.closedSource(self.previous.streamInfo);\n        if(self._sources.length) {\n            self.prepareNextSource();\n        } else {\n            self.end();\n        }\n    });\n    previous.on(\"error\", function (e) {\n        self.error(e);\n    });\n    return this;\n};\n\n/**\n * @see GenericWorker.resume\n */\nZipFileWorker.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if (!this.previous && this._sources.length) {\n        this.prepareNextSource();\n        return true;\n    }\n    if (!this.previous && !this._sources.length && !this.generatedError) {\n        this.end();\n        return true;\n    }\n};\n\n/**\n * @see GenericWorker.error\n */\nZipFileWorker.prototype.error = function (e) {\n    var sources = this._sources;\n    if(!GenericWorker.prototype.error.call(this, e)) {\n        return false;\n    }\n    for(var i = 0; i < sources.length; i++) {\n        try {\n            sources[i].error(e);\n        } catch(e) {\n            // the `error` exploded, nothing to do\n        }\n    }\n    return true;\n};\n\n/**\n * @see GenericWorker.lock\n */\nZipFileWorker.prototype.lock = function () {\n    GenericWorker.prototype.lock.call(this);\n    var sources = this._sources;\n    for(var i = 0; i < sources.length; i++) {\n        sources[i].lock();\n    }\n};\n\nmodule.exports = ZipFileWorker;\n\n},{\"../crc32\":4,\"../signature\":23,\"../stream/GenericWorker\":28,\"../utf8\":31,\"../utils\":32}],9:[function(require,module,exports){\n\"use strict\";\n\nvar compressions = require(\"../compressions\");\nvar ZipFileWorker = require(\"./ZipFileWorker\");\n\n/**\n * Find the compression to use.\n * @param {String} fileCompression the compression defined at the file level, if any.\n * @param {String} zipCompression the compression defined at the load() level.\n * @return {Object} the compression object to use.\n */\nvar getCompression = function (fileCompression, zipCompression) {\n\n    var compressionName = fileCompression || zipCompression;\n    var compression = compressions[compressionName];\n    if (!compression) {\n        throw new Error(compressionName + \" is not a valid compression method !\");\n    }\n    return compression;\n};\n\n/**\n * Create a worker to generate a zip file.\n * @param {JSZip} zip the JSZip instance at the right root level.\n * @param {Object} options to generate the zip file.\n * @param {String} comment the comment to use.\n */\nexports.generateWorker = function (zip, options, comment) {\n\n    var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);\n    var entriesCount = 0;\n    try {\n\n        zip.forEach(function (relativePath, file) {\n            entriesCount++;\n            var compression = getCompression(file.options.compression, options.compression);\n            var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};\n            var dir = file.dir, date = file.date;\n\n            file._compressWorker(compression, compressionOptions)\n                .withStreamInfo(\"file\", {\n                    name : relativePath,\n                    dir : dir,\n                    date : date,\n                    comment : file.comment || \"\",\n                    unixPermissions : file.unixPermissions,\n                    dosPermissions : file.dosPermissions\n                })\n                .pipe(zipFileWorker);\n        });\n        zipFileWorker.entriesCount = entriesCount;\n    } catch (e) {\n        zipFileWorker.error(e);\n    }\n\n    return zipFileWorker;\n};\n\n},{\"../compressions\":3,\"./ZipFileWorker\":8}],10:[function(require,module,exports){\n\"use strict\";\n\n/**\n * Representation a of zip file in js\n * @constructor\n */\nfunction JSZip() {\n    // if this constructor is used without `new`, it adds `new` before itself:\n    if(!(this instanceof JSZip)) {\n        return new JSZip();\n    }\n\n    if(arguments.length) {\n        throw new Error(\"The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.\");\n    }\n\n    // object containing the files :\n    // {\n    //   \"folder/\" : {...},\n    //   \"folder/data.txt\" : {...}\n    // }\n    // NOTE: we use a null prototype because we do not\n    // want filenames like \"toString\" coming from a zip file\n    // to overwrite methods and attributes in a normal Object.\n    this.files = Object.create(null);\n\n    this.comment = null;\n\n    // Where we are in the hierarchy\n    this.root = \"\";\n    this.clone = function() {\n        var newObj = new JSZip();\n        for (var i in this) {\n            if (typeof this[i] !== \"function\") {\n                newObj[i] = this[i];\n            }\n        }\n        return newObj;\n    };\n}\nJSZip.prototype = require(\"./object\");\nJSZip.prototype.loadAsync = require(\"./load\");\nJSZip.support = require(\"./support\");\nJSZip.defaults = require(\"./defaults\");\n\n// TODO find a better way to handle this version,\n// a require('package.json').version doesn't work with webpack, see #327\nJSZip.version = \"3.10.1\";\n\nJSZip.loadAsync = function (content, options) {\n    return new JSZip().loadAsync(content, options);\n};\n\nJSZip.external = require(\"./external\");\nmodule.exports = JSZip;\n\n},{\"./defaults\":5,\"./external\":6,\"./load\":11,\"./object\":15,\"./support\":30}],11:[function(require,module,exports){\n\"use strict\";\nvar utils = require(\"./utils\");\nvar external = require(\"./external\");\nvar utf8 = require(\"./utf8\");\nvar ZipEntries = require(\"./zipEntries\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar nodejsUtils = require(\"./nodejsUtils\");\n\n/**\n * Check the CRC32 of an entry.\n * @param {ZipEntry} zipEntry the zip entry to check.\n * @return {Promise} the result.\n */\nfunction checkEntryCRC32(zipEntry) {\n    return new external.Promise(function (resolve, reject) {\n        var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());\n        worker.on(\"error\", function (e) {\n            reject(e);\n        })\n            .on(\"end\", function () {\n                if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {\n                    reject(new Error(\"Corrupted zip : CRC32 mismatch\"));\n                } else {\n                    resolve();\n                }\n            })\n            .resume();\n    });\n}\n\nmodule.exports = function (data, options) {\n    var zip = this;\n    options = utils.extend(options || {}, {\n        base64: false,\n        checkCRC32: false,\n        optimizedBinaryString: false,\n        createFolders: false,\n        decodeFileName: utf8.utf8decode\n    });\n\n    if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n        return external.Promise.reject(new Error(\"JSZip can't accept a stream when loading a zip file.\"));\n    }\n\n    return utils.prepareContent(\"the loaded zip file\", data, true, options.optimizedBinaryString, options.base64)\n        .then(function (data) {\n            var zipEntries = new ZipEntries(options);\n            zipEntries.load(data);\n            return zipEntries;\n        }).then(function checkCRC32(zipEntries) {\n            var promises = [external.Promise.resolve(zipEntries)];\n            var files = zipEntries.files;\n            if (options.checkCRC32) {\n                for (var i = 0; i < files.length; i++) {\n                    promises.push(checkEntryCRC32(files[i]));\n                }\n            }\n            return external.Promise.all(promises);\n        }).then(function addFiles(results) {\n            var zipEntries = results.shift();\n            var files = zipEntries.files;\n            for (var i = 0; i < files.length; i++) {\n                var input = files[i];\n\n                var unsafeName = input.fileNameStr;\n                var safeName = utils.resolve(input.fileNameStr);\n\n                zip.file(safeName, input.decompressed, {\n                    binary: true,\n                    optimizedBinaryString: true,\n                    date: input.date,\n                    dir: input.dir,\n                    comment: input.fileCommentStr.length ? input.fileCommentStr : null,\n                    unixPermissions: input.unixPermissions,\n                    dosPermissions: input.dosPermissions,\n                    createFolders: options.createFolders\n                });\n                if (!input.dir) {\n                    zip.file(safeName).unsafeOriginalName = unsafeName;\n                }\n            }\n            if (zipEntries.zipComment.length) {\n                zip.comment = zipEntries.zipComment;\n            }\n\n            return zip;\n        });\n};\n\n},{\"./external\":6,\"./nodejsUtils\":14,\"./stream/Crc32Probe\":25,\"./utf8\":31,\"./utils\":32,\"./zipEntries\":33}],12:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\n\n/**\n * A worker that use a nodejs stream as source.\n * @constructor\n * @param {String} filename the name of the file entry for this stream.\n * @param {Readable} stream the nodejs stream.\n */\nfunction NodejsStreamInputAdapter(filename, stream) {\n    GenericWorker.call(this, \"Nodejs stream input adapter for \" + filename);\n    this._upstreamEnded = false;\n    this._bindStream(stream);\n}\n\nutils.inherits(NodejsStreamInputAdapter, GenericWorker);\n\n/**\n * Prepare the stream and bind the callbacks on it.\n * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.\n * @param {Stream} stream the nodejs stream to use.\n */\nNodejsStreamInputAdapter.prototype._bindStream = function (stream) {\n    var self = this;\n    this._stream = stream;\n    stream.pause();\n    stream\n        .on(\"data\", function (chunk) {\n            self.push({\n                data: chunk,\n                meta : {\n                    percent : 0\n                }\n            });\n        })\n        .on(\"error\", function (e) {\n            if(self.isPaused) {\n                this.generatedError = e;\n            } else {\n                self.error(e);\n            }\n        })\n        .on(\"end\", function () {\n            if(self.isPaused) {\n                self._upstreamEnded = true;\n            } else {\n                self.end();\n            }\n        });\n};\nNodejsStreamInputAdapter.prototype.pause = function () {\n    if(!GenericWorker.prototype.pause.call(this)) {\n        return false;\n    }\n    this._stream.pause();\n    return true;\n};\nNodejsStreamInputAdapter.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if(this._upstreamEnded) {\n        this.end();\n    } else {\n        this._stream.resume();\n    }\n\n    return true;\n};\n\nmodule.exports = NodejsStreamInputAdapter;\n\n},{\"../stream/GenericWorker\":28,\"../utils\":32}],13:[function(require,module,exports){\n\"use strict\";\n\nvar Readable = require(\"readable-stream\").Readable;\n\nvar utils = require(\"../utils\");\nutils.inherits(NodejsStreamOutputAdapter, Readable);\n\n/**\n* A nodejs stream using a worker as source.\n* @see the SourceWrapper in http://nodejs.org/api/stream.html\n* @constructor\n* @param {StreamHelper} helper the helper wrapping the worker\n* @param {Object} options the nodejs stream options\n* @param {Function} updateCb the update callback.\n*/\nfunction NodejsStreamOutputAdapter(helper, options, updateCb) {\n    Readable.call(this, options);\n    this._helper = helper;\n\n    var self = this;\n    helper.on(\"data\", function (data, meta) {\n        if (!self.push(data)) {\n            self._helper.pause();\n        }\n        if(updateCb) {\n            updateCb(meta);\n        }\n    })\n        .on(\"error\", function(e) {\n            self.emit(\"error\", e);\n        })\n        .on(\"end\", function () {\n            self.push(null);\n        });\n}\n\n\nNodejsStreamOutputAdapter.prototype._read = function() {\n    this._helper.resume();\n};\n\nmodule.exports = NodejsStreamOutputAdapter;\n\n},{\"../utils\":32,\"readable-stream\":16}],14:[function(require,module,exports){\n\"use strict\";\n\nmodule.exports = {\n    /**\n     * True if this is running in Nodejs, will be undefined in a browser.\n     * In a browser, browserify won't include this file and the whole module\n     * will be resolved an empty object.\n     */\n    isNode : typeof Buffer !== \"undefined\",\n    /**\n     * Create a new nodejs Buffer from an existing content.\n     * @param {Object} data the data to pass to the constructor.\n     * @param {String} encoding the encoding to use.\n     * @return {Buffer} a new Buffer.\n     */\n    newBufferFrom: function(data, encoding) {\n        if (Buffer.from && Buffer.from !== Uint8Array.from) {\n            return Buffer.from(data, encoding);\n        } else {\n            if (typeof data === \"number\") {\n                // Safeguard for old Node.js versions. On newer versions,\n                // Buffer.from(number) / Buffer(number, encoding) already throw.\n                throw new Error(\"The \\\"data\\\" argument must not be a number\");\n            }\n            return new Buffer(data, encoding);\n        }\n    },\n    /**\n     * Create a new nodejs Buffer with the specified size.\n     * @param {Integer} size the size of the buffer.\n     * @return {Buffer} a new Buffer.\n     */\n    allocBuffer: function (size) {\n        if (Buffer.alloc) {\n            return Buffer.alloc(size);\n        } else {\n            var buf = new Buffer(size);\n            buf.fill(0);\n            return buf;\n        }\n    },\n    /**\n     * Find out if an object is a Buffer.\n     * @param {Object} b the object to test.\n     * @return {Boolean} true if the object is a Buffer, false otherwise.\n     */\n    isBuffer : function(b){\n        return Buffer.isBuffer(b);\n    },\n\n    isStream : function (obj) {\n        return obj &&\n            typeof obj.on === \"function\" &&\n            typeof obj.pause === \"function\" &&\n            typeof obj.resume === \"function\";\n    }\n};\n\n},{}],15:[function(require,module,exports){\n\"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        // ignore warning about unwanted properties because this.files is a null prototype object\n        /* eslint-disable-next-line guard-for-in */\n        for (filename in this.files) {\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     * @deprecated This method has been removed in JSZip 3.0, please check the upgrade guide.\n     */\n    generate: function() {\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 preferred 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\n},{\"./compressedObject\":2,\"./defaults\":5,\"./generate\":9,\"./nodejs/NodejsStreamInputAdapter\":12,\"./nodejsUtils\":14,\"./stream/GenericWorker\":28,\"./stream/StreamHelper\":29,\"./utf8\":31,\"./utils\":32,\"./zipObject\":35}],16:[function(require,module,exports){\n\"use strict\";\n/*\n * This file is used by module bundlers (browserify/webpack/etc) when\n * including a stream implementation. We use \"readable-stream\" to get a\n * consistent behavior between nodejs versions but bundlers often have a shim\n * for \"stream\". Using this shim greatly improve the compatibility and greatly\n * reduce the final size of the bundle (only one stream implementation, not\n * two).\n */\nmodule.exports = require(\"stream\");\n\n},{\"stream\":undefined}],17:[function(require,module,exports){\n\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction ArrayReader(data) {\n    DataReader.call(this, data);\n    for(var i = 0; i < this.data.length; i++) {\n        data[i] = data[i] & 0xFF;\n    }\n}\nutils.inherits(ArrayReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nArrayReader.prototype.byteAt = function(i) {\n    return this.data[this.zero + i];\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nArrayReader.prototype.lastIndexOfSignature = function(sig) {\n    var sig0 = sig.charCodeAt(0),\n        sig1 = sig.charCodeAt(1),\n        sig2 = sig.charCodeAt(2),\n        sig3 = sig.charCodeAt(3);\n    for (var i = this.length - 4; i >= 0; --i) {\n        if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {\n            return i - this.zero;\n        }\n    }\n\n    return -1;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nArrayReader.prototype.readAndCheckSignature = function (sig) {\n    var sig0 = sig.charCodeAt(0),\n        sig1 = sig.charCodeAt(1),\n        sig2 = sig.charCodeAt(2),\n        sig3 = sig.charCodeAt(3),\n        data = this.readData(4);\n    return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];\n};\n/**\n * @see DataReader.readData\n */\nArrayReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    if(size === 0) {\n        return [];\n    }\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = ArrayReader;\n\n},{\"../utils\":32,\"./DataReader\":18}],18:[function(require,module,exports){\n\"use strict\";\nvar utils = require(\"../utils\");\n\nfunction DataReader(data) {\n    this.data = data; // type : see implementation\n    this.length = data.length;\n    this.index = 0;\n    this.zero = 0;\n}\nDataReader.prototype = {\n    /**\n     * Check that the offset will not go too far.\n     * @param {string} offset the additional offset to check.\n     * @throws {Error} an Error if the offset is out of bounds.\n     */\n    checkOffset: function(offset) {\n        this.checkIndex(this.index + offset);\n    },\n    /**\n     * Check that the specified index will not be too far.\n     * @param {string} newIndex the index to check.\n     * @throws {Error} an Error if the index is out of bounds.\n     */\n    checkIndex: function(newIndex) {\n        if (this.length < this.zero + newIndex || newIndex < 0) {\n            throw new Error(\"End of data reached (data length = \" + this.length + \", asked index = \" + (newIndex) + \"). Corrupted zip ?\");\n        }\n    },\n    /**\n     * Change the index.\n     * @param {number} newIndex The new index.\n     * @throws {Error} if the new index is out of the data.\n     */\n    setIndex: function(newIndex) {\n        this.checkIndex(newIndex);\n        this.index = newIndex;\n    },\n    /**\n     * Skip the next n bytes.\n     * @param {number} n the number of bytes to skip.\n     * @throws {Error} if the new index is out of the data.\n     */\n    skip: function(n) {\n        this.setIndex(this.index + n);\n    },\n    /**\n     * Get the byte at the specified index.\n     * @param {number} i the index to use.\n     * @return {number} a byte.\n     */\n    byteAt: function() {\n        // see implementations\n    },\n    /**\n     * Get the next number with a given byte size.\n     * @param {number} size the number of bytes to read.\n     * @return {number} the corresponding number.\n     */\n    readInt: function(size) {\n        var result = 0,\n            i;\n        this.checkOffset(size);\n        for (i = this.index + size - 1; i >= this.index; i--) {\n            result = (result << 8) + this.byteAt(i);\n        }\n        this.index += size;\n        return result;\n    },\n    /**\n     * Get the next string with a given byte size.\n     * @param {number} size the number of bytes to read.\n     * @return {string} the corresponding string.\n     */\n    readString: function(size) {\n        return utils.transformTo(\"string\", this.readData(size));\n    },\n    /**\n     * Get raw data without conversion, <size> bytes.\n     * @param {number} size the number of bytes to read.\n     * @return {Object} the raw data, implementation specific.\n     */\n    readData: function() {\n        // see implementations\n    },\n    /**\n     * Find the last occurrence of a zip signature (4 bytes).\n     * @param {string} sig the signature to find.\n     * @return {number} the index of the last occurrence, -1 if not found.\n     */\n    lastIndexOfSignature: function() {\n        // see implementations\n    },\n    /**\n     * Read the signature (4 bytes) at the current position and compare it with sig.\n     * @param {string} sig the expected signature\n     * @return {boolean} true if the signature matches, false otherwise.\n     */\n    readAndCheckSignature: function() {\n        // see implementations\n    },\n    /**\n     * Get the next date.\n     * @return {Date} the date.\n     */\n    readDate: function() {\n        var dostime = this.readInt(4);\n        return new Date(Date.UTC(\n            ((dostime >> 25) & 0x7f) + 1980, // year\n            ((dostime >> 21) & 0x0f) - 1, // month\n            (dostime >> 16) & 0x1f, // day\n            (dostime >> 11) & 0x1f, // hour\n            (dostime >> 5) & 0x3f, // minute\n            (dostime & 0x1f) << 1)); // second\n    }\n};\nmodule.exports = DataReader;\n\n},{\"../utils\":32}],19:[function(require,module,exports){\n\"use strict\";\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction NodeBufferReader(data) {\n    Uint8ArrayReader.call(this, data);\n}\nutils.inherits(NodeBufferReader, Uint8ArrayReader);\n\n/**\n * @see DataReader.readData\n */\nNodeBufferReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = NodeBufferReader;\n\n},{\"../utils\":32,\"./Uint8ArrayReader\":21}],20:[function(require,module,exports){\n\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction StringReader(data) {\n    DataReader.call(this, data);\n}\nutils.inherits(StringReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nStringReader.prototype.byteAt = function(i) {\n    return this.data.charCodeAt(this.zero + i);\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nStringReader.prototype.lastIndexOfSignature = function(sig) {\n    return this.data.lastIndexOf(sig) - this.zero;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nStringReader.prototype.readAndCheckSignature = function (sig) {\n    var data = this.readData(4);\n    return sig === data;\n};\n/**\n * @see DataReader.readData\n */\nStringReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    // this will work because the constructor applied the \"& 0xff\" mask.\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = StringReader;\n\n},{\"../utils\":32,\"./DataReader\":18}],21:[function(require,module,exports){\n\"use strict\";\nvar ArrayReader = require(\"./ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction Uint8ArrayReader(data) {\n    ArrayReader.call(this, data);\n}\nutils.inherits(Uint8ArrayReader, ArrayReader);\n/**\n * @see DataReader.readData\n */\nUint8ArrayReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    if(size === 0) {\n        // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].\n        return new Uint8Array(0);\n    }\n    var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = Uint8ArrayReader;\n\n},{\"../utils\":32,\"./ArrayReader\":17}],22:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar support = require(\"../support\");\nvar ArrayReader = require(\"./ArrayReader\");\nvar StringReader = require(\"./StringReader\");\nvar NodeBufferReader = require(\"./NodeBufferReader\");\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\n\n/**\n * Create a reader adapted to the data.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.\n * @return {DataReader} the data reader.\n */\nmodule.exports = function (data) {\n    var type = utils.getTypeOf(data);\n    utils.checkSupport(type);\n    if (type === \"string\" && !support.uint8array) {\n        return new StringReader(data);\n    }\n    if (type === \"nodebuffer\") {\n        return new NodeBufferReader(data);\n    }\n    if (support.uint8array) {\n        return new Uint8ArrayReader(utils.transformTo(\"uint8array\", data));\n    }\n    return new ArrayReader(utils.transformTo(\"array\", data));\n};\n\n},{\"../support\":30,\"../utils\":32,\"./ArrayReader\":17,\"./NodeBufferReader\":19,\"./StringReader\":20,\"./Uint8ArrayReader\":21}],23:[function(require,module,exports){\n\"use strict\";\nexports.LOCAL_FILE_HEADER = \"PK\\x03\\x04\";\nexports.CENTRAL_FILE_HEADER = \"PK\\x01\\x02\";\nexports.CENTRAL_DIRECTORY_END = \"PK\\x05\\x06\";\nexports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = \"PK\\x06\\x07\";\nexports.ZIP64_CENTRAL_DIRECTORY_END = \"PK\\x06\\x06\";\nexports.DATA_DESCRIPTOR = \"PK\\x07\\x08\";\n\n},{}],24:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which convert chunks to a specified type.\n * @constructor\n * @param {String} destType the destination type.\n */\nfunction ConvertWorker(destType) {\n    GenericWorker.call(this, \"ConvertWorker to \" + destType);\n    this.destType = destType;\n}\nutils.inherits(ConvertWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nConvertWorker.prototype.processChunk = function (chunk) {\n    this.push({\n        data : utils.transformTo(this.destType, chunk.data),\n        meta : chunk.meta\n    });\n};\nmodule.exports = ConvertWorker;\n\n},{\"../utils\":32,\"./GenericWorker\":28}],25:[function(require,module,exports){\n\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar crc32 = require(\"../crc32\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which calculate the crc32 of the data flowing through.\n * @constructor\n */\nfunction Crc32Probe() {\n    GenericWorker.call(this, \"Crc32Probe\");\n    this.withStreamInfo(\"crc32\", 0);\n}\nutils.inherits(Crc32Probe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nCrc32Probe.prototype.processChunk = function (chunk) {\n    this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);\n    this.push(chunk);\n};\nmodule.exports = Crc32Probe;\n\n},{\"../crc32\":4,\"../utils\":32,\"./GenericWorker\":28}],26:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n/**\n * A worker which calculate the total length of the data flowing through.\n * @constructor\n * @param {String} propName the name used to expose the length\n */\nfunction DataLengthProbe(propName) {\n    GenericWorker.call(this, \"DataLengthProbe for \" + propName);\n    this.propName = propName;\n    this.withStreamInfo(propName, 0);\n}\nutils.inherits(DataLengthProbe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nDataLengthProbe.prototype.processChunk = function (chunk) {\n    if(chunk) {\n        var length = this.streamInfo[this.propName] || 0;\n        this.streamInfo[this.propName] = length + chunk.data.length;\n    }\n    GenericWorker.prototype.processChunk.call(this, chunk);\n};\nmodule.exports = DataLengthProbe;\n\n\n},{\"../utils\":32,\"./GenericWorker\":28}],27:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n// the size of the generated chunks\n// TODO expose this as a public variable\nvar DEFAULT_BLOCK_SIZE = 16 * 1024;\n\n/**\n * A worker that reads a content and emits chunks.\n * @constructor\n * @param {Promise} dataP the promise of the data to split\n */\nfunction DataWorker(dataP) {\n    GenericWorker.call(this, \"DataWorker\");\n    var self = this;\n    this.dataIsReady = false;\n    this.index = 0;\n    this.max = 0;\n    this.data = null;\n    this.type = \"\";\n\n    this._tickScheduled = false;\n\n    dataP.then(function (data) {\n        self.dataIsReady = true;\n        self.data = data;\n        self.max = data && data.length || 0;\n        self.type = utils.getTypeOf(data);\n        if(!self.isPaused) {\n            self._tickAndRepeat();\n        }\n    }, function (e) {\n        self.error(e);\n    });\n}\n\nutils.inherits(DataWorker, GenericWorker);\n\n/**\n * @see GenericWorker.cleanUp\n */\nDataWorker.prototype.cleanUp = function () {\n    GenericWorker.prototype.cleanUp.call(this);\n    this.data = null;\n};\n\n/**\n * @see GenericWorker.resume\n */\nDataWorker.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if (!this._tickScheduled && this.dataIsReady) {\n        this._tickScheduled = true;\n        utils.delay(this._tickAndRepeat, [], this);\n    }\n    return true;\n};\n\n/**\n * Trigger a tick a schedule an other call to this function.\n */\nDataWorker.prototype._tickAndRepeat = function() {\n    this._tickScheduled = false;\n    if(this.isPaused || this.isFinished) {\n        return;\n    }\n    this._tick();\n    if(!this.isFinished) {\n        utils.delay(this._tickAndRepeat, [], this);\n        this._tickScheduled = true;\n    }\n};\n\n/**\n * Read and push a chunk.\n */\nDataWorker.prototype._tick = function() {\n\n    if(this.isPaused || this.isFinished) {\n        return false;\n    }\n\n    var size = DEFAULT_BLOCK_SIZE;\n    var data = null, nextIndex = Math.min(this.max, this.index + size);\n    if (this.index >= this.max) {\n        // EOF\n        return this.end();\n    } else {\n        switch(this.type) {\n        case \"string\":\n            data = this.data.substring(this.index, nextIndex);\n            break;\n        case \"uint8array\":\n            data = this.data.subarray(this.index, nextIndex);\n            break;\n        case \"array\":\n        case \"nodebuffer\":\n            data = this.data.slice(this.index, nextIndex);\n            break;\n        }\n        this.index = nextIndex;\n        return this.push({\n            data : data,\n            meta : {\n                percent : this.max ? this.index / this.max * 100 : 0\n            }\n        });\n    }\n};\n\nmodule.exports = DataWorker;\n\n},{\"../utils\":32,\"./GenericWorker\":28}],28:[function(require,module,exports){\n\"use strict\";\n\n/**\n * A worker that does nothing but passing chunks to the next one. This is like\n * a nodejs stream but with some differences. On the good side :\n * - it works on IE 6-9 without any issue / polyfill\n * - it weights less than the full dependencies bundled with browserify\n * - it forwards errors (no need to declare an error handler EVERYWHERE)\n *\n * A chunk is an object with 2 attributes : `meta` and `data`. The former is an\n * object containing anything (`percent` for example), see each worker for more\n * details. The latter is the real data (String, Uint8Array, etc).\n *\n * @constructor\n * @param {String} name the name of the stream (mainly used for debugging purposes)\n */\nfunction GenericWorker(name) {\n    // the name of the worker\n    this.name = name || \"default\";\n    // an object containing metadata about the workers chain\n    this.streamInfo = {};\n    // an error which happened when the worker was paused\n    this.generatedError = null;\n    // an object containing metadata to be merged by this worker into the general metadata\n    this.extraStreamInfo = {};\n    // true if the stream is paused (and should not do anything), false otherwise\n    this.isPaused = true;\n    // true if the stream is finished (and should not do anything), false otherwise\n    this.isFinished = false;\n    // true if the stream is locked to prevent further structure updates (pipe), false otherwise\n    this.isLocked = false;\n    // the event listeners\n    this._listeners = {\n        \"data\":[],\n        \"end\":[],\n        \"error\":[]\n    };\n    // the previous worker, if any\n    this.previous = null;\n}\n\nGenericWorker.prototype = {\n    /**\n     * Push a chunk to the next workers.\n     * @param {Object} chunk the chunk to push\n     */\n    push : function (chunk) {\n        this.emit(\"data\", chunk);\n    },\n    /**\n     * End the stream.\n     * @return {Boolean} true if this call ended the worker, false otherwise.\n     */\n    end : function () {\n        if (this.isFinished) {\n            return false;\n        }\n\n        this.flush();\n        try {\n            this.emit(\"end\");\n            this.cleanUp();\n            this.isFinished = true;\n        } catch (e) {\n            this.emit(\"error\", e);\n        }\n        return true;\n    },\n    /**\n     * End the stream with an error.\n     * @param {Error} e the error which caused the premature end.\n     * @return {Boolean} true if this call ended the worker with an error, false otherwise.\n     */\n    error : function (e) {\n        if (this.isFinished) {\n            return false;\n        }\n\n        if(this.isPaused) {\n            this.generatedError = e;\n        } else {\n            this.isFinished = true;\n\n            this.emit(\"error\", e);\n\n            // in the workers chain exploded in the middle of the chain,\n            // the error event will go downward but we also need to notify\n            // workers upward that there has been an error.\n            if(this.previous) {\n                this.previous.error(e);\n            }\n\n            this.cleanUp();\n        }\n        return true;\n    },\n    /**\n     * Add a callback on an event.\n     * @param {String} name the name of the event (data, end, error)\n     * @param {Function} listener the function to call when the event is triggered\n     * @return {GenericWorker} the current object for chainability\n     */\n    on : function (name, listener) {\n        this._listeners[name].push(listener);\n        return this;\n    },\n    /**\n     * Clean any references when a worker is ending.\n     */\n    cleanUp : function () {\n        this.streamInfo = this.generatedError = this.extraStreamInfo = null;\n        this._listeners = [];\n    },\n    /**\n     * Trigger an event. This will call registered callback with the provided arg.\n     * @param {String} name the name of the event (data, end, error)\n     * @param {Object} arg the argument to call the callback with.\n     */\n    emit : function (name, arg) {\n        if (this._listeners[name]) {\n            for(var i = 0; i < this._listeners[name].length; i++) {\n                this._listeners[name][i].call(this, arg);\n            }\n        }\n    },\n    /**\n     * Chain a worker with an other.\n     * @param {Worker} next the worker receiving events from the current one.\n     * @return {worker} the next worker for chainability\n     */\n    pipe : function (next) {\n        return next.registerPrevious(this);\n    },\n    /**\n     * Same as `pipe` in the other direction.\n     * Using an API with `pipe(next)` is very easy.\n     * Implementing the API with the point of view of the next one registering\n     * a source is easier, see the ZipFileWorker.\n     * @param {Worker} previous the previous worker, sending events to this one\n     * @return {Worker} the current worker for chainability\n     */\n    registerPrevious : function (previous) {\n        if (this.isLocked) {\n            throw new Error(\"The stream '\" + this + \"' has already been used.\");\n        }\n\n        // sharing the streamInfo...\n        this.streamInfo = previous.streamInfo;\n        // ... and adding our own bits\n        this.mergeStreamInfo();\n        this.previous =  previous;\n        var self = this;\n        previous.on(\"data\", function (chunk) {\n            self.processChunk(chunk);\n        });\n        previous.on(\"end\", function () {\n            self.end();\n        });\n        previous.on(\"error\", function (e) {\n            self.error(e);\n        });\n        return this;\n    },\n    /**\n     * Pause the stream so it doesn't send events anymore.\n     * @return {Boolean} true if this call paused the worker, false otherwise.\n     */\n    pause : function () {\n        if(this.isPaused || this.isFinished) {\n            return false;\n        }\n        this.isPaused = true;\n\n        if(this.previous) {\n            this.previous.pause();\n        }\n        return true;\n    },\n    /**\n     * Resume a paused stream.\n     * @return {Boolean} true if this call resumed the worker, false otherwise.\n     */\n    resume : function () {\n        if(!this.isPaused || this.isFinished) {\n            return false;\n        }\n        this.isPaused = false;\n\n        // if true, the worker tried to resume but failed\n        var withError = false;\n        if(this.generatedError) {\n            this.error(this.generatedError);\n            withError = true;\n        }\n        if(this.previous) {\n            this.previous.resume();\n        }\n\n        return !withError;\n    },\n    /**\n     * Flush any remaining bytes as the stream is ending.\n     */\n    flush : function () {},\n    /**\n     * Process a chunk. This is usually the method overridden.\n     * @param {Object} chunk the chunk to process.\n     */\n    processChunk : function(chunk) {\n        this.push(chunk);\n    },\n    /**\n     * Add a key/value to be added in the workers chain streamInfo once activated.\n     * @param {String} key the key to use\n     * @param {Object} value the associated value\n     * @return {Worker} the current worker for chainability\n     */\n    withStreamInfo : function (key, value) {\n        this.extraStreamInfo[key] = value;\n        this.mergeStreamInfo();\n        return this;\n    },\n    /**\n     * Merge this worker's streamInfo into the chain's streamInfo.\n     */\n    mergeStreamInfo : function () {\n        for(var key in this.extraStreamInfo) {\n            if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) {\n                continue;\n            }\n            this.streamInfo[key] = this.extraStreamInfo[key];\n        }\n    },\n\n    /**\n     * Lock the stream to prevent further updates on the workers chain.\n     * After calling this method, all calls to pipe will fail.\n     */\n    lock: function () {\n        if (this.isLocked) {\n            throw new Error(\"The stream '\" + this + \"' has already been used.\");\n        }\n        this.isLocked = true;\n        if (this.previous) {\n            this.previous.lock();\n        }\n    },\n\n    /**\n     *\n     * Pretty print the workers chain.\n     */\n    toString : function () {\n        var me = \"Worker \" + this.name;\n        if (this.previous) {\n            return this.previous + \" -> \" + me;\n        } else {\n            return me;\n        }\n    }\n};\n\nmodule.exports = GenericWorker;\n\n},{}],29:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"../utils\");\nvar ConvertWorker = require(\"./ConvertWorker\");\nvar GenericWorker = require(\"./GenericWorker\");\nvar base64 = require(\"../base64\");\nvar support = require(\"../support\");\nvar external = require(\"../external\");\n\nvar NodejsStreamOutputAdapter = null;\nif (support.nodestream) {\n    try {\n        NodejsStreamOutputAdapter = require(\"../nodejs/NodejsStreamOutputAdapter\");\n    } catch(e) {\n        // ignore\n    }\n}\n\n/**\n * Apply the final transformation of the data. If the user wants a Blob for\n * example, it's easier to work with an U8intArray and finally do the\n * ArrayBuffer/Blob conversion.\n * @param {String} type the name of the final type\n * @param {String|Uint8Array|Buffer} content the content to transform\n * @param {String} mimeType the mime type of the content, if applicable.\n * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.\n */\nfunction transformZipOutput(type, content, mimeType) {\n    switch(type) {\n    case \"blob\" :\n        return utils.newBlob(utils.transformTo(\"arraybuffer\", content), mimeType);\n    case \"base64\" :\n        return base64.encode(content);\n    default :\n        return utils.transformTo(type, content);\n    }\n}\n\n/**\n * Concatenate an array of data of the given type.\n * @param {String} type the type of the data in the given array.\n * @param {Array} dataArray the array containing the data chunks to concatenate\n * @return {String|Uint8Array|Buffer} the concatenated data\n * @throws Error if the asked type is unsupported\n */\nfunction concat (type, dataArray) {\n    var i, index = 0, res = null, totalLength = 0;\n    for(i = 0; i < dataArray.length; i++) {\n        totalLength += dataArray[i].length;\n    }\n    switch(type) {\n    case \"string\":\n        return dataArray.join(\"\");\n    case \"array\":\n        return Array.prototype.concat.apply([], dataArray);\n    case \"uint8array\":\n        res = new Uint8Array(totalLength);\n        for(i = 0; i < dataArray.length; i++) {\n            res.set(dataArray[i], index);\n            index += dataArray[i].length;\n        }\n        return res;\n    case \"nodebuffer\":\n        return Buffer.concat(dataArray);\n    default:\n        throw new Error(\"concat : unsupported type '\"  + type + \"'\");\n    }\n}\n\n/**\n * Listen a StreamHelper, accumulate its content and concatenate it into a\n * complete block.\n * @param {StreamHelper} helper the helper to use.\n * @param {Function} updateCallback a callback called on each update. Called\n * with one arg :\n * - the metadata linked to the update received.\n * @return Promise the promise for the accumulation.\n */\nfunction accumulate(helper, updateCallback) {\n    return new external.Promise(function (resolve, reject){\n        var dataArray = [];\n        var chunkType = helper._internalType,\n            resultType = helper._outputType,\n            mimeType = helper._mimeType;\n        helper\n            .on(\"data\", function (data, meta) {\n                dataArray.push(data);\n                if(updateCallback) {\n                    updateCallback(meta);\n                }\n            })\n            .on(\"error\", function(err) {\n                dataArray = [];\n                reject(err);\n            })\n            .on(\"end\", function (){\n                try {\n                    var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);\n                    resolve(result);\n                } catch (e) {\n                    reject(e);\n                }\n                dataArray = [];\n            })\n            .resume();\n    });\n}\n\n/**\n * An helper to easily use workers outside of JSZip.\n * @constructor\n * @param {Worker} worker the worker to wrap\n * @param {String} outputType the type of data expected by the use\n * @param {String} mimeType the mime type of the content, if applicable.\n */\nfunction StreamHelper(worker, outputType, mimeType) {\n    var internalType = outputType;\n    switch(outputType) {\n    case \"blob\":\n    case \"arraybuffer\":\n        internalType = \"uint8array\";\n        break;\n    case \"base64\":\n        internalType = \"string\";\n        break;\n    }\n\n    try {\n        // the type used internally\n        this._internalType = internalType;\n        // the type used to output results\n        this._outputType = outputType;\n        // the mime type\n        this._mimeType = mimeType;\n        utils.checkSupport(internalType);\n        this._worker = worker.pipe(new ConvertWorker(internalType));\n        // the last workers can be rewired without issues but we need to\n        // prevent any updates on previous workers.\n        worker.lock();\n    } catch(e) {\n        this._worker = new GenericWorker(\"error\");\n        this._worker.error(e);\n    }\n}\n\nStreamHelper.prototype = {\n    /**\n     * Listen a StreamHelper, accumulate its content and concatenate it into a\n     * complete block.\n     * @param {Function} updateCb the update callback.\n     * @return Promise the promise for the accumulation.\n     */\n    accumulate : function (updateCb) {\n        return accumulate(this, updateCb);\n    },\n    /**\n     * Add a listener on an event triggered on a stream.\n     * @param {String} evt the name of the event\n     * @param {Function} fn the listener\n     * @return {StreamHelper} the current helper.\n     */\n    on : function (evt, fn) {\n        var self = this;\n\n        if(evt === \"data\") {\n            this._worker.on(evt, function (chunk) {\n                fn.call(self, chunk.data, chunk.meta);\n            });\n        } else {\n            this._worker.on(evt, function () {\n                utils.delay(fn, arguments, self);\n            });\n        }\n        return this;\n    },\n    /**\n     * Resume the flow of chunks.\n     * @return {StreamHelper} the current helper.\n     */\n    resume : function () {\n        utils.delay(this._worker.resume, [], this._worker);\n        return this;\n    },\n    /**\n     * Pause the flow of chunks.\n     * @return {StreamHelper} the current helper.\n     */\n    pause : function () {\n        this._worker.pause();\n        return this;\n    },\n    /**\n     * Return a nodejs stream for this helper.\n     * @param {Function} updateCb the update callback.\n     * @return {NodejsStreamOutputAdapter} the nodejs stream.\n     */\n    toNodejsStream : function (updateCb) {\n        utils.checkSupport(\"nodestream\");\n        if (this._outputType !== \"nodebuffer\") {\n            // an object stream containing blob/arraybuffer/uint8array/string\n            // is strange and I don't know if it would be useful.\n            // I you find this comment and have a good usecase, please open a\n            // bug report !\n            throw new Error(this._outputType + \" is not supported by this method\");\n        }\n\n        return new NodejsStreamOutputAdapter(this, {\n            objectMode : this._outputType !== \"nodebuffer\"\n        }, updateCb);\n    }\n};\n\n\nmodule.exports = StreamHelper;\n\n},{\"../base64\":1,\"../external\":6,\"../nodejs/NodejsStreamOutputAdapter\":13,\"../support\":30,\"../utils\":32,\"./ConvertWorker\":24,\"./GenericWorker\":28}],30:[function(require,module,exports){\n\"use strict\";\n\nexports.base64 = true;\nexports.array = true;\nexports.string = true;\nexports.arraybuffer = typeof ArrayBuffer !== \"undefined\" && typeof Uint8Array !== \"undefined\";\nexports.nodebuffer = typeof Buffer !== \"undefined\";\n// contains true if JSZip can read/generate Uint8Array, false otherwise.\nexports.uint8array = typeof Uint8Array !== \"undefined\";\n\nif (typeof ArrayBuffer === \"undefined\") {\n    exports.blob = false;\n}\nelse {\n    var buffer = new ArrayBuffer(0);\n    try {\n        exports.blob = new Blob([buffer], {\n            type: \"application/zip\"\n        }).size === 0;\n    }\n    catch (e) {\n        try {\n            var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n            var builder = new Builder();\n            builder.append(buffer);\n            exports.blob = builder.getBlob(\"application/zip\").size === 0;\n        }\n        catch (e) {\n            exports.blob = false;\n        }\n    }\n}\n\ntry {\n    exports.nodestream = !!require(\"readable-stream\").Readable;\n} catch(e) {\n    exports.nodestream = false;\n}\n\n},{\"readable-stream\":16}],31:[function(require,module,exports){\n\"use strict\";\n\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * The following functions come from pako, from pako/lib/utils/strings\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Array(256);\nfor (var i=0; i<256; i++) {\n    _utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);\n}\n_utf8len[254]=_utf8len[254]=1; // Invalid sequence start\n\n// convert string to array (typed, when possible)\nvar string2buf = function (str) {\n    var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n    // count binary size\n    for (m_pos = 0; m_pos < str_len; m_pos++) {\n        c = str.charCodeAt(m_pos);\n        if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n            c2 = str.charCodeAt(m_pos+1);\n            if ((c2 & 0xfc00) === 0xdc00) {\n                c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n                m_pos++;\n            }\n        }\n        buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n    }\n\n    // allocate buffer\n    if (support.uint8array) {\n        buf = new Uint8Array(buf_len);\n    } else {\n        buf = new Array(buf_len);\n    }\n\n    // convert\n    for (i=0, m_pos = 0; i < buf_len; m_pos++) {\n        c = str.charCodeAt(m_pos);\n        if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n            c2 = str.charCodeAt(m_pos+1);\n            if ((c2 & 0xfc00) === 0xdc00) {\n                c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n                m_pos++;\n            }\n        }\n        if (c < 0x80) {\n            /* one byte */\n            buf[i++] = c;\n        } else if (c < 0x800) {\n            /* two bytes */\n            buf[i++] = 0xC0 | (c >>> 6);\n            buf[i++] = 0x80 | (c & 0x3f);\n        } else if (c < 0x10000) {\n            /* three bytes */\n            buf[i++] = 0xE0 | (c >>> 12);\n            buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n            buf[i++] = 0x80 | (c & 0x3f);\n        } else {\n            /* four bytes */\n            buf[i++] = 0xf0 | (c >>> 18);\n            buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n            buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n            buf[i++] = 0x80 | (c & 0x3f);\n        }\n    }\n\n    return buf;\n};\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max   - length limit (mandatory);\nvar utf8border = function(buf, max) {\n    var pos;\n\n    max = max || buf.length;\n    if (max > buf.length) { max = buf.length; }\n\n    // go back from last position, until start of sequence found\n    pos = max-1;\n    while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n    // Fuckup - very small and broken sequence,\n    // return max, because we should return something anyway.\n    if (pos < 0) { return max; }\n\n    // If we came to start of buffer - that means vuffer is too small,\n    // return max too.\n    if (pos === 0) { return max; }\n\n    return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n// convert array to string\nvar buf2string = function (buf) {\n    var i, out, c, c_len;\n    var len = buf.length;\n\n    // Reserve max possible length (2 words per char)\n    // NB: by unknown reasons, Array is significantly faster for\n    //     String.fromCharCode.apply than Uint16Array.\n    var utf16buf = new Array(len*2);\n\n    for (out=0, i=0; i<len;) {\n        c = buf[i++];\n        // quick process ascii\n        if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n        c_len = _utf8len[c];\n        // skip 5 & 6 byte codes\n        if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }\n\n        // apply mask on first byte\n        c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n        // join the rest\n        while (c_len > 1 && i < len) {\n            c = (c << 6) | (buf[i++] & 0x3f);\n            c_len--;\n        }\n\n        // terminated by end of string?\n        if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n        if (c < 0x10000) {\n            utf16buf[out++] = c;\n        } else {\n            c -= 0x10000;\n            utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n            utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n        }\n    }\n\n    // shrinkBuf(utf16buf, out)\n    if (utf16buf.length !== out) {\n        if(utf16buf.subarray) {\n            utf16buf = utf16buf.subarray(0, out);\n        } else {\n            utf16buf.length = out;\n        }\n    }\n\n    // return String.fromCharCode.apply(null, utf16buf);\n    return utils.applyFromCharCode(utf16buf);\n};\n\n\n// That's all for the pako functions.\n\n\n/**\n * Transform a javascript string into an array (typed if possible) of bytes,\n * UTF-8 encoded.\n * @param {String} str the string to encode\n * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.\n */\nexports.utf8encode = function utf8encode(str) {\n    if (support.nodebuffer) {\n        return nodejsUtils.newBufferFrom(str, \"utf-8\");\n    }\n\n    return string2buf(str);\n};\n\n\n/**\n * Transform a bytes array (or a representation) representing an UTF-8 encoded\n * string into a javascript string.\n * @param {Array|Uint8Array|Buffer} buf the data de decode\n * @return {String} the decoded string.\n */\nexports.utf8decode = function utf8decode(buf) {\n    if (support.nodebuffer) {\n        return utils.transformTo(\"nodebuffer\", buf).toString(\"utf-8\");\n    }\n\n    buf = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", buf);\n\n    return buf2string(buf);\n};\n\n/**\n * A worker to decode utf8 encoded binary chunks into string chunks.\n * @constructor\n */\nfunction Utf8DecodeWorker() {\n    GenericWorker.call(this, \"utf-8 decode\");\n    // the last bytes if a chunk didn't end with a complete codepoint.\n    this.leftOver = null;\n}\nutils.inherits(Utf8DecodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8DecodeWorker.prototype.processChunk = function (chunk) {\n\n    var data = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", chunk.data);\n\n    // 1st step, re-use what's left of the previous chunk\n    if (this.leftOver && this.leftOver.length) {\n        if(support.uint8array) {\n            var previousData = data;\n            data = new Uint8Array(previousData.length + this.leftOver.length);\n            data.set(this.leftOver, 0);\n            data.set(previousData, this.leftOver.length);\n        } else {\n            data = this.leftOver.concat(data);\n        }\n        this.leftOver = null;\n    }\n\n    var nextBoundary = utf8border(data);\n    var usableData = data;\n    if (nextBoundary !== data.length) {\n        if (support.uint8array) {\n            usableData = data.subarray(0, nextBoundary);\n            this.leftOver = data.subarray(nextBoundary, data.length);\n        } else {\n            usableData = data.slice(0, nextBoundary);\n            this.leftOver = data.slice(nextBoundary, data.length);\n        }\n    }\n\n    this.push({\n        data : exports.utf8decode(usableData),\n        meta : chunk.meta\n    });\n};\n\n/**\n * @see GenericWorker.flush\n */\nUtf8DecodeWorker.prototype.flush = function () {\n    if(this.leftOver && this.leftOver.length) {\n        this.push({\n            data : exports.utf8decode(this.leftOver),\n            meta : {}\n        });\n        this.leftOver = null;\n    }\n};\nexports.Utf8DecodeWorker = Utf8DecodeWorker;\n\n/**\n * A worker to endcode string chunks into utf8 encoded binary chunks.\n * @constructor\n */\nfunction Utf8EncodeWorker() {\n    GenericWorker.call(this, \"utf-8 encode\");\n}\nutils.inherits(Utf8EncodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8EncodeWorker.prototype.processChunk = function (chunk) {\n    this.push({\n        data : exports.utf8encode(chunk.data),\n        meta : chunk.meta\n    });\n};\nexports.Utf8EncodeWorker = Utf8EncodeWorker;\n\n},{\"./nodejsUtils\":14,\"./stream/GenericWorker\":28,\"./support\":30,\"./utils\":32}],32:[function(require,module,exports){\n\"use strict\";\n\nvar support = require(\"./support\");\nvar base64 = require(\"./base64\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar external = require(\"./external\");\nrequire(\"setimmediate\");\n\n\n/**\n * Convert a string that pass as a \"binary string\": it should represent a byte\n * array but may have > 255 char codes. Be sure to take only the first byte\n * and returns the byte array.\n * @param {String} str the string to transform.\n * @return {Array|Uint8Array} the string in a binary format.\n */\nfunction string2binary(str) {\n    var result = null;\n    if (support.uint8array) {\n        result = new Uint8Array(str.length);\n    } else {\n        result = new Array(str.length);\n    }\n    return stringToArrayLike(str, result);\n}\n\n/**\n * Create a new blob with the given content and the given type.\n * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use\n * an Uint8Array because the stock browser of android 4 won't accept it (it\n * will be silently converted to a string, \"[object Uint8Array]\").\n *\n * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:\n * when a large amount of Array is used to create the Blob, the amount of\n * memory consumed is nearly 100 times the original data amount.\n *\n * @param {String} type the mime type of the blob.\n * @return {Blob} the created blob.\n */\nexports.newBlob = function(part, type) {\n    exports.checkSupport(\"blob\");\n\n    try {\n        // Blob constructor\n        return new Blob([part], {\n            type: type\n        });\n    }\n    catch (e) {\n\n        try {\n            // deprecated, browser only, old way\n            var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n            var builder = new Builder();\n            builder.append(part);\n            return builder.getBlob(type);\n        }\n        catch (e) {\n\n            // well, fuck ?!\n            throw new Error(\"Bug : can't construct the Blob.\");\n        }\n    }\n\n\n};\n/**\n * The identity function.\n * @param {Object} input the input.\n * @return {Object} the same input.\n */\nfunction identity(input) {\n    return input;\n}\n\n/**\n * Fill in an array with a string.\n * @param {String} str the string to use.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.\n */\nfunction stringToArrayLike(str, array) {\n    for (var i = 0; i < str.length; ++i) {\n        array[i] = str.charCodeAt(i) & 0xFF;\n    }\n    return array;\n}\n\n/**\n * An helper for the function arrayLikeToString.\n * This contains static information and functions that\n * can be optimized by the browser JIT compiler.\n */\nvar arrayToStringHelper = {\n    /**\n     * Transform an array of int into a string, chunk by chunk.\n     * See the performances notes on arrayLikeToString.\n     * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n     * @param {String} type the type of the array.\n     * @param {Integer} chunk the chunk size.\n     * @return {String} the resulting string.\n     * @throws Error if the chunk is too big for the stack.\n     */\n    stringifyByChunk: function(array, type, chunk) {\n        var result = [], k = 0, len = array.length;\n        // shortcut\n        if (len <= chunk) {\n            return String.fromCharCode.apply(null, array);\n        }\n        while (k < len) {\n            if (type === \"array\" || type === \"nodebuffer\") {\n                result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));\n            }\n            else {\n                result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));\n            }\n            k += chunk;\n        }\n        return result.join(\"\");\n    },\n    /**\n     * Call String.fromCharCode on every item in the array.\n     * This is the naive implementation, which generate A LOT of intermediate string.\n     * This should be used when everything else fail.\n     * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n     * @return {String} the result.\n     */\n    stringifyByChar: function(array){\n        var resultStr = \"\";\n        for(var i = 0; i < array.length; i++) {\n            resultStr += String.fromCharCode(array[i]);\n        }\n        return resultStr;\n    },\n    applyCanBeUsed : {\n        /**\n         * true if the browser accepts to use String.fromCharCode on Uint8Array\n         */\n        uint8array : (function () {\n            try {\n                return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;\n            } catch (e) {\n                return false;\n            }\n        })(),\n        /**\n         * true if the browser accepts to use String.fromCharCode on nodejs Buffer.\n         */\n        nodebuffer : (function () {\n            try {\n                return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;\n            } catch (e) {\n                return false;\n            }\n        })()\n    }\n};\n\n/**\n * Transform an array-like object to a string.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\nfunction arrayLikeToString(array) {\n    // Performances notes :\n    // --------------------\n    // String.fromCharCode.apply(null, array) is the fastest, see\n    // see http://jsperf.com/converting-a-uint8array-to-a-string/2\n    // but the stack is limited (and we can get huge arrays !).\n    //\n    // result += String.fromCharCode(array[i]); generate too many strings !\n    //\n    // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2\n    // TODO : we now have workers that split the work. Do we still need that ?\n    var chunk = 65536,\n        type = exports.getTypeOf(array),\n        canUseApply = true;\n    if (type === \"uint8array\") {\n        canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;\n    } else if (type === \"nodebuffer\") {\n        canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;\n    }\n\n    if (canUseApply) {\n        while (chunk > 1) {\n            try {\n                return arrayToStringHelper.stringifyByChunk(array, type, chunk);\n            } catch (e) {\n                chunk = Math.floor(chunk / 2);\n            }\n        }\n    }\n\n    // no apply or chunk error : slow and painful algorithm\n    // default browser on android 4.*\n    return arrayToStringHelper.stringifyByChar(array);\n}\n\nexports.applyFromCharCode = arrayLikeToString;\n\n\n/**\n * Copy the data from an array-like to an other array-like.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.\n */\nfunction arrayLikeToArrayLike(arrayFrom, arrayTo) {\n    for (var i = 0; i < arrayFrom.length; i++) {\n        arrayTo[i] = arrayFrom[i];\n    }\n    return arrayTo;\n}\n\n// a matrix containing functions to transform everything into everything.\nvar transform = {};\n\n// string to ?\ntransform[\"string\"] = {\n    \"string\": identity,\n    \"array\": function(input) {\n        return stringToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return transform[\"string\"][\"uint8array\"](input).buffer;\n    },\n    \"uint8array\": function(input) {\n        return stringToArrayLike(input, new Uint8Array(input.length));\n    },\n    \"nodebuffer\": function(input) {\n        return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));\n    }\n};\n\n// array to ?\ntransform[\"array\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": identity,\n    \"arraybuffer\": function(input) {\n        return (new Uint8Array(input)).buffer;\n    },\n    \"uint8array\": function(input) {\n        return new Uint8Array(input);\n    },\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(input);\n    }\n};\n\n// arraybuffer to ?\ntransform[\"arraybuffer\"] = {\n    \"string\": function(input) {\n        return arrayLikeToString(new Uint8Array(input));\n    },\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));\n    },\n    \"arraybuffer\": identity,\n    \"uint8array\": function(input) {\n        return new Uint8Array(input);\n    },\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(new Uint8Array(input));\n    }\n};\n\n// uint8array to ?\ntransform[\"uint8array\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return input.buffer;\n    },\n    \"uint8array\": identity,\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(input);\n    }\n};\n\n// nodebuffer to ?\ntransform[\"nodebuffer\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return transform[\"nodebuffer\"][\"uint8array\"](input).buffer;\n    },\n    \"uint8array\": function(input) {\n        return arrayLikeToArrayLike(input, new Uint8Array(input.length));\n    },\n    \"nodebuffer\": identity\n};\n\n/**\n * Transform an input into any type.\n * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.\n * If no output type is specified, the unmodified input will be returned.\n * @param {String} outputType the output type.\n * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.\n * @throws {Error} an Error if the browser doesn't support the requested output type.\n */\nexports.transformTo = function(outputType, input) {\n    if (!input) {\n        // undefined, null, etc\n        // an empty string won't harm.\n        input = \"\";\n    }\n    if (!outputType) {\n        return input;\n    }\n    exports.checkSupport(outputType);\n    var inputType = exports.getTypeOf(input);\n    var result = transform[inputType][outputType](input);\n    return result;\n};\n\n/**\n * Resolve all relative path components, \".\" and \"..\", in a path. If these relative components\n * traverse above the root then the resulting path will only contain the final path component.\n *\n * All empty components, e.g. \"//\", are removed.\n * @param {string} path A path with / or \\ separators\n * @returns {string} The path with all relative path components resolved.\n */\nexports.resolve = function(path) {\n    var parts = path.split(\"/\");\n    var result = [];\n    for (var index = 0; index < parts.length; index++) {\n        var part = parts[index];\n        // Allow the first and last component to be empty for trailing slashes.\n        if (part === \".\" || (part === \"\" && index !== 0 && index !== parts.length - 1)) {\n            continue;\n        } else if (part === \"..\") {\n            result.pop();\n        } else {\n            result.push(part);\n        }\n    }\n    return result.join(\"/\");\n};\n\n/**\n * Return the type of the input.\n * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.\n * @param {Object} input the input to identify.\n * @return {String} the (lowercase) type of the input.\n */\nexports.getTypeOf = function(input) {\n    if (typeof input === \"string\") {\n        return \"string\";\n    }\n    if (Object.prototype.toString.call(input) === \"[object Array]\") {\n        return \"array\";\n    }\n    if (support.nodebuffer && nodejsUtils.isBuffer(input)) {\n        return \"nodebuffer\";\n    }\n    if (support.uint8array && input instanceof Uint8Array) {\n        return \"uint8array\";\n    }\n    if (support.arraybuffer && input instanceof ArrayBuffer) {\n        return \"arraybuffer\";\n    }\n};\n\n/**\n * Throw an exception if the type is not supported.\n * @param {String} type the type to check.\n * @throws {Error} an Error if the browser doesn't support the requested type.\n */\nexports.checkSupport = function(type) {\n    var supported = support[type.toLowerCase()];\n    if (!supported) {\n        throw new Error(type + \" is not supported by this platform\");\n    }\n};\n\nexports.MAX_VALUE_16BITS = 65535;\nexports.MAX_VALUE_32BITS = -1; // well, \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\" is parsed as -1\n\n/**\n * Prettify a string read as binary.\n * @param {string} str the string to prettify.\n * @return {string} a pretty string.\n */\nexports.pretty = function(str) {\n    var res = \"\",\n        code, i;\n    for (i = 0; i < (str || \"\").length; i++) {\n        code = str.charCodeAt(i);\n        res += \"\\\\x\" + (code < 16 ? \"0\" : \"\") + code.toString(16).toUpperCase();\n    }\n    return res;\n};\n\n/**\n * Defer the call of a function.\n * @param {Function} callback the function to call asynchronously.\n * @param {Array} args the arguments to give to the callback.\n */\nexports.delay = function(callback, args, self) {\n    setImmediate(function () {\n        callback.apply(self || null, args || []);\n    });\n};\n\n/**\n * Extends a prototype with an other, without calling a constructor with\n * side effects. Inspired by nodejs' `utils.inherits`\n * @param {Function} ctor the constructor to augment\n * @param {Function} superCtor the parent constructor to use\n */\nexports.inherits = function (ctor, superCtor) {\n    var Obj = function() {};\n    Obj.prototype = superCtor.prototype;\n    ctor.prototype = new Obj();\n};\n\n/**\n * Merge the objects passed as parameters into a new one.\n * @private\n * @param {...Object} var_args All objects to merge.\n * @return {Object} a new object with the data of the others.\n */\nexports.extend = function() {\n    var result = {}, i, attr;\n    for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers\n        for (attr in arguments[i]) {\n            if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === \"undefined\") {\n                result[attr] = arguments[i][attr];\n            }\n        }\n    }\n    return result;\n};\n\n/**\n * Transform arbitrary content into a Promise.\n * @param {String} name a name for the content being processed.\n * @param {Object} inputData the content to process.\n * @param {Boolean} isBinary true if the content is not an unicode string\n * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.\n * @param {Boolean} isBase64 true if the string content is encoded with base64.\n * @return {Promise} a promise in a format usable by JSZip.\n */\nexports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {\n\n    // if inputData is already a promise, this flatten it.\n    var promise = external.Promise.resolve(inputData).then(function(data) {\n\n\n        var isBlob = support.blob && (data instanceof Blob || [\"[object File]\", \"[object Blob]\"].indexOf(Object.prototype.toString.call(data)) !== -1);\n\n        if (isBlob && typeof FileReader !== \"undefined\") {\n            return new external.Promise(function (resolve, reject) {\n                var reader = new FileReader();\n\n                reader.onload = function(e) {\n                    resolve(e.target.result);\n                };\n                reader.onerror = function(e) {\n                    reject(e.target.error);\n                };\n                reader.readAsArrayBuffer(data);\n            });\n        } else {\n            return data;\n        }\n    });\n\n    return promise.then(function(data) {\n        var dataType = exports.getTypeOf(data);\n\n        if (!dataType) {\n            return external.Promise.reject(\n                new Error(\"Can't read the data of '\" + name + \"'. Is it \" +\n                          \"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?\")\n            );\n        }\n        // special case : it's way easier to work with Uint8Array than with ArrayBuffer\n        if (dataType === \"arraybuffer\") {\n            data = exports.transformTo(\"uint8array\", data);\n        } else if (dataType === \"string\") {\n            if (isBase64) {\n                data = base64.decode(data);\n            }\n            else if (isBinary) {\n                // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask\n                if (isOptimizedBinaryString !== true) {\n                    // this is a string, not in a base64 format.\n                    // Be sure that this is a correct \"binary string\"\n                    data = string2binary(data);\n                }\n            }\n        }\n        return data;\n    });\n};\n\n},{\"./base64\":1,\"./external\":6,\"./nodejsUtils\":14,\"./support\":30,\"setimmediate\":54}],33:[function(require,module,exports){\n\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar sig = require(\"./signature\");\nvar ZipEntry = require(\"./zipEntry\");\nvar support = require(\"./support\");\n//  class ZipEntries {{{\n/**\n * All the entries in the zip file.\n * @constructor\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntries(loadOptions) {\n    this.files = [];\n    this.loadOptions = loadOptions;\n}\nZipEntries.prototype = {\n    /**\n     * Check that the reader is on the specified signature.\n     * @param {string} expectedSignature the expected signature.\n     * @throws {Error} if it is an other signature.\n     */\n    checkSignature: function(expectedSignature) {\n        if (!this.reader.readAndCheckSignature(expectedSignature)) {\n            this.reader.index -= 4;\n            var signature = this.reader.readString(4);\n            throw new Error(\"Corrupted zip or bug: unexpected signature \" + \"(\" + utils.pretty(signature) + \", expected \" + utils.pretty(expectedSignature) + \")\");\n        }\n    },\n    /**\n     * Check if the given signature is at the given index.\n     * @param {number} askedIndex the index to check.\n     * @param {string} expectedSignature the signature to expect.\n     * @return {boolean} true if the signature is here, false otherwise.\n     */\n    isSignature: function(askedIndex, expectedSignature) {\n        var currentIndex = this.reader.index;\n        this.reader.setIndex(askedIndex);\n        var signature = this.reader.readString(4);\n        var result = signature === expectedSignature;\n        this.reader.setIndex(currentIndex);\n        return result;\n    },\n    /**\n     * Read the end of the central directory.\n     */\n    readBlockEndOfCentral: function() {\n        this.diskNumber = this.reader.readInt(2);\n        this.diskWithCentralDirStart = this.reader.readInt(2);\n        this.centralDirRecordsOnThisDisk = this.reader.readInt(2);\n        this.centralDirRecords = this.reader.readInt(2);\n        this.centralDirSize = this.reader.readInt(4);\n        this.centralDirOffset = this.reader.readInt(4);\n\n        this.zipCommentLength = this.reader.readInt(2);\n        // warning : the encoding depends of the system locale\n        // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.\n        // On a windows machine, this field is encoded with the localized windows code page.\n        var zipComment = this.reader.readData(this.zipCommentLength);\n        var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n        // To get consistent behavior with the generation part, we will assume that\n        // this is utf8 encoded unless specified otherwise.\n        var decodeContent = utils.transformTo(decodeParamType, zipComment);\n        this.zipComment = this.loadOptions.decodeFileName(decodeContent);\n    },\n    /**\n     * Read the end of the Zip 64 central directory.\n     * Not merged with the method readEndOfCentral :\n     * The end of central can coexist with its Zip64 brother,\n     * I don't want to read the wrong number of bytes !\n     */\n    readBlockZip64EndOfCentral: function() {\n        this.zip64EndOfCentralSize = this.reader.readInt(8);\n        this.reader.skip(4);\n        // this.versionMadeBy = this.reader.readString(2);\n        // this.versionNeeded = this.reader.readInt(2);\n        this.diskNumber = this.reader.readInt(4);\n        this.diskWithCentralDirStart = this.reader.readInt(4);\n        this.centralDirRecordsOnThisDisk = this.reader.readInt(8);\n        this.centralDirRecords = this.reader.readInt(8);\n        this.centralDirSize = this.reader.readInt(8);\n        this.centralDirOffset = this.reader.readInt(8);\n\n        this.zip64ExtensibleData = {};\n        var extraDataSize = this.zip64EndOfCentralSize - 44,\n            index = 0,\n            extraFieldId,\n            extraFieldLength,\n            extraFieldValue;\n        while (index < extraDataSize) {\n            extraFieldId = this.reader.readInt(2);\n            extraFieldLength = this.reader.readInt(4);\n            extraFieldValue = this.reader.readData(extraFieldLength);\n            this.zip64ExtensibleData[extraFieldId] = {\n                id: extraFieldId,\n                length: extraFieldLength,\n                value: extraFieldValue\n            };\n        }\n    },\n    /**\n     * Read the end of the Zip 64 central directory locator.\n     */\n    readBlockZip64EndOfCentralLocator: function() {\n        this.diskWithZip64CentralDirStart = this.reader.readInt(4);\n        this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);\n        this.disksCount = this.reader.readInt(4);\n        if (this.disksCount > 1) {\n            throw new Error(\"Multi-volumes zip are not supported\");\n        }\n    },\n    /**\n     * Read the local files, based on the offset read in the central part.\n     */\n    readLocalFiles: function() {\n        var i, file;\n        for (i = 0; i < this.files.length; i++) {\n            file = this.files[i];\n            this.reader.setIndex(file.localHeaderOffset);\n            this.checkSignature(sig.LOCAL_FILE_HEADER);\n            file.readLocalPart(this.reader);\n            file.handleUTF8();\n            file.processAttributes();\n        }\n    },\n    /**\n     * Read the central directory.\n     */\n    readCentralDir: function() {\n        var file;\n\n        this.reader.setIndex(this.centralDirOffset);\n        while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {\n            file = new ZipEntry({\n                zip64: this.zip64\n            }, this.loadOptions);\n            file.readCentralPart(this.reader);\n            this.files.push(file);\n        }\n\n        if (this.centralDirRecords !== this.files.length) {\n            if (this.centralDirRecords !== 0 && this.files.length === 0) {\n                // We expected some records but couldn't find ANY.\n                // This is really suspicious, as if something went wrong.\n                throw new Error(\"Corrupted zip or bug: expected \" + this.centralDirRecords + \" records in central dir, got \" + this.files.length);\n            } else {\n                // We found some records but not all.\n                // Something is wrong but we got something for the user: no error here.\n                // console.warn(\"expected\", this.centralDirRecords, \"records in central dir, got\", this.files.length);\n            }\n        }\n    },\n    /**\n     * Read the end of central directory.\n     */\n    readEndOfCentral: function() {\n        var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);\n        if (offset < 0) {\n            // Check if the content is a truncated zip or complete garbage.\n            // A \"LOCAL_FILE_HEADER\" is not required at the beginning (auto\n            // extractible zip for example) but it can give a good hint.\n            // If an ajax request was used without responseType, we will also\n            // get unreadable data.\n            var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);\n\n            if (isGarbage) {\n                throw new Error(\"Can't find end of central directory : is this a zip file ? \" +\n                                \"If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html\");\n            } else {\n                throw new Error(\"Corrupted zip: can't find end of central directory\");\n            }\n\n        }\n        this.reader.setIndex(offset);\n        var endOfCentralDirOffset = offset;\n        this.checkSignature(sig.CENTRAL_DIRECTORY_END);\n        this.readBlockEndOfCentral();\n\n\n        /* extract from the zip spec :\n            4)  If one of the fields in the end of central directory\n                record is too small to hold required data, the field\n                should be set to -1 (0xFFFF or 0xFFFFFFFF) and the\n                ZIP64 format record should be created.\n            5)  The end of central directory record and the\n                Zip64 end of central directory locator record must\n                reside on the same disk when splitting or spanning\n                an archive.\n         */\n        if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {\n            this.zip64 = true;\n\n            /*\n            Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from\n            the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents\n            all numbers as 64-bit double precision IEEE 754 floating point numbers.\n            So, we have 53bits for integers and bitwise operations treat everything as 32bits.\n            see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators\n            and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5\n            */\n\n            // should look for a zip64 EOCD locator\n            offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n            if (offset < 0) {\n                throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory locator\");\n            }\n            this.reader.setIndex(offset);\n            this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n            this.readBlockZip64EndOfCentralLocator();\n\n            // now the zip64 EOCD record\n            if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {\n                // console.warn(\"ZIP64 end of central directory not where expected.\");\n                this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n                if (this.relativeOffsetEndOfZip64CentralDir < 0) {\n                    throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory\");\n                }\n            }\n            this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);\n            this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n            this.readBlockZip64EndOfCentral();\n        }\n\n        var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;\n        if (this.zip64) {\n            expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator\n            expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;\n        }\n\n        var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;\n\n        if (extraBytes > 0) {\n            // console.warn(extraBytes, \"extra bytes at beginning or within zipfile\");\n            if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {\n                // The offsets seem wrong, but we have something at the specified offset.\n                // So… we keep it.\n            } else {\n                // the offset is wrong, update the \"zero\" of the reader\n                // this happens if data has been prepended (crx files for example)\n                this.reader.zero = extraBytes;\n            }\n        } else if (extraBytes < 0) {\n            throw new Error(\"Corrupted zip: missing \" + Math.abs(extraBytes) + \" bytes.\");\n        }\n    },\n    prepareReader: function(data) {\n        this.reader = readerFor(data);\n    },\n    /**\n     * Read a zip file and create ZipEntries.\n     * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.\n     */\n    load: function(data) {\n        this.prepareReader(data);\n        this.readEndOfCentral();\n        this.readCentralDir();\n        this.readLocalFiles();\n    }\n};\n// }}} end of ZipEntries\nmodule.exports = ZipEntries;\n\n},{\"./reader/readerFor\":22,\"./signature\":23,\"./support\":30,\"./utils\":32,\"./zipEntry\":34}],34:[function(require,module,exports){\n\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar CompressedObject = require(\"./compressedObject\");\nvar crc32fn = require(\"./crc32\");\nvar utf8 = require(\"./utf8\");\nvar compressions = require(\"./compressions\");\nvar support = require(\"./support\");\n\nvar MADE_BY_DOS = 0x00;\nvar MADE_BY_UNIX = 0x03;\n\n/**\n * Find a compression registered in JSZip.\n * @param {string} compressionMethod the method magic to find.\n * @return {Object|null} the JSZip compression object, null if none found.\n */\nvar findCompression = function(compressionMethod) {\n    for (var method in compressions) {\n        if (!Object.prototype.hasOwnProperty.call(compressions, method)) {\n            continue;\n        }\n        if (compressions[method].magic === compressionMethod) {\n            return compressions[method];\n        }\n    }\n    return null;\n};\n\n// class ZipEntry {{{\n/**\n * An entry in the zip file.\n * @constructor\n * @param {Object} options Options of the current file.\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntry(options, loadOptions) {\n    this.options = options;\n    this.loadOptions = loadOptions;\n}\nZipEntry.prototype = {\n    /**\n     * say if the file is encrypted.\n     * @return {boolean} true if the file is encrypted, false otherwise.\n     */\n    isEncrypted: function() {\n        // bit 1 is set\n        return (this.bitFlag & 0x0001) === 0x0001;\n    },\n    /**\n     * say if the file has utf-8 filename/comment.\n     * @return {boolean} true if the filename/comment is in utf-8, false otherwise.\n     */\n    useUTF8: function() {\n        // bit 11 is set\n        return (this.bitFlag & 0x0800) === 0x0800;\n    },\n    /**\n     * Read the local part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readLocalPart: function(reader) {\n        var compression, localExtraFieldsLength;\n\n        // we already know everything from the central dir !\n        // If the central dir data are false, we are doomed.\n        // On the bright side, the local part is scary  : zip64, data descriptors, both, etc.\n        // The less data we get here, the more reliable this should be.\n        // Let's skip the whole header and dash to the data !\n        reader.skip(22);\n        // in some zip created on windows, the filename stored in the central dir contains \\ instead of /.\n        // Strangely, the filename here is OK.\n        // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes\n        // or APPNOTE#4.4.17.1, \"All slashes MUST be forward slashes '/'\") but there are a lot of bad zip generators...\n        // Search \"unzip mismatching \"local\" filename continuing with \"central\" filename version\" on\n        // the internet.\n        //\n        // I think I see the logic here : the central directory is used to display\n        // content and the local directory is used to extract the files. Mixing / and \\\n        // may be used to display \\ to windows users and use / when extracting the files.\n        // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394\n        this.fileNameLength = reader.readInt(2);\n        localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir\n        // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.\n        this.fileName = reader.readData(this.fileNameLength);\n        reader.skip(localExtraFieldsLength);\n\n        if (this.compressedSize === -1 || this.uncompressedSize === -1) {\n            throw new Error(\"Bug or corrupted zip : didn't get enough information from the central directory \" + \"(compressedSize === -1 || uncompressedSize === -1)\");\n        }\n\n        compression = findCompression(this.compressionMethod);\n        if (compression === null) { // no compression found\n            throw new Error(\"Corrupted zip : compression \" + utils.pretty(this.compressionMethod) + \" unknown (inner file : \" + utils.transformTo(\"string\", this.fileName) + \")\");\n        }\n        this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));\n    },\n\n    /**\n     * Read the central part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readCentralPart: function(reader) {\n        this.versionMadeBy = reader.readInt(2);\n        reader.skip(2);\n        // this.versionNeeded = reader.readInt(2);\n        this.bitFlag = reader.readInt(2);\n        this.compressionMethod = reader.readString(2);\n        this.date = reader.readDate();\n        this.crc32 = reader.readInt(4);\n        this.compressedSize = reader.readInt(4);\n        this.uncompressedSize = reader.readInt(4);\n        var fileNameLength = reader.readInt(2);\n        this.extraFieldsLength = reader.readInt(2);\n        this.fileCommentLength = reader.readInt(2);\n        this.diskNumberStart = reader.readInt(2);\n        this.internalFileAttributes = reader.readInt(2);\n        this.externalFileAttributes = reader.readInt(4);\n        this.localHeaderOffset = reader.readInt(4);\n\n        if (this.isEncrypted()) {\n            throw new Error(\"Encrypted zip are not supported\");\n        }\n\n        // will be read in the local part, see the comments there\n        reader.skip(fileNameLength);\n        this.readExtraFields(reader);\n        this.parseZIP64ExtraField(reader);\n        this.fileComment = reader.readData(this.fileCommentLength);\n    },\n\n    /**\n     * Parse the external file attributes and get the unix/dos permissions.\n     */\n    processAttributes: function () {\n        this.unixPermissions = null;\n        this.dosPermissions = null;\n        var madeBy = this.versionMadeBy >> 8;\n\n        // Check if we have the DOS directory flag set.\n        // We look for it in the DOS and UNIX permissions\n        // but some unknown platform could set it as a compatibility flag.\n        this.dir = this.externalFileAttributes & 0x0010 ? true : false;\n\n        if(madeBy === MADE_BY_DOS) {\n            // first 6 bits (0 to 5)\n            this.dosPermissions = this.externalFileAttributes & 0x3F;\n        }\n\n        if(madeBy === MADE_BY_UNIX) {\n            this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;\n            // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);\n        }\n\n        // fail safe : if the name ends with a / it probably means a folder\n        if (!this.dir && this.fileNameStr.slice(-1) === \"/\") {\n            this.dir = true;\n        }\n    },\n\n    /**\n     * Parse the ZIP64 extra field and merge the info in the current ZipEntry.\n     * @param {DataReader} reader the reader to use.\n     */\n    parseZIP64ExtraField: function() {\n        if (!this.extraFields[0x0001]) {\n            return;\n        }\n\n        // should be something, preparing the extra reader\n        var extraReader = readerFor(this.extraFields[0x0001].value);\n\n        // I really hope that these 64bits integer can fit in 32 bits integer, because js\n        // won't let us have more.\n        if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {\n            this.uncompressedSize = extraReader.readInt(8);\n        }\n        if (this.compressedSize === utils.MAX_VALUE_32BITS) {\n            this.compressedSize = extraReader.readInt(8);\n        }\n        if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {\n            this.localHeaderOffset = extraReader.readInt(8);\n        }\n        if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {\n            this.diskNumberStart = extraReader.readInt(4);\n        }\n    },\n    /**\n     * Read the central part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readExtraFields: function(reader) {\n        var end = reader.index + this.extraFieldsLength,\n            extraFieldId,\n            extraFieldLength,\n            extraFieldValue;\n\n        if (!this.extraFields) {\n            this.extraFields = {};\n        }\n\n        while (reader.index + 4 < end) {\n            extraFieldId = reader.readInt(2);\n            extraFieldLength = reader.readInt(2);\n            extraFieldValue = reader.readData(extraFieldLength);\n\n            this.extraFields[extraFieldId] = {\n                id: extraFieldId,\n                length: extraFieldLength,\n                value: extraFieldValue\n            };\n        }\n\n        reader.setIndex(end);\n    },\n    /**\n     * Apply an UTF8 transformation if needed.\n     */\n    handleUTF8: function() {\n        var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n        if (this.useUTF8()) {\n            this.fileNameStr = utf8.utf8decode(this.fileName);\n            this.fileCommentStr = utf8.utf8decode(this.fileComment);\n        } else {\n            var upath = this.findExtraFieldUnicodePath();\n            if (upath !== null) {\n                this.fileNameStr = upath;\n            } else {\n                // ASCII text or unsupported code page\n                var fileNameByteArray =  utils.transformTo(decodeParamType, this.fileName);\n                this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);\n            }\n\n            var ucomment = this.findExtraFieldUnicodeComment();\n            if (ucomment !== null) {\n                this.fileCommentStr = ucomment;\n            } else {\n                // ASCII text or unsupported code page\n                var commentByteArray =  utils.transformTo(decodeParamType, this.fileComment);\n                this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);\n            }\n        }\n    },\n\n    /**\n     * Find the unicode path declared in the extra field, if any.\n     * @return {String} the unicode path, null otherwise.\n     */\n    findExtraFieldUnicodePath: function() {\n        var upathField = this.extraFields[0x7075];\n        if (upathField) {\n            var extraReader = readerFor(upathField.value);\n\n            // wrong version\n            if (extraReader.readInt(1) !== 1) {\n                return null;\n            }\n\n            // the crc of the filename changed, this field is out of date.\n            if (crc32fn(this.fileName) !== extraReader.readInt(4)) {\n                return null;\n            }\n\n            return utf8.utf8decode(extraReader.readData(upathField.length - 5));\n        }\n        return null;\n    },\n\n    /**\n     * Find the unicode comment declared in the extra field, if any.\n     * @return {String} the unicode comment, null otherwise.\n     */\n    findExtraFieldUnicodeComment: function() {\n        var ucommentField = this.extraFields[0x6375];\n        if (ucommentField) {\n            var extraReader = readerFor(ucommentField.value);\n\n            // wrong version\n            if (extraReader.readInt(1) !== 1) {\n                return null;\n            }\n\n            // the crc of the comment changed, this field is out of date.\n            if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {\n                return null;\n            }\n\n            return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));\n        }\n        return null;\n    }\n};\nmodule.exports = ZipEntry;\n\n},{\"./compressedObject\":2,\"./compressions\":3,\"./crc32\":4,\"./reader/readerFor\":22,\"./support\":30,\"./utf8\":31,\"./utils\":32}],35:[function(require,module,exports){\n\"use strict\";\n\nvar StreamHelper = require(\"./stream/StreamHelper\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar utf8 = require(\"./utf8\");\nvar CompressedObject = require(\"./compressedObject\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * A simple object representing a file in the zip file.\n * @constructor\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data\n * @param {Object} options the options of the file\n */\nvar ZipObject = function(name, data, options) {\n    this.name = name;\n    this.dir = options.dir;\n    this.date = options.date;\n    this.comment = options.comment;\n    this.unixPermissions = options.unixPermissions;\n    this.dosPermissions = options.dosPermissions;\n\n    this._data = data;\n    this._dataBinary = options.binary;\n    // keep only the compression\n    this.options = {\n        compression : options.compression,\n        compressionOptions : options.compressionOptions\n    };\n};\n\nZipObject.prototype = {\n    /**\n     * Create an internal stream for the content of this object.\n     * @param {String} type the type of each chunk.\n     * @return StreamHelper the stream.\n     */\n    internalStream: function (type) {\n        var result = null, outputType = \"string\";\n        try {\n            if (!type) {\n                throw new Error(\"No output type specified.\");\n            }\n            outputType = type.toLowerCase();\n            var askUnicodeString = outputType === \"string\" || outputType === \"text\";\n            if (outputType === \"binarystring\" || outputType === \"text\") {\n                outputType = \"string\";\n            }\n            result = this._decompressWorker();\n\n            var isUnicodeString = !this._dataBinary;\n\n            if (isUnicodeString && !askUnicodeString) {\n                result = result.pipe(new utf8.Utf8EncodeWorker());\n            }\n            if (!isUnicodeString && askUnicodeString) {\n                result = result.pipe(new utf8.Utf8DecodeWorker());\n            }\n        } catch (e) {\n            result = new GenericWorker(\"error\");\n            result.error(e);\n        }\n\n        return new StreamHelper(result, outputType, \"\");\n    },\n\n    /**\n     * Prepare the content in the asked type.\n     * @param {String} type the type of the result.\n     * @param {Function} onUpdate a function to call on each internal update.\n     * @return Promise the promise of the result.\n     */\n    async: function (type, onUpdate) {\n        return this.internalStream(type).accumulate(onUpdate);\n    },\n\n    /**\n     * Prepare the content as a nodejs stream.\n     * @param {String} type the type of each chunk.\n     * @param {Function} onUpdate a function to call on each internal update.\n     * @return Stream the stream.\n     */\n    nodeStream: function (type, onUpdate) {\n        return this.internalStream(type || \"nodebuffer\").toNodejsStream(onUpdate);\n    },\n\n    /**\n     * Return a worker for the compressed content.\n     * @private\n     * @param {Object} compression the compression object to use.\n     * @param {Object} compressionOptions the options to use when compressing.\n     * @return Worker the worker.\n     */\n    _compressWorker: function (compression, compressionOptions) {\n        if (\n            this._data instanceof CompressedObject &&\n            this._data.compression.magic === compression.magic\n        ) {\n            return this._data.getCompressedWorker();\n        } else {\n            var result = this._decompressWorker();\n            if(!this._dataBinary) {\n                result = result.pipe(new utf8.Utf8EncodeWorker());\n            }\n            return CompressedObject.createWorkerFrom(result, compression, compressionOptions);\n        }\n    },\n    /**\n     * Return a worker for the decompressed content.\n     * @private\n     * @return Worker the worker.\n     */\n    _decompressWorker : function () {\n        if (this._data instanceof CompressedObject) {\n            return this._data.getContentWorker();\n        } else if (this._data instanceof GenericWorker) {\n            return this._data;\n        } else {\n            return new DataWorker(this._data);\n        }\n    }\n};\n\nvar removedMethods = [\"asText\", \"asBinary\", \"asNodeBuffer\", \"asUint8Array\", \"asArrayBuffer\"];\nvar removedFn = function () {\n    throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n};\n\nfor(var i = 0; i < removedMethods.length; i++) {\n    ZipObject.prototype[removedMethods[i]] = removedFn;\n}\nmodule.exports = ZipObject;\n\n},{\"./compressedObject\":2,\"./stream/DataWorker\":27,\"./stream/GenericWorker\":28,\"./stream/StreamHelper\":29,\"./utf8\":31}],36:[function(require,module,exports){\n(function (global){\n'use strict';\nvar Mutation = global.MutationObserver || global.WebKitMutationObserver;\n\nvar scheduleDrain;\n\n{\n  if (Mutation) {\n    var called = 0;\n    var observer = new Mutation(nextTick);\n    var element = global.document.createTextNode('');\n    observer.observe(element, {\n      characterData: true\n    });\n    scheduleDrain = function () {\n      element.data = (called = ++called % 2);\n    };\n  } else if (!global.setImmediate && typeof global.MessageChannel !== 'undefined') {\n    var channel = new global.MessageChannel();\n    channel.port1.onmessage = nextTick;\n    scheduleDrain = function () {\n      channel.port2.postMessage(0);\n    };\n  } else if ('document' in global && 'onreadystatechange' in global.document.createElement('script')) {\n    scheduleDrain = function () {\n\n      // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n      // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n      var scriptEl = global.document.createElement('script');\n      scriptEl.onreadystatechange = function () {\n        nextTick();\n\n        scriptEl.onreadystatechange = null;\n        scriptEl.parentNode.removeChild(scriptEl);\n        scriptEl = null;\n      };\n      global.document.documentElement.appendChild(scriptEl);\n    };\n  } else {\n    scheduleDrain = function () {\n      setTimeout(nextTick, 0);\n    };\n  }\n}\n\nvar draining;\nvar queue = [];\n//named nextTick for less confusing stack traces\nfunction nextTick() {\n  draining = true;\n  var i, oldQueue;\n  var len = queue.length;\n  while (len) {\n    oldQueue = queue;\n    queue = [];\n    i = -1;\n    while (++i < len) {\n      oldQueue[i]();\n    }\n    len = queue.length;\n  }\n  draining = false;\n}\n\nmodule.exports = immediate;\nfunction immediate(task) {\n  if (queue.push(task) === 1 && !draining) {\n    scheduleDrain();\n  }\n}\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}],37:[function(require,module,exports){\n'use strict';\nvar immediate = require('immediate');\n\n/* istanbul ignore next */\nfunction INTERNAL() {}\n\nvar handlers = {};\n\nvar REJECTED = ['REJECTED'];\nvar FULFILLED = ['FULFILLED'];\nvar PENDING = ['PENDING'];\n\nmodule.exports = Promise;\n\nfunction Promise(resolver) {\n  if (typeof resolver !== 'function') {\n    throw new TypeError('resolver must be a function');\n  }\n  this.state = PENDING;\n  this.queue = [];\n  this.outcome = void 0;\n  if (resolver !== INTERNAL) {\n    safelyResolveThenable(this, resolver);\n  }\n}\n\nPromise.prototype[\"finally\"] = function (callback) {\n  if (typeof callback !== 'function') {\n    return this;\n  }\n  var p = this.constructor;\n  return this.then(resolve, reject);\n\n  function resolve(value) {\n    function yes () {\n      return value;\n    }\n    return p.resolve(callback()).then(yes);\n  }\n  function reject(reason) {\n    function no () {\n      throw reason;\n    }\n    return p.resolve(callback()).then(no);\n  }\n};\nPromise.prototype[\"catch\"] = function (onRejected) {\n  return this.then(null, onRejected);\n};\nPromise.prototype.then = function (onFulfilled, onRejected) {\n  if (typeof onFulfilled !== 'function' && this.state === FULFILLED ||\n    typeof onRejected !== 'function' && this.state === REJECTED) {\n    return this;\n  }\n  var promise = new this.constructor(INTERNAL);\n  if (this.state !== PENDING) {\n    var resolver = this.state === FULFILLED ? onFulfilled : onRejected;\n    unwrap(promise, resolver, this.outcome);\n  } else {\n    this.queue.push(new QueueItem(promise, onFulfilled, onRejected));\n  }\n\n  return promise;\n};\nfunction QueueItem(promise, onFulfilled, onRejected) {\n  this.promise = promise;\n  if (typeof onFulfilled === 'function') {\n    this.onFulfilled = onFulfilled;\n    this.callFulfilled = this.otherCallFulfilled;\n  }\n  if (typeof onRejected === 'function') {\n    this.onRejected = onRejected;\n    this.callRejected = this.otherCallRejected;\n  }\n}\nQueueItem.prototype.callFulfilled = function (value) {\n  handlers.resolve(this.promise, value);\n};\nQueueItem.prototype.otherCallFulfilled = function (value) {\n  unwrap(this.promise, this.onFulfilled, value);\n};\nQueueItem.prototype.callRejected = function (value) {\n  handlers.reject(this.promise, value);\n};\nQueueItem.prototype.otherCallRejected = function (value) {\n  unwrap(this.promise, this.onRejected, value);\n};\n\nfunction unwrap(promise, func, value) {\n  immediate(function () {\n    var returnValue;\n    try {\n      returnValue = func(value);\n    } catch (e) {\n      return handlers.reject(promise, e);\n    }\n    if (returnValue === promise) {\n      handlers.reject(promise, new TypeError('Cannot resolve promise with itself'));\n    } else {\n      handlers.resolve(promise, returnValue);\n    }\n  });\n}\n\nhandlers.resolve = function (self, value) {\n  var result = tryCatch(getThen, value);\n  if (result.status === 'error') {\n    return handlers.reject(self, result.value);\n  }\n  var thenable = result.value;\n\n  if (thenable) {\n    safelyResolveThenable(self, thenable);\n  } else {\n    self.state = FULFILLED;\n    self.outcome = value;\n    var i = -1;\n    var len = self.queue.length;\n    while (++i < len) {\n      self.queue[i].callFulfilled(value);\n    }\n  }\n  return self;\n};\nhandlers.reject = function (self, error) {\n  self.state = REJECTED;\n  self.outcome = error;\n  var i = -1;\n  var len = self.queue.length;\n  while (++i < len) {\n    self.queue[i].callRejected(error);\n  }\n  return self;\n};\n\nfunction getThen(obj) {\n  // Make sure we only access the accessor once as required by the spec\n  var then = obj && obj.then;\n  if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') {\n    return function appyThen() {\n      then.apply(obj, arguments);\n    };\n  }\n}\n\nfunction safelyResolveThenable(self, thenable) {\n  // Either fulfill, reject or reject with error\n  var called = false;\n  function onError(value) {\n    if (called) {\n      return;\n    }\n    called = true;\n    handlers.reject(self, value);\n  }\n\n  function onSuccess(value) {\n    if (called) {\n      return;\n    }\n    called = true;\n    handlers.resolve(self, value);\n  }\n\n  function tryToUnwrap() {\n    thenable(onSuccess, onError);\n  }\n\n  var result = tryCatch(tryToUnwrap);\n  if (result.status === 'error') {\n    onError(result.value);\n  }\n}\n\nfunction tryCatch(func, value) {\n  var out = {};\n  try {\n    out.value = func(value);\n    out.status = 'success';\n  } catch (e) {\n    out.status = 'error';\n    out.value = e;\n  }\n  return out;\n}\n\nPromise.resolve = resolve;\nfunction resolve(value) {\n  if (value instanceof this) {\n    return value;\n  }\n  return handlers.resolve(new this(INTERNAL), value);\n}\n\nPromise.reject = reject;\nfunction reject(reason) {\n  var promise = new this(INTERNAL);\n  return handlers.reject(promise, reason);\n}\n\nPromise.all = all;\nfunction all(iterable) {\n  var self = this;\n  if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n    return this.reject(new TypeError('must be an array'));\n  }\n\n  var len = iterable.length;\n  var called = false;\n  if (!len) {\n    return this.resolve([]);\n  }\n\n  var values = new Array(len);\n  var resolved = 0;\n  var i = -1;\n  var promise = new this(INTERNAL);\n\n  while (++i < len) {\n    allResolver(iterable[i], i);\n  }\n  return promise;\n  function allResolver(value, i) {\n    self.resolve(value).then(resolveFromAll, function (error) {\n      if (!called) {\n        called = true;\n        handlers.reject(promise, error);\n      }\n    });\n    function resolveFromAll(outValue) {\n      values[i] = outValue;\n      if (++resolved === len && !called) {\n        called = true;\n        handlers.resolve(promise, values);\n      }\n    }\n  }\n}\n\nPromise.race = race;\nfunction race(iterable) {\n  var self = this;\n  if (Object.prototype.toString.call(iterable) !== '[object Array]') {\n    return this.reject(new TypeError('must be an array'));\n  }\n\n  var len = iterable.length;\n  var called = false;\n  if (!len) {\n    return this.resolve([]);\n  }\n\n  var i = -1;\n  var promise = new this(INTERNAL);\n\n  while (++i < len) {\n    resolver(iterable[i]);\n  }\n  return promise;\n  function resolver(value) {\n    self.resolve(value).then(function (response) {\n      if (!called) {\n        called = true;\n        handlers.resolve(promise, response);\n      }\n    }, function (error) {\n      if (!called) {\n        called = true;\n        handlers.reject(promise, error);\n      }\n    });\n  }\n}\n\n},{\"immediate\":36}],38:[function(require,module,exports){\n// Top level file is just a mixin of submodules & constants\n'use strict';\n\nvar assign    = require('./lib/utils/common').assign;\n\nvar deflate   = require('./lib/deflate');\nvar inflate   = require('./lib/inflate');\nvar constants = require('./lib/zlib/constants');\n\nvar pako = {};\n\nassign(pako, deflate, inflate, constants);\n\nmodule.exports = pako;\n\n},{\"./lib/deflate\":39,\"./lib/inflate\":40,\"./lib/utils/common\":41,\"./lib/zlib/constants\":44}],39:[function(require,module,exports){\n'use strict';\n\n\nvar zlib_deflate = require('./zlib/deflate');\nvar utils        = require('./utils/common');\nvar strings      = require('./utils/strings');\nvar msg          = require('./zlib/messages');\nvar ZStream      = require('./zlib/zstream');\n\nvar toString = Object.prototype.toString;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\nvar Z_NO_FLUSH      = 0;\nvar Z_FINISH        = 4;\n\nvar Z_OK            = 0;\nvar Z_STREAM_END    = 1;\nvar Z_SYNC_FLUSH    = 2;\n\nvar Z_DEFAULT_COMPRESSION = -1;\n\nvar Z_DEFAULT_STRATEGY    = 0;\n\nvar Z_DEFLATED  = 8;\n\n/* ===========================================================================*/\n\n\n/**\n * class Deflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[deflate]],\n * [[deflateRaw]] and [[gzip]].\n **/\n\n/* internal\n * Deflate.chunks -> Array\n *\n * Chunks of output data, if [[Deflate#onData]] not overriden.\n **/\n\n/**\n * Deflate.result -> Uint8Array|Array\n *\n * Compressed result, generated by default [[Deflate#onData]]\n * and [[Deflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Deflate#push]] with `Z_FINISH` / `true` param)  or if you\n * push a chunk with explicit flush (call [[Deflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Deflate.err -> Number\n *\n * Error code after deflate finished. 0 (Z_OK) on success.\n * You will not need it in real life, because deflate errors\n * are possible only on wrong options or bad `onData` / `onEnd`\n * custom handlers.\n **/\n\n/**\n * Deflate.msg -> String\n *\n * Error message, if [[Deflate.err]] != 0\n **/\n\n\n/**\n * new Deflate(options)\n * - options (Object): zlib deflate options.\n *\n * Creates new deflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `level`\n * - `windowBits`\n * - `memLevel`\n * - `strategy`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw deflate\n * - `gzip` (Boolean) - create gzip wrapper\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n *    (each char code [0..255])\n * - `header` (Object) - custom header for gzip\n *   - `text` (Boolean) - true if compressed data believed to be text\n *   - `time` (Number) - modification time, unix timestamp\n *   - `os` (Number) - operation system code\n *   - `extra` (Array) - array of bytes with extra data (max 65536)\n *   - `name` (String) - file name (binary string)\n *   - `comment` (String) - comment (binary string)\n *   - `hcrc` (Boolean) - true if header crc should be added\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n *   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n *   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var deflate = new pako.Deflate({ level: 3});\n *\n * deflate.push(chunk1, false);\n * deflate.push(chunk2, true);  // true -> last chunk\n *\n * if (deflate.err) { throw new Error(deflate.err); }\n *\n * console.log(deflate.result);\n * ```\n **/\nfunction Deflate(options) {\n  if (!(this instanceof Deflate)) return new Deflate(options);\n\n  this.options = utils.assign({\n    level: Z_DEFAULT_COMPRESSION,\n    method: Z_DEFLATED,\n    chunkSize: 16384,\n    windowBits: 15,\n    memLevel: 8,\n    strategy: Z_DEFAULT_STRATEGY,\n    to: ''\n  }, options || {});\n\n  var opt = this.options;\n\n  if (opt.raw && (opt.windowBits > 0)) {\n    opt.windowBits = -opt.windowBits;\n  }\n\n  else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {\n    opt.windowBits += 16;\n  }\n\n  this.err    = 0;      // error code, if happens (0 = Z_OK)\n  this.msg    = '';     // error message\n  this.ended  = false;  // used to avoid multiple onEnd() calls\n  this.chunks = [];     // chunks of compressed data\n\n  this.strm = new ZStream();\n  this.strm.avail_out = 0;\n\n  var status = zlib_deflate.deflateInit2(\n    this.strm,\n    opt.level,\n    opt.method,\n    opt.windowBits,\n    opt.memLevel,\n    opt.strategy\n  );\n\n  if (status !== Z_OK) {\n    throw new Error(msg[status]);\n  }\n\n  if (opt.header) {\n    zlib_deflate.deflateSetHeader(this.strm, opt.header);\n  }\n\n  if (opt.dictionary) {\n    var dict;\n    // Convert data if needed\n    if (typeof opt.dictionary === 'string') {\n      // If we need to compress text, change encoding to utf8.\n      dict = strings.string2buf(opt.dictionary);\n    } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {\n      dict = new Uint8Array(opt.dictionary);\n    } else {\n      dict = opt.dictionary;\n    }\n\n    status = zlib_deflate.deflateSetDictionary(this.strm, dict);\n\n    if (status !== Z_OK) {\n      throw new Error(msg[status]);\n    }\n\n    this._dict_set = true;\n  }\n}\n\n/**\n * Deflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be\n *   converted to utf8 byte sequence.\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to deflate pipe, generating [[Deflate#onData]] calls with\n * new compressed chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the compression context.\n *\n * On fail call [[Deflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * array format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true);  // push last chunk\n * ```\n **/\nDeflate.prototype.push = function (data, mode) {\n  var strm = this.strm;\n  var chunkSize = this.options.chunkSize;\n  var status, _mode;\n\n  if (this.ended) { return false; }\n\n  _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);\n\n  // Convert data if needed\n  if (typeof data === 'string') {\n    // If we need to compress text, change encoding to utf8.\n    strm.input = strings.string2buf(data);\n  } else if (toString.call(data) === '[object ArrayBuffer]') {\n    strm.input = new Uint8Array(data);\n  } else {\n    strm.input = data;\n  }\n\n  strm.next_in = 0;\n  strm.avail_in = strm.input.length;\n\n  do {\n    if (strm.avail_out === 0) {\n      strm.output = new utils.Buf8(chunkSize);\n      strm.next_out = 0;\n      strm.avail_out = chunkSize;\n    }\n    status = zlib_deflate.deflate(strm, _mode);    /* no bad return value */\n\n    if (status !== Z_STREAM_END && status !== Z_OK) {\n      this.onEnd(status);\n      this.ended = true;\n      return false;\n    }\n    if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {\n      if (this.options.to === 'string') {\n        this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));\n      } else {\n        this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n      }\n    }\n  } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);\n\n  // Finalize on the last chunk.\n  if (_mode === Z_FINISH) {\n    status = zlib_deflate.deflateEnd(this.strm);\n    this.onEnd(status);\n    this.ended = true;\n    return status === Z_OK;\n  }\n\n  // callback interim results if Z_SYNC_FLUSH.\n  if (_mode === Z_SYNC_FLUSH) {\n    this.onEnd(Z_OK);\n    strm.avail_out = 0;\n    return true;\n  }\n\n  return true;\n};\n\n\n/**\n * Deflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n *   on js engine support. When string output requested, each chunk\n *   will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nDeflate.prototype.onData = function (chunk) {\n  this.chunks.push(chunk);\n};\n\n\n/**\n * Deflate#onEnd(status) -> Void\n * - status (Number): deflate status. 0 (Z_OK) on success,\n *   other if not.\n *\n * Called once after you tell deflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nDeflate.prototype.onEnd = function (status) {\n  // On success - join\n  if (status === Z_OK) {\n    if (this.options.to === 'string') {\n      this.result = this.chunks.join('');\n    } else {\n      this.result = utils.flattenChunks(this.chunks);\n    }\n  }\n  this.chunks = [];\n  this.err = status;\n  this.msg = this.strm.msg;\n};\n\n\n/**\n * deflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * Compress `data` with deflate algorithm and `options`.\n *\n * Supported options are:\n *\n * - level\n * - windowBits\n * - memLevel\n * - strategy\n * - dictionary\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n *   negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be \"binary string\"\n *    (each char code [0..255])\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n *   , data = Uint8Array([1,2,3,4,5,6,7,8,9]);\n *\n * console.log(pako.deflate(data));\n * ```\n **/\nfunction deflate(input, options) {\n  var deflator = new Deflate(options);\n\n  deflator.push(input, true);\n\n  // That will never happens, if you don't cheat with options :)\n  if (deflator.err) { throw deflator.msg || msg[deflator.err]; }\n\n  return deflator.result;\n}\n\n\n/**\n * deflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction deflateRaw(input, options) {\n  options = options || {};\n  options.raw = true;\n  return deflate(input, options);\n}\n\n\n/**\n * gzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to compress.\n * - options (Object): zlib deflate options.\n *\n * The same as [[deflate]], but create gzip wrapper instead of\n * deflate one.\n **/\nfunction gzip(input, options) {\n  options = options || {};\n  options.gzip = true;\n  return deflate(input, options);\n}\n\n\nexports.Deflate = Deflate;\nexports.deflate = deflate;\nexports.deflateRaw = deflateRaw;\nexports.gzip = gzip;\n\n},{\"./utils/common\":41,\"./utils/strings\":42,\"./zlib/deflate\":46,\"./zlib/messages\":51,\"./zlib/zstream\":53}],40:[function(require,module,exports){\n'use strict';\n\n\nvar zlib_inflate = require('./zlib/inflate');\nvar utils        = require('./utils/common');\nvar strings      = require('./utils/strings');\nvar c            = require('./zlib/constants');\nvar msg          = require('./zlib/messages');\nvar ZStream      = require('./zlib/zstream');\nvar GZheader     = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n *   from utf8 to utf16 (javascript) string. When string output requested,\n *   chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n *   , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n *   , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true);  // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n  if (!(this instanceof Inflate)) return new Inflate(options);\n\n  this.options = utils.assign({\n    chunkSize: 16384,\n    windowBits: 0,\n    to: ''\n  }, options || {});\n\n  var opt = this.options;\n\n  // Force window size for `raw` data, if not set directly,\n  // because we have no header for autodetect.\n  if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n    opt.windowBits = -opt.windowBits;\n    if (opt.windowBits === 0) { opt.windowBits = -15; }\n  }\n\n  // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n  if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n      !(options && options.windowBits)) {\n    opt.windowBits += 32;\n  }\n\n  // Gzip header has no info about windows size, we can do autodetect only\n  // for deflate. So, if window size not set, force it to max when gzip possible\n  if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n    // bit 3 (16) -> gzipped data\n    // bit 4 (32) -> autodetect gzip/deflate\n    if ((opt.windowBits & 15) === 0) {\n      opt.windowBits |= 15;\n    }\n  }\n\n  this.err    = 0;      // error code, if happens (0 = Z_OK)\n  this.msg    = '';     // error message\n  this.ended  = false;  // used to avoid multiple onEnd() calls\n  this.chunks = [];     // chunks of compressed data\n\n  this.strm   = new ZStream();\n  this.strm.avail_out = 0;\n\n  var status  = zlib_inflate.inflateInit2(\n    this.strm,\n    opt.windowBits\n  );\n\n  if (status !== c.Z_OK) {\n    throw new Error(msg[status]);\n  }\n\n  this.header = new GZheader();\n\n  zlib_inflate.inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n *   See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true);  // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n  var strm = this.strm;\n  var chunkSize = this.options.chunkSize;\n  var dictionary = this.options.dictionary;\n  var status, _mode;\n  var next_out_utf8, tail, utf8str;\n  var dict;\n\n  // Flag to properly process Z_BUF_ERROR on testing inflate call\n  // when we check that all output data was flushed.\n  var allowBufError = false;\n\n  if (this.ended) { return false; }\n  _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);\n\n  // Convert data if needed\n  if (typeof data === 'string') {\n    // Only binary strings can be decompressed on practice\n    strm.input = strings.binstring2buf(data);\n  } else if (toString.call(data) === '[object ArrayBuffer]') {\n    strm.input = new Uint8Array(data);\n  } else {\n    strm.input = data;\n  }\n\n  strm.next_in = 0;\n  strm.avail_in = strm.input.length;\n\n  do {\n    if (strm.avail_out === 0) {\n      strm.output = new utils.Buf8(chunkSize);\n      strm.next_out = 0;\n      strm.avail_out = chunkSize;\n    }\n\n    status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);    /* no bad return value */\n\n    if (status === c.Z_NEED_DICT && dictionary) {\n      // Convert data if needed\n      if (typeof dictionary === 'string') {\n        dict = strings.string2buf(dictionary);\n      } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n        dict = new Uint8Array(dictionary);\n      } else {\n        dict = dictionary;\n      }\n\n      status = zlib_inflate.inflateSetDictionary(this.strm, dict);\n\n    }\n\n    if (status === c.Z_BUF_ERROR && allowBufError === true) {\n      status = c.Z_OK;\n      allowBufError = false;\n    }\n\n    if (status !== c.Z_STREAM_END && status !== c.Z_OK) {\n      this.onEnd(status);\n      this.ended = true;\n      return false;\n    }\n\n    if (strm.next_out) {\n      if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {\n\n        if (this.options.to === 'string') {\n\n          next_out_utf8 = strings.utf8border(strm.output, strm.next_out);\n\n          tail = strm.next_out - next_out_utf8;\n          utf8str = strings.buf2string(strm.output, next_out_utf8);\n\n          // move tail\n          strm.next_out = tail;\n          strm.avail_out = chunkSize - tail;\n          if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n          this.onData(utf8str);\n\n        } else {\n          this.onData(utils.shrinkBuf(strm.output, strm.next_out));\n        }\n      }\n    }\n\n    // When no more input data, we should check that internal inflate buffers\n    // are flushed. The only way to do it when avail_out = 0 - run one more\n    // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n    // Here we set flag to process this error properly.\n    //\n    // NOTE. Deflate does not return error in this case and does not needs such\n    // logic.\n    if (strm.avail_in === 0 && strm.avail_out === 0) {\n      allowBufError = true;\n    }\n\n  } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);\n\n  if (status === c.Z_STREAM_END) {\n    _mode = c.Z_FINISH;\n  }\n\n  // Finalize on the last chunk.\n  if (_mode === c.Z_FINISH) {\n    status = zlib_inflate.inflateEnd(this.strm);\n    this.onEnd(status);\n    this.ended = true;\n    return status === c.Z_OK;\n  }\n\n  // callback interim results if Z_SYNC_FLUSH.\n  if (_mode === c.Z_SYNC_FLUSH) {\n    this.onEnd(c.Z_OK);\n    strm.avail_out = 0;\n    return true;\n  }\n\n  return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n *   on js engine support. When string output requested, each chunk\n *   will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n  this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n *   other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n  // On success - join\n  if (status === c.Z_OK) {\n    if (this.options.to === 'string') {\n      // Glue & convert here, until we teach pako to send\n      // utf8 alligned strings to onData\n      this.result = this.chunks.join('');\n    } else {\n      this.result = utils.flattenChunks(this.chunks);\n    }\n  }\n  this.chunks = [];\n  this.err = status;\n  this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n *   negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n *   from utf8 to utf16 (javascript) string. When string output requested,\n *   chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n *   , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n *   , output;\n *\n * try {\n *   output = pako.inflate(input);\n * } catch (err)\n *   console.log(err);\n * }\n * ```\n **/\nfunction inflate(input, options) {\n  var inflator = new Inflate(options);\n\n  inflator.push(input, true);\n\n  // That will never happens, if you don't cheat with options :)\n  if (inflator.err) { throw inflator.msg || msg[inflator.err]; }\n\n  return inflator.result;\n}\n\n\n/**\n * inflateRaw(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * The same as [[inflate]], but creates raw data, without wrapper\n * (header and adler32 crc).\n **/\nfunction inflateRaw(input, options) {\n  options = options || {};\n  options.raw = true;\n  return inflate(input, options);\n}\n\n\n/**\n * ungzip(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Just shortcut to [[inflate]], because it autodetects format\n * by header.content. Done for convenience.\n **/\n\n\nexports.Inflate = Inflate;\nexports.inflate = inflate;\nexports.inflateRaw = inflateRaw;\nexports.ungzip  = inflate;\n\n},{\"./utils/common\":41,\"./utils/strings\":42,\"./zlib/constants\":44,\"./zlib/gzheader\":47,\"./zlib/inflate\":49,\"./zlib/messages\":51,\"./zlib/zstream\":53}],41:[function(require,module,exports){\n'use strict';\n\n\nvar TYPED_OK =  (typeof Uint8Array !== 'undefined') &&\n                (typeof Uint16Array !== 'undefined') &&\n                (typeof Int32Array !== 'undefined');\n\n\nexports.assign = function (obj /*from1, from2, from3, ...*/) {\n  var sources = Array.prototype.slice.call(arguments, 1);\n  while (sources.length) {\n    var source = sources.shift();\n    if (!source) { continue; }\n\n    if (typeof source !== 'object') {\n      throw new TypeError(source + 'must be non-object');\n    }\n\n    for (var p in source) {\n      if (source.hasOwnProperty(p)) {\n        obj[p] = source[p];\n      }\n    }\n  }\n\n  return obj;\n};\n\n\n// reduce buffer size, avoiding mem copy\nexports.shrinkBuf = function (buf, size) {\n  if (buf.length === size) { return buf; }\n  if (buf.subarray) { return buf.subarray(0, size); }\n  buf.length = size;\n  return buf;\n};\n\n\nvar fnTyped = {\n  arraySet: function (dest, src, src_offs, len, dest_offs) {\n    if (src.subarray && dest.subarray) {\n      dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n      return;\n    }\n    // Fallback to ordinary array\n    for (var i = 0; i < len; i++) {\n      dest[dest_offs + i] = src[src_offs + i];\n    }\n  },\n  // Join array of chunks to single array.\n  flattenChunks: function (chunks) {\n    var i, l, len, pos, chunk, result;\n\n    // calculate data length\n    len = 0;\n    for (i = 0, l = chunks.length; i < l; i++) {\n      len += chunks[i].length;\n    }\n\n    // join chunks\n    result = new Uint8Array(len);\n    pos = 0;\n    for (i = 0, l = chunks.length; i < l; i++) {\n      chunk = chunks[i];\n      result.set(chunk, pos);\n      pos += chunk.length;\n    }\n\n    return result;\n  }\n};\n\nvar fnUntyped = {\n  arraySet: function (dest, src, src_offs, len, dest_offs) {\n    for (var i = 0; i < len; i++) {\n      dest[dest_offs + i] = src[src_offs + i];\n    }\n  },\n  // Join array of chunks to single array.\n  flattenChunks: function (chunks) {\n    return [].concat.apply([], chunks);\n  }\n};\n\n\n// Enable/Disable typed arrays use, for testing\n//\nexports.setTyped = function (on) {\n  if (on) {\n    exports.Buf8  = Uint8Array;\n    exports.Buf16 = Uint16Array;\n    exports.Buf32 = Int32Array;\n    exports.assign(exports, fnTyped);\n  } else {\n    exports.Buf8  = Array;\n    exports.Buf16 = Array;\n    exports.Buf32 = Array;\n    exports.assign(exports, fnUntyped);\n  }\n};\n\nexports.setTyped(TYPED_OK);\n\n},{}],42:[function(require,module,exports){\n// String encode/decode helpers\n'use strict';\n\n\nvar utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new utils.Buf8(256);\nfor (var q = 0; q < 256; q++) {\n  _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nexports.string2buf = function (str) {\n  var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n  // count binary size\n  for (m_pos = 0; m_pos < str_len; m_pos++) {\n    c = str.charCodeAt(m_pos);\n    if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n      c2 = str.charCodeAt(m_pos + 1);\n      if ((c2 & 0xfc00) === 0xdc00) {\n        c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n        m_pos++;\n      }\n    }\n    buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n  }\n\n  // allocate buffer\n  buf = new utils.Buf8(buf_len);\n\n  // convert\n  for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n    c = str.charCodeAt(m_pos);\n    if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n      c2 = str.charCodeAt(m_pos + 1);\n      if ((c2 & 0xfc00) === 0xdc00) {\n        c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n        m_pos++;\n      }\n    }\n    if (c < 0x80) {\n      /* one byte */\n      buf[i++] = c;\n    } else if (c < 0x800) {\n      /* two bytes */\n      buf[i++] = 0xC0 | (c >>> 6);\n      buf[i++] = 0x80 | (c & 0x3f);\n    } else if (c < 0x10000) {\n      /* three bytes */\n      buf[i++] = 0xE0 | (c >>> 12);\n      buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n      buf[i++] = 0x80 | (c & 0x3f);\n    } else {\n      /* four bytes */\n      buf[i++] = 0xf0 | (c >>> 18);\n      buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n      buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n      buf[i++] = 0x80 | (c & 0x3f);\n    }\n  }\n\n  return buf;\n};\n\n// Helper (used in 2 places)\nfunction buf2binstring(buf, len) {\n  // use fallback for big arrays to avoid stack overflow\n  if (len < 65537) {\n    if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n      return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));\n    }\n  }\n\n  var result = '';\n  for (var i = 0; i < len; i++) {\n    result += String.fromCharCode(buf[i]);\n  }\n  return result;\n}\n\n\n// Convert byte array to binary string\nexports.buf2binstring = function (buf) {\n  return buf2binstring(buf, buf.length);\n};\n\n\n// Convert binary string (typed, when possible)\nexports.binstring2buf = function (str) {\n  var buf = new utils.Buf8(str.length);\n  for (var i = 0, len = buf.length; i < len; i++) {\n    buf[i] = str.charCodeAt(i);\n  }\n  return buf;\n};\n\n\n// convert array to string\nexports.buf2string = function (buf, max) {\n  var i, out, c, c_len;\n  var len = max || buf.length;\n\n  // Reserve max possible length (2 words per char)\n  // NB: by unknown reasons, Array is significantly faster for\n  //     String.fromCharCode.apply than Uint16Array.\n  var utf16buf = new Array(len * 2);\n\n  for (out = 0, i = 0; i < len;) {\n    c = buf[i++];\n    // quick process ascii\n    if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n    c_len = _utf8len[c];\n    // skip 5 & 6 byte codes\n    if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n    // apply mask on first byte\n    c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n    // join the rest\n    while (c_len > 1 && i < len) {\n      c = (c << 6) | (buf[i++] & 0x3f);\n      c_len--;\n    }\n\n    // terminated by end of string?\n    if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n    if (c < 0x10000) {\n      utf16buf[out++] = c;\n    } else {\n      c -= 0x10000;\n      utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n      utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n    }\n  }\n\n  return buf2binstring(utf16buf, out);\n};\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max   - length limit (mandatory);\nexports.utf8border = function (buf, max) {\n  var pos;\n\n  max = max || buf.length;\n  if (max > buf.length) { max = buf.length; }\n\n  // go back from last position, until start of sequence found\n  pos = max - 1;\n  while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n  // Fuckup - very small and broken sequence,\n  // return max, because we should return something anyway.\n  if (pos < 0) { return max; }\n\n  // If we came to start of buffer - that means vuffer is too small,\n  // return max too.\n  if (pos === 0) { return max; }\n\n  return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n},{\"./common\":41}],43:[function(require,module,exports){\n'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction adler32(adler, buf, len, pos) {\n  var s1 = (adler & 0xffff) |0,\n      s2 = ((adler >>> 16) & 0xffff) |0,\n      n = 0;\n\n  while (len !== 0) {\n    // Set limit ~ twice less than 5552, to keep\n    // s2 in 31-bits, because we force signed ints.\n    // in other case %= will fail.\n    n = len > 2000 ? 2000 : len;\n    len -= n;\n\n    do {\n      s1 = (s1 + buf[pos++]) |0;\n      s2 = (s2 + s1) |0;\n    } while (--n);\n\n    s1 %= 65521;\n    s2 %= 65521;\n  }\n\n  return (s1 | (s2 << 16)) |0;\n}\n\n\nmodule.exports = adler32;\n\n},{}],44:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n\n  /* Allowed flush values; see deflate() and inflate() below for details */\n  Z_NO_FLUSH:         0,\n  Z_PARTIAL_FLUSH:    1,\n  Z_SYNC_FLUSH:       2,\n  Z_FULL_FLUSH:       3,\n  Z_FINISH:           4,\n  Z_BLOCK:            5,\n  Z_TREES:            6,\n\n  /* Return codes for the compression/decompression functions. Negative values\n  * are errors, positive values are used for special but normal events.\n  */\n  Z_OK:               0,\n  Z_STREAM_END:       1,\n  Z_NEED_DICT:        2,\n  Z_ERRNO:           -1,\n  Z_STREAM_ERROR:    -2,\n  Z_DATA_ERROR:      -3,\n  //Z_MEM_ERROR:     -4,\n  Z_BUF_ERROR:       -5,\n  //Z_VERSION_ERROR: -6,\n\n  /* compression levels */\n  Z_NO_COMPRESSION:         0,\n  Z_BEST_SPEED:             1,\n  Z_BEST_COMPRESSION:       9,\n  Z_DEFAULT_COMPRESSION:   -1,\n\n\n  Z_FILTERED:               1,\n  Z_HUFFMAN_ONLY:           2,\n  Z_RLE:                    3,\n  Z_FIXED:                  4,\n  Z_DEFAULT_STRATEGY:       0,\n\n  /* Possible values of the data_type field (though see inflate()) */\n  Z_BINARY:                 0,\n  Z_TEXT:                   1,\n  //Z_ASCII:                1, // = Z_TEXT (deprecated)\n  Z_UNKNOWN:                2,\n\n  /* The deflate compression method */\n  Z_DEFLATED:               8\n  //Z_NULL:                 null // Use -1 or null inline, depending on var type\n};\n\n},{}],45:[function(require,module,exports){\n'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n  var c, table = [];\n\n  for (var n = 0; n < 256; n++) {\n    c = n;\n    for (var k = 0; k < 8; k++) {\n      c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n    }\n    table[n] = c;\n  }\n\n  return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n  var t = crcTable,\n      end = pos + len;\n\n  crc ^= -1;\n\n  for (var i = pos; i < end; i++) {\n    crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n  }\n\n  return (crc ^ (-1)); // >>> 0;\n}\n\n\nmodule.exports = crc32;\n\n},{}],46:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils   = require('../utils/common');\nvar trees   = require('./trees');\nvar adler32 = require('./adler32');\nvar crc32   = require('./crc32');\nvar msg     = require('./messages');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH      = 0;\nvar Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH    = 2;\nvar Z_FULL_FLUSH    = 3;\nvar Z_FINISH        = 4;\nvar Z_BLOCK         = 5;\n//var Z_TREES         = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK            = 0;\nvar Z_STREAM_END    = 1;\n//var Z_NEED_DICT     = 2;\n//var Z_ERRNO         = -1;\nvar Z_STREAM_ERROR  = -2;\nvar Z_DATA_ERROR    = -3;\n//var Z_MEM_ERROR     = -4;\nvar Z_BUF_ERROR     = -5;\n//var Z_VERSION_ERROR = -6;\n\n\n/* compression levels */\n//var Z_NO_COMPRESSION      = 0;\n//var Z_BEST_SPEED          = 1;\n//var Z_BEST_COMPRESSION    = 9;\nvar Z_DEFAULT_COMPRESSION = -1;\n\n\nvar Z_FILTERED            = 1;\nvar Z_HUFFMAN_ONLY        = 2;\nvar Z_RLE                 = 3;\nvar Z_FIXED               = 4;\nvar Z_DEFAULT_STRATEGY    = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\n//var Z_BINARY              = 0;\n//var Z_TEXT                = 1;\n//var Z_ASCII               = 1; // = Z_TEXT\nvar Z_UNKNOWN             = 2;\n\n\n/* The deflate compression method */\nvar Z_DEFLATED  = 8;\n\n/*============================================================================*/\n\n\nvar MAX_MEM_LEVEL = 9;\n/* Maximum value for memLevel in deflateInit2 */\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_MEM_LEVEL = 8;\n\n\nvar LENGTH_CODES  = 29;\n/* number of length codes, not counting the special END_BLOCK code */\nvar LITERALS      = 256;\n/* number of literal bytes 0..255 */\nvar L_CODES       = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\nvar D_CODES       = 30;\n/* number of distance codes */\nvar BL_CODES      = 19;\n/* number of codes used to transfer the bit lengths */\nvar HEAP_SIZE     = 2 * L_CODES + 1;\n/* maximum heap size */\nvar MAX_BITS  = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar MIN_MATCH = 3;\nvar MAX_MATCH = 258;\nvar MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1);\n\nvar PRESET_DICT = 0x20;\n\nvar INIT_STATE = 42;\nvar EXTRA_STATE = 69;\nvar NAME_STATE = 73;\nvar COMMENT_STATE = 91;\nvar HCRC_STATE = 103;\nvar BUSY_STATE = 113;\nvar FINISH_STATE = 666;\n\nvar BS_NEED_MORE      = 1; /* block not completed, need more input or more output */\nvar BS_BLOCK_DONE     = 2; /* block flush performed */\nvar BS_FINISH_STARTED = 3; /* finish started, need only more output at next deflate */\nvar BS_FINISH_DONE    = 4; /* finish done, accept no more input or output */\n\nvar OS_CODE = 0x03; // Unix :) . Don't detect, use this default.\n\nfunction err(strm, errorCode) {\n  strm.msg = msg[errorCode];\n  return errorCode;\n}\n\nfunction rank(f) {\n  return ((f) << 1) - ((f) > 4 ? 9 : 0);\n}\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n\n/* =========================================================================\n * Flush as much pending output as possible. All deflate() output goes\n * through this function so some applications may wish to modify it\n * to avoid allocating a large strm->output buffer and copying into it.\n * (See also read_buf()).\n */\nfunction flush_pending(strm) {\n  var s = strm.state;\n\n  //_tr_flush_bits(s);\n  var len = s.pending;\n  if (len > strm.avail_out) {\n    len = strm.avail_out;\n  }\n  if (len === 0) { return; }\n\n  utils.arraySet(strm.output, s.pending_buf, s.pending_out, len, strm.next_out);\n  strm.next_out += len;\n  s.pending_out += len;\n  strm.total_out += len;\n  strm.avail_out -= len;\n  s.pending -= len;\n  if (s.pending === 0) {\n    s.pending_out = 0;\n  }\n}\n\n\nfunction flush_block_only(s, last) {\n  trees._tr_flush_block(s, (s.block_start >= 0 ? s.block_start : -1), s.strstart - s.block_start, last);\n  s.block_start = s.strstart;\n  flush_pending(s.strm);\n}\n\n\nfunction put_byte(s, b) {\n  s.pending_buf[s.pending++] = b;\n}\n\n\n/* =========================================================================\n * Put a short in the pending buffer. The 16-bit value is put in MSB order.\n * IN assertion: the stream state is correct and there is enough room in\n * pending_buf.\n */\nfunction putShortMSB(s, b) {\n//  put_byte(s, (Byte)(b >> 8));\n//  put_byte(s, (Byte)(b & 0xff));\n  s.pending_buf[s.pending++] = (b >>> 8) & 0xff;\n  s.pending_buf[s.pending++] = b & 0xff;\n}\n\n\n/* ===========================================================================\n * Read a new buffer from the current input stream, update the adler32\n * and total number of bytes read.  All deflate() input goes through\n * this function so some applications may wish to modify it to avoid\n * allocating a large strm->input buffer and copying from it.\n * (See also flush_pending()).\n */\nfunction read_buf(strm, buf, start, size) {\n  var len = strm.avail_in;\n\n  if (len > size) { len = size; }\n  if (len === 0) { return 0; }\n\n  strm.avail_in -= len;\n\n  // zmemcpy(buf, strm->next_in, len);\n  utils.arraySet(buf, strm.input, strm.next_in, len, start);\n  if (strm.state.wrap === 1) {\n    strm.adler = adler32(strm.adler, buf, len, start);\n  }\n\n  else if (strm.state.wrap === 2) {\n    strm.adler = crc32(strm.adler, buf, len, start);\n  }\n\n  strm.next_in += len;\n  strm.total_in += len;\n\n  return len;\n}\n\n\n/* ===========================================================================\n * Set match_start to the longest match starting at the given string and\n * return its length. Matches shorter or equal to prev_length are discarded,\n * in which case the result is equal to prev_length and match_start is\n * garbage.\n * IN assertions: cur_match is the head of the hash chain for the current\n *   string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1\n * OUT assertion: the match length is not greater than s->lookahead.\n */\nfunction longest_match(s, cur_match) {\n  var chain_length = s.max_chain_length;      /* max hash chain length */\n  var scan = s.strstart; /* current string */\n  var match;                       /* matched string */\n  var len;                           /* length of current match */\n  var best_len = s.prev_length;              /* best match length so far */\n  var nice_match = s.nice_match;             /* stop if match long enough */\n  var limit = (s.strstart > (s.w_size - MIN_LOOKAHEAD)) ?\n      s.strstart - (s.w_size - MIN_LOOKAHEAD) : 0/*NIL*/;\n\n  var _win = s.window; // shortcut\n\n  var wmask = s.w_mask;\n  var prev  = s.prev;\n\n  /* Stop when cur_match becomes <= limit. To simplify the code,\n   * we prevent matches with the string of window index 0.\n   */\n\n  var strend = s.strstart + MAX_MATCH;\n  var scan_end1  = _win[scan + best_len - 1];\n  var scan_end   = _win[scan + best_len];\n\n  /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.\n   * It is easy to get rid of this optimization if necessary.\n   */\n  // Assert(s->hash_bits >= 8 && MAX_MATCH == 258, \"Code too clever\");\n\n  /* Do not waste too much time if we already have a good match: */\n  if (s.prev_length >= s.good_match) {\n    chain_length >>= 2;\n  }\n  /* Do not look for matches beyond the end of the input. This is necessary\n   * to make deflate deterministic.\n   */\n  if (nice_match > s.lookahead) { nice_match = s.lookahead; }\n\n  // Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, \"need lookahead\");\n\n  do {\n    // Assert(cur_match < s->strstart, \"no future\");\n    match = cur_match;\n\n    /* Skip to next match if the match length cannot increase\n     * or if the match length is less than 2.  Note that the checks below\n     * for insufficient lookahead only occur occasionally for performance\n     * reasons.  Therefore uninitialized memory will be accessed, and\n     * conditional jumps will be made that depend on those values.\n     * However the length of the match is limited to the lookahead, so\n     * the output of deflate is not affected by the uninitialized values.\n     */\n\n    if (_win[match + best_len]     !== scan_end  ||\n        _win[match + best_len - 1] !== scan_end1 ||\n        _win[match]                !== _win[scan] ||\n        _win[++match]              !== _win[scan + 1]) {\n      continue;\n    }\n\n    /* The check at best_len-1 can be removed because it will be made\n     * again later. (This heuristic is not always a win.)\n     * It is not necessary to compare scan[2] and match[2] since they\n     * are always equal when the other bytes match, given that\n     * the hash keys are equal and that HASH_BITS >= 8.\n     */\n    scan += 2;\n    match++;\n    // Assert(*scan == *match, \"match[2]?\");\n\n    /* We check for insufficient lookahead only every 8th comparison;\n     * the 256th check will be made at strstart+258.\n     */\n    do {\n      /*jshint noempty:false*/\n    } while (_win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             _win[++scan] === _win[++match] && _win[++scan] === _win[++match] &&\n             scan < strend);\n\n    // Assert(scan <= s->window+(unsigned)(s->window_size-1), \"wild scan\");\n\n    len = MAX_MATCH - (strend - scan);\n    scan = strend - MAX_MATCH;\n\n    if (len > best_len) {\n      s.match_start = cur_match;\n      best_len = len;\n      if (len >= nice_match) {\n        break;\n      }\n      scan_end1  = _win[scan + best_len - 1];\n      scan_end   = _win[scan + best_len];\n    }\n  } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length !== 0);\n\n  if (best_len <= s.lookahead) {\n    return best_len;\n  }\n  return s.lookahead;\n}\n\n\n/* ===========================================================================\n * Fill the window when the lookahead becomes insufficient.\n * Updates strstart and lookahead.\n *\n * IN assertion: lookahead < MIN_LOOKAHEAD\n * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD\n *    At least one byte has been read, or avail_in == 0; reads are\n *    performed for at least two bytes (required for the zip translate_eol\n *    option -- not supported here).\n */\nfunction fill_window(s) {\n  var _w_size = s.w_size;\n  var p, n, m, more, str;\n\n  //Assert(s->lookahead < MIN_LOOKAHEAD, \"already enough lookahead\");\n\n  do {\n    more = s.window_size - s.lookahead - s.strstart;\n\n    // JS ints have 32 bit, block below not needed\n    /* Deal with !@#$% 64K limit: */\n    //if (sizeof(int) <= 2) {\n    //    if (more == 0 && s->strstart == 0 && s->lookahead == 0) {\n    //        more = wsize;\n    //\n    //  } else if (more == (unsigned)(-1)) {\n    //        /* Very unlikely, but possible on 16 bit machine if\n    //         * strstart == 0 && lookahead == 1 (input done a byte at time)\n    //         */\n    //        more--;\n    //    }\n    //}\n\n\n    /* If the window is almost full and there is insufficient lookahead,\n     * move the upper half to the lower one to make room in the upper half.\n     */\n    if (s.strstart >= _w_size + (_w_size - MIN_LOOKAHEAD)) {\n\n      utils.arraySet(s.window, s.window, _w_size, _w_size, 0);\n      s.match_start -= _w_size;\n      s.strstart -= _w_size;\n      /* we now have strstart >= MAX_DIST */\n      s.block_start -= _w_size;\n\n      /* Slide the hash table (could be avoided with 32 bit values\n       at the expense of memory usage). We slide even when level == 0\n       to keep the hash table consistent if we switch back to level > 0\n       later. (Using level 0 permanently is not an optimal usage of\n       zlib, so we don't care about this pathological case.)\n       */\n\n      n = s.hash_size;\n      p = n;\n      do {\n        m = s.head[--p];\n        s.head[p] = (m >= _w_size ? m - _w_size : 0);\n      } while (--n);\n\n      n = _w_size;\n      p = n;\n      do {\n        m = s.prev[--p];\n        s.prev[p] = (m >= _w_size ? m - _w_size : 0);\n        /* If n is not on any hash chain, prev[n] is garbage but\n         * its value will never be used.\n         */\n      } while (--n);\n\n      more += _w_size;\n    }\n    if (s.strm.avail_in === 0) {\n      break;\n    }\n\n    /* If there was no sliding:\n     *    strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 &&\n     *    more == window_size - lookahead - strstart\n     * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1)\n     * => more >= window_size - 2*WSIZE + 2\n     * In the BIG_MEM or MMAP case (not yet supported),\n     *   window_size == input_size + MIN_LOOKAHEAD  &&\n     *   strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD.\n     * Otherwise, window_size == 2*WSIZE so more >= 2.\n     * If there was sliding, more >= WSIZE. So in all cases, more >= 2.\n     */\n    //Assert(more >= 2, \"more < 2\");\n    n = read_buf(s.strm, s.window, s.strstart + s.lookahead, more);\n    s.lookahead += n;\n\n    /* Initialize the hash value now that we have some input: */\n    if (s.lookahead + s.insert >= MIN_MATCH) {\n      str = s.strstart - s.insert;\n      s.ins_h = s.window[str];\n\n      /* UPDATE_HASH(s, s->ins_h, s->window[str + 1]); */\n      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + 1]) & s.hash_mask;\n//#if MIN_MATCH != 3\n//        Call update_hash() MIN_MATCH-3 more times\n//#endif\n      while (s.insert) {\n        /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n        s.prev[str & s.w_mask] = s.head[s.ins_h];\n        s.head[s.ins_h] = str;\n        str++;\n        s.insert--;\n        if (s.lookahead + s.insert < MIN_MATCH) {\n          break;\n        }\n      }\n    }\n    /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,\n     * but this is not important since only literal bytes will be emitted.\n     */\n\n  } while (s.lookahead < MIN_LOOKAHEAD && s.strm.avail_in !== 0);\n\n  /* If the WIN_INIT bytes after the end of the current data have never been\n   * written, then zero those bytes in order to avoid memory check reports of\n   * the use of uninitialized (or uninitialised as Julian writes) bytes by\n   * the longest match routines.  Update the high water mark for the next\n   * time through here.  WIN_INIT is set to MAX_MATCH since the longest match\n   * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.\n   */\n//  if (s.high_water < s.window_size) {\n//    var curr = s.strstart + s.lookahead;\n//    var init = 0;\n//\n//    if (s.high_water < curr) {\n//      /* Previous high water mark below current data -- zero WIN_INIT\n//       * bytes or up to end of window, whichever is less.\n//       */\n//      init = s.window_size - curr;\n//      if (init > WIN_INIT)\n//        init = WIN_INIT;\n//      zmemzero(s->window + curr, (unsigned)init);\n//      s->high_water = curr + init;\n//    }\n//    else if (s->high_water < (ulg)curr + WIN_INIT) {\n//      /* High water mark at or above current data, but below current data\n//       * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up\n//       * to end of window, whichever is less.\n//       */\n//      init = (ulg)curr + WIN_INIT - s->high_water;\n//      if (init > s->window_size - s->high_water)\n//        init = s->window_size - s->high_water;\n//      zmemzero(s->window + s->high_water, (unsigned)init);\n//      s->high_water += init;\n//    }\n//  }\n//\n//  Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD,\n//    \"not enough room for search\");\n}\n\n/* ===========================================================================\n * Copy without compression as much as possible from the input stream, return\n * the current block state.\n * This function does not insert new strings in the dictionary since\n * uncompressible data is probably not useful. This function is used\n * only for the level=0 compression option.\n * NOTE: this function should be optimized to avoid extra copying from\n * window to pending_buf.\n */\nfunction deflate_stored(s, flush) {\n  /* Stored blocks are limited to 0xffff bytes, pending_buf is limited\n   * to pending_buf_size, and each stored block has a 5 byte header:\n   */\n  var max_block_size = 0xffff;\n\n  if (max_block_size > s.pending_buf_size - 5) {\n    max_block_size = s.pending_buf_size - 5;\n  }\n\n  /* Copy as much as possible from input to output: */\n  for (;;) {\n    /* Fill the window as much as possible: */\n    if (s.lookahead <= 1) {\n\n      //Assert(s->strstart < s->w_size+MAX_DIST(s) ||\n      //  s->block_start >= (long)s->w_size, \"slide too late\");\n//      if (!(s.strstart < s.w_size + (s.w_size - MIN_LOOKAHEAD) ||\n//        s.block_start >= s.w_size)) {\n//        throw  new Error(\"slide too late\");\n//      }\n\n      fill_window(s);\n      if (s.lookahead === 0 && flush === Z_NO_FLUSH) {\n        return BS_NEED_MORE;\n      }\n\n      if (s.lookahead === 0) {\n        break;\n      }\n      /* flush the current block */\n    }\n    //Assert(s->block_start >= 0L, \"block gone\");\n//    if (s.block_start < 0) throw new Error(\"block gone\");\n\n    s.strstart += s.lookahead;\n    s.lookahead = 0;\n\n    /* Emit a stored block if pending_buf will be full: */\n    var max_start = s.block_start + max_block_size;\n\n    if (s.strstart === 0 || s.strstart >= max_start) {\n      /* strstart == 0 is possible when wraparound on 16-bit machine */\n      s.lookahead = s.strstart - max_start;\n      s.strstart = max_start;\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n\n\n    }\n    /* Flush if we may have to slide, otherwise block_start may become\n     * negative and the data will be gone:\n     */\n    if (s.strstart - s.block_start >= (s.w_size - MIN_LOOKAHEAD)) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n\n  s.insert = 0;\n\n  if (flush === Z_FINISH) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n\n  if (s.strstart > s.block_start) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n\n  return BS_NEED_MORE;\n}\n\n/* ===========================================================================\n * Compress as much as possible from the input stream, return the current\n * block state.\n * This function does not perform lazy evaluation of matches and inserts\n * new strings in the dictionary only for unmatched strings or for short\n * matches. It is used only for the fast compression options.\n */\nfunction deflate_fast(s, flush) {\n  var hash_head;        /* head of the hash chain */\n  var bflush;           /* set if current block must be flushed */\n\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the next match, plus MIN_MATCH bytes to insert the\n     * string following the next match.\n     */\n    if (s.lookahead < MIN_LOOKAHEAD) {\n      fill_window(s);\n      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) {\n        break; /* flush the current block */\n      }\n    }\n\n    /* Insert the string window[strstart .. strstart+2] in the\n     * dictionary, and set hash_head to the head of the hash chain:\n     */\n    hash_head = 0/*NIL*/;\n    if (s.lookahead >= MIN_MATCH) {\n      /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n      s.head[s.ins_h] = s.strstart;\n      /***/\n    }\n\n    /* Find the longest match, discarding those <= prev_length.\n     * At this point we have always match_length < MIN_MATCH\n     */\n    if (hash_head !== 0/*NIL*/ && ((s.strstart - hash_head) <= (s.w_size - MIN_LOOKAHEAD))) {\n      /* To simplify the code, we prevent matches with the string\n       * of window index 0 (in particular we have to avoid a match\n       * of the string with itself at the start of the input file).\n       */\n      s.match_length = longest_match(s, hash_head);\n      /* longest_match() sets match_start */\n    }\n    if (s.match_length >= MIN_MATCH) {\n      // check_match(s, s.strstart, s.match_start, s.match_length); // for debug only\n\n      /*** _tr_tally_dist(s, s.strstart - s.match_start,\n                     s.match_length - MIN_MATCH, bflush); ***/\n      bflush = trees._tr_tally(s, s.strstart - s.match_start, s.match_length - MIN_MATCH);\n\n      s.lookahead -= s.match_length;\n\n      /* Insert new strings in the hash table only if the match length\n       * is not too large. This saves time but degrades compression.\n       */\n      if (s.match_length <= s.max_lazy_match/*max_insert_length*/ && s.lookahead >= MIN_MATCH) {\n        s.match_length--; /* string at strstart already in table */\n        do {\n          s.strstart++;\n          /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n          s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n          s.head[s.ins_h] = s.strstart;\n          /***/\n          /* strstart never exceeds WSIZE-MAX_MATCH, so there are\n           * always MIN_MATCH bytes ahead.\n           */\n        } while (--s.match_length !== 0);\n        s.strstart++;\n      } else\n      {\n        s.strstart += s.match_length;\n        s.match_length = 0;\n        s.ins_h = s.window[s.strstart];\n        /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */\n        s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + 1]) & s.hash_mask;\n\n//#if MIN_MATCH != 3\n//                Call UPDATE_HASH() MIN_MATCH-3 more times\n//#endif\n        /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not\n         * matter since it will be recomputed at next deflate call.\n         */\n      }\n    } else {\n      /* No match, output a literal byte */\n      //Tracevv((stderr,\"%c\", s.window[s.strstart]));\n      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n      bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n      s.lookahead--;\n      s.strstart++;\n    }\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = ((s.strstart < (MIN_MATCH - 1)) ? s.strstart : MIN_MATCH - 1);\n  if (flush === Z_FINISH) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * Same as above, but achieves better compression. We use a lazy\n * evaluation for matches: a match is finally adopted only if there is\n * no better match at the next window position.\n */\nfunction deflate_slow(s, flush) {\n  var hash_head;          /* head of hash chain */\n  var bflush;              /* set if current block must be flushed */\n\n  var max_insert;\n\n  /* Process the input block. */\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the next match, plus MIN_MATCH bytes to insert the\n     * string following the next match.\n     */\n    if (s.lookahead < MIN_LOOKAHEAD) {\n      fill_window(s);\n      if (s.lookahead < MIN_LOOKAHEAD && flush === Z_NO_FLUSH) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) { break; } /* flush the current block */\n    }\n\n    /* Insert the string window[strstart .. strstart+2] in the\n     * dictionary, and set hash_head to the head of the hash chain:\n     */\n    hash_head = 0/*NIL*/;\n    if (s.lookahead >= MIN_MATCH) {\n      /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n      hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n      s.head[s.ins_h] = s.strstart;\n      /***/\n    }\n\n    /* Find the longest match, discarding those <= prev_length.\n     */\n    s.prev_length = s.match_length;\n    s.prev_match = s.match_start;\n    s.match_length = MIN_MATCH - 1;\n\n    if (hash_head !== 0/*NIL*/ && s.prev_length < s.max_lazy_match &&\n        s.strstart - hash_head <= (s.w_size - MIN_LOOKAHEAD)/*MAX_DIST(s)*/) {\n      /* To simplify the code, we prevent matches with the string\n       * of window index 0 (in particular we have to avoid a match\n       * of the string with itself at the start of the input file).\n       */\n      s.match_length = longest_match(s, hash_head);\n      /* longest_match() sets match_start */\n\n      if (s.match_length <= 5 &&\n         (s.strategy === Z_FILTERED || (s.match_length === MIN_MATCH && s.strstart - s.match_start > 4096/*TOO_FAR*/))) {\n\n        /* If prev_match is also MIN_MATCH, match_start is garbage\n         * but we will ignore the current match anyway.\n         */\n        s.match_length = MIN_MATCH - 1;\n      }\n    }\n    /* If there was a match at the previous step and the current\n     * match is not better, output the previous match:\n     */\n    if (s.prev_length >= MIN_MATCH && s.match_length <= s.prev_length) {\n      max_insert = s.strstart + s.lookahead - MIN_MATCH;\n      /* Do not insert strings in hash table beyond this. */\n\n      //check_match(s, s.strstart-1, s.prev_match, s.prev_length);\n\n      /***_tr_tally_dist(s, s.strstart - 1 - s.prev_match,\n                     s.prev_length - MIN_MATCH, bflush);***/\n      bflush = trees._tr_tally(s, s.strstart - 1 - s.prev_match, s.prev_length - MIN_MATCH);\n      /* Insert in hash table all strings up to the end of the match.\n       * strstart-1 and strstart are already inserted. If there is not\n       * enough lookahead, the last two strings are not inserted in\n       * the hash table.\n       */\n      s.lookahead -= s.prev_length - 1;\n      s.prev_length -= 2;\n      do {\n        if (++s.strstart <= max_insert) {\n          /*** INSERT_STRING(s, s.strstart, hash_head); ***/\n          s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[s.strstart + MIN_MATCH - 1]) & s.hash_mask;\n          hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];\n          s.head[s.ins_h] = s.strstart;\n          /***/\n        }\n      } while (--s.prev_length !== 0);\n      s.match_available = 0;\n      s.match_length = MIN_MATCH - 1;\n      s.strstart++;\n\n      if (bflush) {\n        /*** FLUSH_BLOCK(s, 0); ***/\n        flush_block_only(s, false);\n        if (s.strm.avail_out === 0) {\n          return BS_NEED_MORE;\n        }\n        /***/\n      }\n\n    } else if (s.match_available) {\n      /* If there was no match at the previous position, output a\n       * single literal. If there was a match but the current match\n       * is longer, truncate the previous match to a single literal.\n       */\n      //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n      /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n      bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n      if (bflush) {\n        /*** FLUSH_BLOCK_ONLY(s, 0) ***/\n        flush_block_only(s, false);\n        /***/\n      }\n      s.strstart++;\n      s.lookahead--;\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n    } else {\n      /* There is no previous match to compare with, wait for\n       * the next step to decide.\n       */\n      s.match_available = 1;\n      s.strstart++;\n      s.lookahead--;\n    }\n  }\n  //Assert (flush != Z_NO_FLUSH, \"no flush?\");\n  if (s.match_available) {\n    //Tracevv((stderr,\"%c\", s->window[s->strstart-1]));\n    /*** _tr_tally_lit(s, s.window[s.strstart-1], bflush); ***/\n    bflush = trees._tr_tally(s, 0, s.window[s.strstart - 1]);\n\n    s.match_available = 0;\n  }\n  s.insert = s.strstart < MIN_MATCH - 1 ? s.strstart : MIN_MATCH - 1;\n  if (flush === Z_FINISH) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n\n  return BS_BLOCK_DONE;\n}\n\n\n/* ===========================================================================\n * For Z_RLE, simply look for runs of bytes, generate matches only of distance\n * one.  Do not maintain a hash table.  (It will be regenerated if this run of\n * deflate switches away from Z_RLE.)\n */\nfunction deflate_rle(s, flush) {\n  var bflush;            /* set if current block must be flushed */\n  var prev;              /* byte at distance one to match */\n  var scan, strend;      /* scan goes up to strend for length of run */\n\n  var _win = s.window;\n\n  for (;;) {\n    /* Make sure that we always have enough lookahead, except\n     * at the end of the input file. We need MAX_MATCH bytes\n     * for the longest run, plus one for the unrolled loop.\n     */\n    if (s.lookahead <= MAX_MATCH) {\n      fill_window(s);\n      if (s.lookahead <= MAX_MATCH && flush === Z_NO_FLUSH) {\n        return BS_NEED_MORE;\n      }\n      if (s.lookahead === 0) { break; } /* flush the current block */\n    }\n\n    /* See how many times the previous byte repeats */\n    s.match_length = 0;\n    if (s.lookahead >= MIN_MATCH && s.strstart > 0) {\n      scan = s.strstart - 1;\n      prev = _win[scan];\n      if (prev === _win[++scan] && prev === _win[++scan] && prev === _win[++scan]) {\n        strend = s.strstart + MAX_MATCH;\n        do {\n          /*jshint noempty:false*/\n        } while (prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 prev === _win[++scan] && prev === _win[++scan] &&\n                 scan < strend);\n        s.match_length = MAX_MATCH - (strend - scan);\n        if (s.match_length > s.lookahead) {\n          s.match_length = s.lookahead;\n        }\n      }\n      //Assert(scan <= s->window+(uInt)(s->window_size-1), \"wild scan\");\n    }\n\n    /* Emit match if have run of MIN_MATCH or longer, else emit literal */\n    if (s.match_length >= MIN_MATCH) {\n      //check_match(s, s.strstart, s.strstart - 1, s.match_length);\n\n      /*** _tr_tally_dist(s, 1, s.match_length - MIN_MATCH, bflush); ***/\n      bflush = trees._tr_tally(s, 1, s.match_length - MIN_MATCH);\n\n      s.lookahead -= s.match_length;\n      s.strstart += s.match_length;\n      s.match_length = 0;\n    } else {\n      /* No match, output a literal byte */\n      //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n      /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n      bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n\n      s.lookahead--;\n      s.strstart++;\n    }\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = 0;\n  if (flush === Z_FINISH) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n}\n\n/* ===========================================================================\n * For Z_HUFFMAN_ONLY, do not look for matches.  Do not maintain a hash table.\n * (It will be regenerated if this run of deflate switches away from Huffman.)\n */\nfunction deflate_huff(s, flush) {\n  var bflush;             /* set if current block must be flushed */\n\n  for (;;) {\n    /* Make sure that we have a literal to write. */\n    if (s.lookahead === 0) {\n      fill_window(s);\n      if (s.lookahead === 0) {\n        if (flush === Z_NO_FLUSH) {\n          return BS_NEED_MORE;\n        }\n        break;      /* flush the current block */\n      }\n    }\n\n    /* Output a literal byte */\n    s.match_length = 0;\n    //Tracevv((stderr,\"%c\", s->window[s->strstart]));\n    /*** _tr_tally_lit(s, s.window[s.strstart], bflush); ***/\n    bflush = trees._tr_tally(s, 0, s.window[s.strstart]);\n    s.lookahead--;\n    s.strstart++;\n    if (bflush) {\n      /*** FLUSH_BLOCK(s, 0); ***/\n      flush_block_only(s, false);\n      if (s.strm.avail_out === 0) {\n        return BS_NEED_MORE;\n      }\n      /***/\n    }\n  }\n  s.insert = 0;\n  if (flush === Z_FINISH) {\n    /*** FLUSH_BLOCK(s, 1); ***/\n    flush_block_only(s, true);\n    if (s.strm.avail_out === 0) {\n      return BS_FINISH_STARTED;\n    }\n    /***/\n    return BS_FINISH_DONE;\n  }\n  if (s.last_lit) {\n    /*** FLUSH_BLOCK(s, 0); ***/\n    flush_block_only(s, false);\n    if (s.strm.avail_out === 0) {\n      return BS_NEED_MORE;\n    }\n    /***/\n  }\n  return BS_BLOCK_DONE;\n}\n\n/* Values for max_lazy_match, good_match and max_chain_length, depending on\n * the desired pack level (0..9). The values given below have been tuned to\n * exclude worst case performance for pathological files. Better values may be\n * found for specific files.\n */\nfunction Config(good_length, max_lazy, nice_length, max_chain, func) {\n  this.good_length = good_length;\n  this.max_lazy = max_lazy;\n  this.nice_length = nice_length;\n  this.max_chain = max_chain;\n  this.func = func;\n}\n\nvar configuration_table;\n\nconfiguration_table = [\n  /*      good lazy nice chain */\n  new Config(0, 0, 0, 0, deflate_stored),          /* 0 store only */\n  new Config(4, 4, 8, 4, deflate_fast),            /* 1 max speed, no lazy matches */\n  new Config(4, 5, 16, 8, deflate_fast),           /* 2 */\n  new Config(4, 6, 32, 32, deflate_fast),          /* 3 */\n\n  new Config(4, 4, 16, 16, deflate_slow),          /* 4 lazy matches */\n  new Config(8, 16, 32, 32, deflate_slow),         /* 5 */\n  new Config(8, 16, 128, 128, deflate_slow),       /* 6 */\n  new Config(8, 32, 128, 256, deflate_slow),       /* 7 */\n  new Config(32, 128, 258, 1024, deflate_slow),    /* 8 */\n  new Config(32, 258, 258, 4096, deflate_slow)     /* 9 max compression */\n];\n\n\n/* ===========================================================================\n * Initialize the \"longest match\" routines for a new zlib stream\n */\nfunction lm_init(s) {\n  s.window_size = 2 * s.w_size;\n\n  /*** CLEAR_HASH(s); ***/\n  zero(s.head); // Fill with NIL (= 0);\n\n  /* Set the default configuration parameters:\n   */\n  s.max_lazy_match = configuration_table[s.level].max_lazy;\n  s.good_match = configuration_table[s.level].good_length;\n  s.nice_match = configuration_table[s.level].nice_length;\n  s.max_chain_length = configuration_table[s.level].max_chain;\n\n  s.strstart = 0;\n  s.block_start = 0;\n  s.lookahead = 0;\n  s.insert = 0;\n  s.match_length = s.prev_length = MIN_MATCH - 1;\n  s.match_available = 0;\n  s.ins_h = 0;\n}\n\n\nfunction DeflateState() {\n  this.strm = null;            /* pointer back to this zlib stream */\n  this.status = 0;            /* as the name implies */\n  this.pending_buf = null;      /* output still pending */\n  this.pending_buf_size = 0;  /* size of pending_buf */\n  this.pending_out = 0;       /* next pending byte to output to the stream */\n  this.pending = 0;           /* nb of bytes in the pending buffer */\n  this.wrap = 0;              /* bit 0 true for zlib, bit 1 true for gzip */\n  this.gzhead = null;         /* gzip header information to write */\n  this.gzindex = 0;           /* where in extra, name, or comment */\n  this.method = Z_DEFLATED; /* can only be DEFLATED */\n  this.last_flush = -1;   /* value of flush param for previous deflate call */\n\n  this.w_size = 0;  /* LZ77 window size (32K by default) */\n  this.w_bits = 0;  /* log2(w_size)  (8..16) */\n  this.w_mask = 0;  /* w_size - 1 */\n\n  this.window = null;\n  /* Sliding window. Input bytes are read into the second half of the window,\n   * and move to the first half later to keep a dictionary of at least wSize\n   * bytes. With this organization, matches are limited to a distance of\n   * wSize-MAX_MATCH bytes, but this ensures that IO is always\n   * performed with a length multiple of the block size.\n   */\n\n  this.window_size = 0;\n  /* Actual size of window: 2*wSize, except when the user input buffer\n   * is directly used as sliding window.\n   */\n\n  this.prev = null;\n  /* Link to older string with same hash index. To limit the size of this\n   * array to 64K, this link is maintained only for the last 32K strings.\n   * An index in this array is thus a window index modulo 32K.\n   */\n\n  this.head = null;   /* Heads of the hash chains or NIL. */\n\n  this.ins_h = 0;       /* hash index of string to be inserted */\n  this.hash_size = 0;   /* number of elements in hash table */\n  this.hash_bits = 0;   /* log2(hash_size) */\n  this.hash_mask = 0;   /* hash_size-1 */\n\n  this.hash_shift = 0;\n  /* Number of bits by which ins_h must be shifted at each input\n   * step. It must be such that after MIN_MATCH steps, the oldest\n   * byte no longer takes part in the hash key, that is:\n   *   hash_shift * MIN_MATCH >= hash_bits\n   */\n\n  this.block_start = 0;\n  /* Window position at the beginning of the current output block. Gets\n   * negative when the window is moved backwards.\n   */\n\n  this.match_length = 0;      /* length of best match */\n  this.prev_match = 0;        /* previous match */\n  this.match_available = 0;   /* set if previous match exists */\n  this.strstart = 0;          /* start of string to insert */\n  this.match_start = 0;       /* start of matching string */\n  this.lookahead = 0;         /* number of valid bytes ahead in window */\n\n  this.prev_length = 0;\n  /* Length of the best match at previous step. Matches not greater than this\n   * are discarded. This is used in the lazy match evaluation.\n   */\n\n  this.max_chain_length = 0;\n  /* To speed up deflation, hash chains are never searched beyond this\n   * length.  A higher limit improves compression ratio but degrades the\n   * speed.\n   */\n\n  this.max_lazy_match = 0;\n  /* Attempt to find a better match only when the current match is strictly\n   * smaller than this value. This mechanism is used only for compression\n   * levels >= 4.\n   */\n  // That's alias to max_lazy_match, don't use directly\n  //this.max_insert_length = 0;\n  /* Insert new strings in the hash table only if the match length is not\n   * greater than this length. This saves time but degrades compression.\n   * max_insert_length is used only for compression levels <= 3.\n   */\n\n  this.level = 0;     /* compression level (1..9) */\n  this.strategy = 0;  /* favor or force Huffman coding*/\n\n  this.good_match = 0;\n  /* Use a faster search when the previous match is longer than this */\n\n  this.nice_match = 0; /* Stop searching when current match exceeds this */\n\n              /* used by trees.c: */\n\n  /* Didn't use ct_data typedef below to suppress compiler warning */\n\n  // struct ct_data_s dyn_ltree[HEAP_SIZE];   /* literal and length tree */\n  // struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */\n  // struct ct_data_s bl_tree[2*BL_CODES+1];  /* Huffman tree for bit lengths */\n\n  // Use flat array of DOUBLE size, with interleaved fata,\n  // because JS does not support effective\n  this.dyn_ltree  = new utils.Buf16(HEAP_SIZE * 2);\n  this.dyn_dtree  = new utils.Buf16((2 * D_CODES + 1) * 2);\n  this.bl_tree    = new utils.Buf16((2 * BL_CODES + 1) * 2);\n  zero(this.dyn_ltree);\n  zero(this.dyn_dtree);\n  zero(this.bl_tree);\n\n  this.l_desc   = null;         /* desc. for literal tree */\n  this.d_desc   = null;         /* desc. for distance tree */\n  this.bl_desc  = null;         /* desc. for bit length tree */\n\n  //ush bl_count[MAX_BITS+1];\n  this.bl_count = new utils.Buf16(MAX_BITS + 1);\n  /* number of codes at each bit length for an optimal tree */\n\n  //int heap[2*L_CODES+1];      /* heap used to build the Huffman trees */\n  this.heap = new utils.Buf16(2 * L_CODES + 1);  /* heap used to build the Huffman trees */\n  zero(this.heap);\n\n  this.heap_len = 0;               /* number of elements in the heap */\n  this.heap_max = 0;               /* element of largest frequency */\n  /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.\n   * The same heap array is used to build all trees.\n   */\n\n  this.depth = new utils.Buf16(2 * L_CODES + 1); //uch depth[2*L_CODES+1];\n  zero(this.depth);\n  /* Depth of each subtree used as tie breaker for trees of equal frequency\n   */\n\n  this.l_buf = 0;          /* buffer index for literals or lengths */\n\n  this.lit_bufsize = 0;\n  /* Size of match buffer for literals/lengths.  There are 4 reasons for\n   * limiting lit_bufsize to 64K:\n   *   - frequencies can be kept in 16 bit counters\n   *   - if compression is not successful for the first block, all input\n   *     data is still in the window so we can still emit a stored block even\n   *     when input comes from standard input.  (This can also be done for\n   *     all blocks if lit_bufsize is not greater than 32K.)\n   *   - if compression is not successful for a file smaller than 64K, we can\n   *     even emit a stored file instead of a stored block (saving 5 bytes).\n   *     This is applicable only for zip (not gzip or zlib).\n   *   - creating new Huffman trees less frequently may not provide fast\n   *     adaptation to changes in the input data statistics. (Take for\n   *     example a binary file with poorly compressible code followed by\n   *     a highly compressible string table.) Smaller buffer sizes give\n   *     fast adaptation but have of course the overhead of transmitting\n   *     trees more frequently.\n   *   - I can't count above 4\n   */\n\n  this.last_lit = 0;      /* running index in l_buf */\n\n  this.d_buf = 0;\n  /* Buffer index for distances. To simplify the code, d_buf and l_buf have\n   * the same number of elements. To use different lengths, an extra flag\n   * array would be necessary.\n   */\n\n  this.opt_len = 0;       /* bit length of current block with optimal trees */\n  this.static_len = 0;    /* bit length of current block with static trees */\n  this.matches = 0;       /* number of string matches in current block */\n  this.insert = 0;        /* bytes at end of window left to insert */\n\n\n  this.bi_buf = 0;\n  /* Output buffer. bits are inserted starting at the bottom (least\n   * significant bits).\n   */\n  this.bi_valid = 0;\n  /* Number of valid bits in bi_buf.  All bits above the last valid bit\n   * are always zero.\n   */\n\n  // Used for window memory init. We safely ignore it for JS. That makes\n  // sense only for pointers and memory check tools.\n  //this.high_water = 0;\n  /* High water mark offset in window for initialized bytes -- bytes above\n   * this are set to zero in order to avoid memory check warnings when\n   * longest match routines access bytes past the input.  This is then\n   * updated to the new high water mark.\n   */\n}\n\n\nfunction deflateResetKeep(strm) {\n  var s;\n\n  if (!strm || !strm.state) {\n    return err(strm, Z_STREAM_ERROR);\n  }\n\n  strm.total_in = strm.total_out = 0;\n  strm.data_type = Z_UNKNOWN;\n\n  s = strm.state;\n  s.pending = 0;\n  s.pending_out = 0;\n\n  if (s.wrap < 0) {\n    s.wrap = -s.wrap;\n    /* was made negative by deflate(..., Z_FINISH); */\n  }\n  s.status = (s.wrap ? INIT_STATE : BUSY_STATE);\n  strm.adler = (s.wrap === 2) ?\n    0  // crc32(0, Z_NULL, 0)\n  :\n    1; // adler32(0, Z_NULL, 0)\n  s.last_flush = Z_NO_FLUSH;\n  trees._tr_init(s);\n  return Z_OK;\n}\n\n\nfunction deflateReset(strm) {\n  var ret = deflateResetKeep(strm);\n  if (ret === Z_OK) {\n    lm_init(strm.state);\n  }\n  return ret;\n}\n\n\nfunction deflateSetHeader(strm, head) {\n  if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n  if (strm.state.wrap !== 2) { return Z_STREAM_ERROR; }\n  strm.state.gzhead = head;\n  return Z_OK;\n}\n\n\nfunction deflateInit2(strm, level, method, windowBits, memLevel, strategy) {\n  if (!strm) { // === Z_NULL\n    return Z_STREAM_ERROR;\n  }\n  var wrap = 1;\n\n  if (level === Z_DEFAULT_COMPRESSION) {\n    level = 6;\n  }\n\n  if (windowBits < 0) { /* suppress zlib wrapper */\n    wrap = 0;\n    windowBits = -windowBits;\n  }\n\n  else if (windowBits > 15) {\n    wrap = 2;           /* write gzip wrapper instead */\n    windowBits -= 16;\n  }\n\n\n  if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method !== Z_DEFLATED ||\n    windowBits < 8 || windowBits > 15 || level < 0 || level > 9 ||\n    strategy < 0 || strategy > Z_FIXED) {\n    return err(strm, Z_STREAM_ERROR);\n  }\n\n\n  if (windowBits === 8) {\n    windowBits = 9;\n  }\n  /* until 256-byte window bug fixed */\n\n  var s = new DeflateState();\n\n  strm.state = s;\n  s.strm = strm;\n\n  s.wrap = wrap;\n  s.gzhead = null;\n  s.w_bits = windowBits;\n  s.w_size = 1 << s.w_bits;\n  s.w_mask = s.w_size - 1;\n\n  s.hash_bits = memLevel + 7;\n  s.hash_size = 1 << s.hash_bits;\n  s.hash_mask = s.hash_size - 1;\n  s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);\n\n  s.window = new utils.Buf8(s.w_size * 2);\n  s.head = new utils.Buf16(s.hash_size);\n  s.prev = new utils.Buf16(s.w_size);\n\n  // Don't need mem init magic for JS.\n  //s.high_water = 0;  /* nothing written to s->window yet */\n\n  s.lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */\n\n  s.pending_buf_size = s.lit_bufsize * 4;\n\n  //overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);\n  //s->pending_buf = (uchf *) overlay;\n  s.pending_buf = new utils.Buf8(s.pending_buf_size);\n\n  // It is offset from `s.pending_buf` (size is `s.lit_bufsize * 2`)\n  //s->d_buf = overlay + s->lit_bufsize/sizeof(ush);\n  s.d_buf = 1 * s.lit_bufsize;\n\n  //s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize;\n  s.l_buf = (1 + 2) * s.lit_bufsize;\n\n  s.level = level;\n  s.strategy = strategy;\n  s.method = method;\n\n  return deflateReset(strm);\n}\n\nfunction deflateInit(strm, level) {\n  return deflateInit2(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY);\n}\n\n\nfunction deflate(strm, flush) {\n  var old_flush, s;\n  var beg, val; // for gzip header write only\n\n  if (!strm || !strm.state ||\n    flush > Z_BLOCK || flush < 0) {\n    return strm ? err(strm, Z_STREAM_ERROR) : Z_STREAM_ERROR;\n  }\n\n  s = strm.state;\n\n  if (!strm.output ||\n      (!strm.input && strm.avail_in !== 0) ||\n      (s.status === FINISH_STATE && flush !== Z_FINISH)) {\n    return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR : Z_STREAM_ERROR);\n  }\n\n  s.strm = strm; /* just in case */\n  old_flush = s.last_flush;\n  s.last_flush = flush;\n\n  /* Write the header */\n  if (s.status === INIT_STATE) {\n\n    if (s.wrap === 2) { // GZIP header\n      strm.adler = 0;  //crc32(0L, Z_NULL, 0);\n      put_byte(s, 31);\n      put_byte(s, 139);\n      put_byte(s, 8);\n      if (!s.gzhead) { // s->gzhead == Z_NULL\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, 0);\n        put_byte(s, s.level === 9 ? 2 :\n                    (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n                     4 : 0));\n        put_byte(s, OS_CODE);\n        s.status = BUSY_STATE;\n      }\n      else {\n        put_byte(s, (s.gzhead.text ? 1 : 0) +\n                    (s.gzhead.hcrc ? 2 : 0) +\n                    (!s.gzhead.extra ? 0 : 4) +\n                    (!s.gzhead.name ? 0 : 8) +\n                    (!s.gzhead.comment ? 0 : 16)\n                );\n        put_byte(s, s.gzhead.time & 0xff);\n        put_byte(s, (s.gzhead.time >> 8) & 0xff);\n        put_byte(s, (s.gzhead.time >> 16) & 0xff);\n        put_byte(s, (s.gzhead.time >> 24) & 0xff);\n        put_byte(s, s.level === 9 ? 2 :\n                    (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2 ?\n                     4 : 0));\n        put_byte(s, s.gzhead.os & 0xff);\n        if (s.gzhead.extra && s.gzhead.extra.length) {\n          put_byte(s, s.gzhead.extra.length & 0xff);\n          put_byte(s, (s.gzhead.extra.length >> 8) & 0xff);\n        }\n        if (s.gzhead.hcrc) {\n          strm.adler = crc32(strm.adler, s.pending_buf, s.pending, 0);\n        }\n        s.gzindex = 0;\n        s.status = EXTRA_STATE;\n      }\n    }\n    else // DEFLATE header\n    {\n      var header = (Z_DEFLATED + ((s.w_bits - 8) << 4)) << 8;\n      var level_flags = -1;\n\n      if (s.strategy >= Z_HUFFMAN_ONLY || s.level < 2) {\n        level_flags = 0;\n      } else if (s.level < 6) {\n        level_flags = 1;\n      } else if (s.level === 6) {\n        level_flags = 2;\n      } else {\n        level_flags = 3;\n      }\n      header |= (level_flags << 6);\n      if (s.strstart !== 0) { header |= PRESET_DICT; }\n      header += 31 - (header % 31);\n\n      s.status = BUSY_STATE;\n      putShortMSB(s, header);\n\n      /* Save the adler32 of the preset dictionary: */\n      if (s.strstart !== 0) {\n        putShortMSB(s, strm.adler >>> 16);\n        putShortMSB(s, strm.adler & 0xffff);\n      }\n      strm.adler = 1; // adler32(0L, Z_NULL, 0);\n    }\n  }\n\n//#ifdef GZIP\n  if (s.status === EXTRA_STATE) {\n    if (s.gzhead.extra/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n\n      while (s.gzindex < (s.gzhead.extra.length & 0xffff)) {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            break;\n          }\n        }\n        put_byte(s, s.gzhead.extra[s.gzindex] & 0xff);\n        s.gzindex++;\n      }\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (s.gzindex === s.gzhead.extra.length) {\n        s.gzindex = 0;\n        s.status = NAME_STATE;\n      }\n    }\n    else {\n      s.status = NAME_STATE;\n    }\n  }\n  if (s.status === NAME_STATE) {\n    if (s.gzhead.name/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n      //int val;\n\n      do {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            val = 1;\n            break;\n          }\n        }\n        // JS specific: little magic to add zero terminator to end of string\n        if (s.gzindex < s.gzhead.name.length) {\n          val = s.gzhead.name.charCodeAt(s.gzindex++) & 0xff;\n        } else {\n          val = 0;\n        }\n        put_byte(s, val);\n      } while (val !== 0);\n\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (val === 0) {\n        s.gzindex = 0;\n        s.status = COMMENT_STATE;\n      }\n    }\n    else {\n      s.status = COMMENT_STATE;\n    }\n  }\n  if (s.status === COMMENT_STATE) {\n    if (s.gzhead.comment/* != Z_NULL*/) {\n      beg = s.pending;  /* start of bytes to update crc */\n      //int val;\n\n      do {\n        if (s.pending === s.pending_buf_size) {\n          if (s.gzhead.hcrc && s.pending > beg) {\n            strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n          }\n          flush_pending(strm);\n          beg = s.pending;\n          if (s.pending === s.pending_buf_size) {\n            val = 1;\n            break;\n          }\n        }\n        // JS specific: little magic to add zero terminator to end of string\n        if (s.gzindex < s.gzhead.comment.length) {\n          val = s.gzhead.comment.charCodeAt(s.gzindex++) & 0xff;\n        } else {\n          val = 0;\n        }\n        put_byte(s, val);\n      } while (val !== 0);\n\n      if (s.gzhead.hcrc && s.pending > beg) {\n        strm.adler = crc32(strm.adler, s.pending_buf, s.pending - beg, beg);\n      }\n      if (val === 0) {\n        s.status = HCRC_STATE;\n      }\n    }\n    else {\n      s.status = HCRC_STATE;\n    }\n  }\n  if (s.status === HCRC_STATE) {\n    if (s.gzhead.hcrc) {\n      if (s.pending + 2 > s.pending_buf_size) {\n        flush_pending(strm);\n      }\n      if (s.pending + 2 <= s.pending_buf_size) {\n        put_byte(s, strm.adler & 0xff);\n        put_byte(s, (strm.adler >> 8) & 0xff);\n        strm.adler = 0; //crc32(0L, Z_NULL, 0);\n        s.status = BUSY_STATE;\n      }\n    }\n    else {\n      s.status = BUSY_STATE;\n    }\n  }\n//#endif\n\n  /* Flush as much pending output as possible */\n  if (s.pending !== 0) {\n    flush_pending(strm);\n    if (strm.avail_out === 0) {\n      /* Since avail_out is 0, deflate will be called again with\n       * more output space, but possibly with both pending and\n       * avail_in equal to zero. There won't be anything to do,\n       * but this is not an error situation so make sure we\n       * return OK instead of BUF_ERROR at next call of deflate:\n       */\n      s.last_flush = -1;\n      return Z_OK;\n    }\n\n    /* Make sure there is something to do and avoid duplicate consecutive\n     * flushes. For repeated and useless calls with Z_FINISH, we keep\n     * returning Z_STREAM_END instead of Z_BUF_ERROR.\n     */\n  } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&\n    flush !== Z_FINISH) {\n    return err(strm, Z_BUF_ERROR);\n  }\n\n  /* User must not provide more input after the first FINISH: */\n  if (s.status === FINISH_STATE && strm.avail_in !== 0) {\n    return err(strm, Z_BUF_ERROR);\n  }\n\n  /* Start a new block or continue the current one.\n   */\n  if (strm.avail_in !== 0 || s.lookahead !== 0 ||\n    (flush !== Z_NO_FLUSH && s.status !== FINISH_STATE)) {\n    var bstate = (s.strategy === Z_HUFFMAN_ONLY) ? deflate_huff(s, flush) :\n      (s.strategy === Z_RLE ? deflate_rle(s, flush) :\n        configuration_table[s.level].func(s, flush));\n\n    if (bstate === BS_FINISH_STARTED || bstate === BS_FINISH_DONE) {\n      s.status = FINISH_STATE;\n    }\n    if (bstate === BS_NEED_MORE || bstate === BS_FINISH_STARTED) {\n      if (strm.avail_out === 0) {\n        s.last_flush = -1;\n        /* avoid BUF_ERROR next call, see above */\n      }\n      return Z_OK;\n      /* If flush != Z_NO_FLUSH && avail_out == 0, the next call\n       * of deflate should use the same flush parameter to make sure\n       * that the flush is complete. So we don't have to output an\n       * empty block here, this will be done at next call. This also\n       * ensures that for a very small output buffer, we emit at most\n       * one empty block.\n       */\n    }\n    if (bstate === BS_BLOCK_DONE) {\n      if (flush === Z_PARTIAL_FLUSH) {\n        trees._tr_align(s);\n      }\n      else if (flush !== Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */\n\n        trees._tr_stored_block(s, 0, 0, false);\n        /* For a full flush, this empty block will be recognized\n         * as a special marker by inflate_sync().\n         */\n        if (flush === Z_FULL_FLUSH) {\n          /*** CLEAR_HASH(s); ***/             /* forget history */\n          zero(s.head); // Fill with NIL (= 0);\n\n          if (s.lookahead === 0) {\n            s.strstart = 0;\n            s.block_start = 0;\n            s.insert = 0;\n          }\n        }\n      }\n      flush_pending(strm);\n      if (strm.avail_out === 0) {\n        s.last_flush = -1; /* avoid BUF_ERROR at next call, see above */\n        return Z_OK;\n      }\n    }\n  }\n  //Assert(strm->avail_out > 0, \"bug2\");\n  //if (strm.avail_out <= 0) { throw new Error(\"bug2\");}\n\n  if (flush !== Z_FINISH) { return Z_OK; }\n  if (s.wrap <= 0) { return Z_STREAM_END; }\n\n  /* Write the trailer */\n  if (s.wrap === 2) {\n    put_byte(s, strm.adler & 0xff);\n    put_byte(s, (strm.adler >> 8) & 0xff);\n    put_byte(s, (strm.adler >> 16) & 0xff);\n    put_byte(s, (strm.adler >> 24) & 0xff);\n    put_byte(s, strm.total_in & 0xff);\n    put_byte(s, (strm.total_in >> 8) & 0xff);\n    put_byte(s, (strm.total_in >> 16) & 0xff);\n    put_byte(s, (strm.total_in >> 24) & 0xff);\n  }\n  else\n  {\n    putShortMSB(s, strm.adler >>> 16);\n    putShortMSB(s, strm.adler & 0xffff);\n  }\n\n  flush_pending(strm);\n  /* If avail_out is zero, the application will call deflate again\n   * to flush the rest.\n   */\n  if (s.wrap > 0) { s.wrap = -s.wrap; }\n  /* write the trailer only once! */\n  return s.pending !== 0 ? Z_OK : Z_STREAM_END;\n}\n\nfunction deflateEnd(strm) {\n  var status;\n\n  if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n    return Z_STREAM_ERROR;\n  }\n\n  status = strm.state.status;\n  if (status !== INIT_STATE &&\n    status !== EXTRA_STATE &&\n    status !== NAME_STATE &&\n    status !== COMMENT_STATE &&\n    status !== HCRC_STATE &&\n    status !== BUSY_STATE &&\n    status !== FINISH_STATE\n  ) {\n    return err(strm, Z_STREAM_ERROR);\n  }\n\n  strm.state = null;\n\n  return status === BUSY_STATE ? err(strm, Z_DATA_ERROR) : Z_OK;\n}\n\n\n/* =========================================================================\n * Initializes the compression dictionary from the given byte\n * sequence without producing any compressed output.\n */\nfunction deflateSetDictionary(strm, dictionary) {\n  var dictLength = dictionary.length;\n\n  var s;\n  var str, n;\n  var wrap;\n  var avail;\n  var next;\n  var input;\n  var tmpDict;\n\n  if (!strm/*== Z_NULL*/ || !strm.state/*== Z_NULL*/) {\n    return Z_STREAM_ERROR;\n  }\n\n  s = strm.state;\n  wrap = s.wrap;\n\n  if (wrap === 2 || (wrap === 1 && s.status !== INIT_STATE) || s.lookahead) {\n    return Z_STREAM_ERROR;\n  }\n\n  /* when using zlib wrappers, compute Adler-32 for provided dictionary */\n  if (wrap === 1) {\n    /* adler32(strm->adler, dictionary, dictLength); */\n    strm.adler = adler32(strm.adler, dictionary, dictLength, 0);\n  }\n\n  s.wrap = 0;   /* avoid computing Adler-32 in read_buf */\n\n  /* if dictionary would fill window, just replace the history */\n  if (dictLength >= s.w_size) {\n    if (wrap === 0) {            /* already empty otherwise */\n      /*** CLEAR_HASH(s); ***/\n      zero(s.head); // Fill with NIL (= 0);\n      s.strstart = 0;\n      s.block_start = 0;\n      s.insert = 0;\n    }\n    /* use the tail */\n    // dictionary = dictionary.slice(dictLength - s.w_size);\n    tmpDict = new utils.Buf8(s.w_size);\n    utils.arraySet(tmpDict, dictionary, dictLength - s.w_size, s.w_size, 0);\n    dictionary = tmpDict;\n    dictLength = s.w_size;\n  }\n  /* insert dictionary into window and hash */\n  avail = strm.avail_in;\n  next = strm.next_in;\n  input = strm.input;\n  strm.avail_in = dictLength;\n  strm.next_in = 0;\n  strm.input = dictionary;\n  fill_window(s);\n  while (s.lookahead >= MIN_MATCH) {\n    str = s.strstart;\n    n = s.lookahead - (MIN_MATCH - 1);\n    do {\n      /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */\n      s.ins_h = ((s.ins_h << s.hash_shift) ^ s.window[str + MIN_MATCH - 1]) & s.hash_mask;\n\n      s.prev[str & s.w_mask] = s.head[s.ins_h];\n\n      s.head[s.ins_h] = str;\n      str++;\n    } while (--n);\n    s.strstart = str;\n    s.lookahead = MIN_MATCH - 1;\n    fill_window(s);\n  }\n  s.strstart += s.lookahead;\n  s.block_start = s.strstart;\n  s.insert = s.lookahead;\n  s.lookahead = 0;\n  s.match_length = s.prev_length = MIN_MATCH - 1;\n  s.match_available = 0;\n  strm.next_in = next;\n  strm.input = input;\n  strm.avail_in = avail;\n  s.wrap = wrap;\n  return Z_OK;\n}\n\n\nexports.deflateInit = deflateInit;\nexports.deflateInit2 = deflateInit2;\nexports.deflateReset = deflateReset;\nexports.deflateResetKeep = deflateResetKeep;\nexports.deflateSetHeader = deflateSetHeader;\nexports.deflate = deflate;\nexports.deflateEnd = deflateEnd;\nexports.deflateSetDictionary = deflateSetDictionary;\nexports.deflateInfo = 'pako deflate (from Nodeca project)';\n\n/* Not implemented\nexports.deflateBound = deflateBound;\nexports.deflateCopy = deflateCopy;\nexports.deflateParams = deflateParams;\nexports.deflatePending = deflatePending;\nexports.deflatePrime = deflatePrime;\nexports.deflateTune = deflateTune;\n*/\n\n},{\"../utils/common\":41,\"./adler32\":43,\"./crc32\":45,\"./messages\":51,\"./trees\":52}],47:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction GZheader() {\n  /* true if compressed data believed to be text */\n  this.text       = 0;\n  /* modification time */\n  this.time       = 0;\n  /* extra flags (not used when writing a gzip file) */\n  this.xflags     = 0;\n  /* operating system */\n  this.os         = 0;\n  /* pointer to extra field or Z_NULL if none */\n  this.extra      = null;\n  /* extra field length (valid if extra != Z_NULL) */\n  this.extra_len  = 0; // Actually, we don't need it in JS,\n                       // but leave for few code modifications\n\n  //\n  // Setup limits is not necessary because in js we should not preallocate memory\n  // for inflate use constant limit in 65536 bytes\n  //\n\n  /* space at extra (only when reading header) */\n  // this.extra_max  = 0;\n  /* pointer to zero-terminated file name or Z_NULL */\n  this.name       = '';\n  /* space at name (only when reading header) */\n  // this.name_max   = 0;\n  /* pointer to zero-terminated comment or Z_NULL */\n  this.comment    = '';\n  /* space at comment (only when reading header) */\n  // this.comm_max   = 0;\n  /* true if there was or will be a header crc */\n  this.hcrc       = 0;\n  /* true when done reading gzip header (not used when writing a gzip file) */\n  this.done       = false;\n}\n\nmodule.exports = GZheader;\n\n},{}],48:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\n// See state defs from inflate.js\nvar BAD = 30;       /* got a data error -- remain here until reset */\nvar TYPE = 12;      /* i: waiting for type bits, including last-flag bit */\n\n/*\n   Decode literal, length, and distance codes and write out the resulting\n   literal and match bytes until either not enough input or output is\n   available, an end-of-block is encountered, or a data error is encountered.\n   When large enough input and output buffers are supplied to inflate(), for\n   example, a 16K input buffer and a 64K output buffer, more than 95% of the\n   inflate execution time is spent in this routine.\n\n   Entry assumptions:\n\n        state.mode === LEN\n        strm.avail_in >= 6\n        strm.avail_out >= 258\n        start >= strm.avail_out\n        state.bits < 8\n\n   On return, state.mode is one of:\n\n        LEN -- ran out of enough output space or enough available input\n        TYPE -- reached end of block code, inflate() to interpret next block\n        BAD -- error in block data\n\n   Notes:\n\n    - The maximum input bits used by a length/distance pair is 15 bits for the\n      length code, 5 bits for the length extra, 15 bits for the distance code,\n      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.\n      Therefore if strm.avail_in >= 6, then there is enough input to avoid\n      checking for available input while decoding.\n\n    - The maximum bytes that a single length/distance pair can output is 258\n      bytes, which is the maximum length that can be coded.  inflate_fast()\n      requires strm.avail_out >= 258 for each loop to avoid checking for\n      output space.\n */\nmodule.exports = function inflate_fast(strm, start) {\n  var state;\n  var _in;                    /* local strm.input */\n  var last;                   /* have enough input while in < last */\n  var _out;                   /* local strm.output */\n  var beg;                    /* inflate()'s initial strm.output */\n  var end;                    /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n  var dmax;                   /* maximum distance from zlib header */\n//#endif\n  var wsize;                  /* window size or zero if not using window */\n  var whave;                  /* valid bytes in the window */\n  var wnext;                  /* window write index */\n  // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n  var s_window;               /* allocated sliding window, if wsize != 0 */\n  var hold;                   /* local strm.hold */\n  var bits;                   /* local strm.bits */\n  var lcode;                  /* local strm.lencode */\n  var dcode;                  /* local strm.distcode */\n  var lmask;                  /* mask for first level of length codes */\n  var dmask;                  /* mask for first level of distance codes */\n  var here;                   /* retrieved table entry */\n  var op;                     /* code bits, operation, extra bits, or */\n                              /*  window position, window bytes to copy */\n  var len;                    /* match length, unused bytes */\n  var dist;                   /* match distance */\n  var from;                   /* where to copy match from */\n  var from_source;\n\n\n  var input, output; // JS specific, because we have no pointers\n\n  /* copy state to local variables */\n  state = strm.state;\n  //here = state.here;\n  _in = strm.next_in;\n  input = strm.input;\n  last = _in + (strm.avail_in - 5);\n  _out = strm.next_out;\n  output = strm.output;\n  beg = _out - (start - strm.avail_out);\n  end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n  dmax = state.dmax;\n//#endif\n  wsize = state.wsize;\n  whave = state.whave;\n  wnext = state.wnext;\n  s_window = state.window;\n  hold = state.hold;\n  bits = state.bits;\n  lcode = state.lencode;\n  dcode = state.distcode;\n  lmask = (1 << state.lenbits) - 1;\n  dmask = (1 << state.distbits) - 1;\n\n\n  /* decode literals and length/distances until end-of-block or not enough\n     input data or output space */\n\n  top:\n  do {\n    if (bits < 15) {\n      hold += input[_in++] << bits;\n      bits += 8;\n      hold += input[_in++] << bits;\n      bits += 8;\n    }\n\n    here = lcode[hold & lmask];\n\n    dolen:\n    for (;;) { // Goto emulation\n      op = here >>> 24/*here.bits*/;\n      hold >>>= op;\n      bits -= op;\n      op = (here >>> 16) & 0xff/*here.op*/;\n      if (op === 0) {                          /* literal */\n        //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n        //        \"inflate:         literal '%c'\\n\" :\n        //        \"inflate:         literal 0x%02x\\n\", here.val));\n        output[_out++] = here & 0xffff/*here.val*/;\n      }\n      else if (op & 16) {                     /* length base */\n        len = here & 0xffff/*here.val*/;\n        op &= 15;                           /* number of extra bits */\n        if (op) {\n          if (bits < op) {\n            hold += input[_in++] << bits;\n            bits += 8;\n          }\n          len += hold & ((1 << op) - 1);\n          hold >>>= op;\n          bits -= op;\n        }\n        //Tracevv((stderr, \"inflate:         length %u\\n\", len));\n        if (bits < 15) {\n          hold += input[_in++] << bits;\n          bits += 8;\n          hold += input[_in++] << bits;\n          bits += 8;\n        }\n        here = dcode[hold & dmask];\n\n        dodist:\n        for (;;) { // goto emulation\n          op = here >>> 24/*here.bits*/;\n          hold >>>= op;\n          bits -= op;\n          op = (here >>> 16) & 0xff/*here.op*/;\n\n          if (op & 16) {                      /* distance base */\n            dist = here & 0xffff/*here.val*/;\n            op &= 15;                       /* number of extra bits */\n            if (bits < op) {\n              hold += input[_in++] << bits;\n              bits += 8;\n              if (bits < op) {\n                hold += input[_in++] << bits;\n                bits += 8;\n              }\n            }\n            dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n            if (dist > dmax) {\n              strm.msg = 'invalid distance too far back';\n              state.mode = BAD;\n              break top;\n            }\n//#endif\n            hold >>>= op;\n            bits -= op;\n            //Tracevv((stderr, \"inflate:         distance %u\\n\", dist));\n            op = _out - beg;                /* max distance in output */\n            if (dist > op) {                /* see if copy from window */\n              op = dist - op;               /* distance back in window */\n              if (op > whave) {\n                if (state.sane) {\n                  strm.msg = 'invalid distance too far back';\n                  state.mode = BAD;\n                  break top;\n                }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n//                if (len <= op - whave) {\n//                  do {\n//                    output[_out++] = 0;\n//                  } while (--len);\n//                  continue top;\n//                }\n//                len -= op - whave;\n//                do {\n//                  output[_out++] = 0;\n//                } while (--op > whave);\n//                if (op === 0) {\n//                  from = _out - dist;\n//                  do {\n//                    output[_out++] = output[from++];\n//                  } while (--len);\n//                  continue top;\n//                }\n//#endif\n              }\n              from = 0; // window index\n              from_source = s_window;\n              if (wnext === 0) {           /* very common case */\n                from += wsize - op;\n                if (op < len) {         /* some from window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = _out - dist;  /* rest from output */\n                  from_source = output;\n                }\n              }\n              else if (wnext < op) {      /* wrap around window */\n                from += wsize + wnext - op;\n                op -= wnext;\n                if (op < len) {         /* some from end of window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = 0;\n                  if (wnext < len) {  /* some from start of window */\n                    op = wnext;\n                    len -= op;\n                    do {\n                      output[_out++] = s_window[from++];\n                    } while (--op);\n                    from = _out - dist;      /* rest from output */\n                    from_source = output;\n                  }\n                }\n              }\n              else {                      /* contiguous in window */\n                from += wnext - op;\n                if (op < len) {         /* some from window */\n                  len -= op;\n                  do {\n                    output[_out++] = s_window[from++];\n                  } while (--op);\n                  from = _out - dist;  /* rest from output */\n                  from_source = output;\n                }\n              }\n              while (len > 2) {\n                output[_out++] = from_source[from++];\n                output[_out++] = from_source[from++];\n                output[_out++] = from_source[from++];\n                len -= 3;\n              }\n              if (len) {\n                output[_out++] = from_source[from++];\n                if (len > 1) {\n                  output[_out++] = from_source[from++];\n                }\n              }\n            }\n            else {\n              from = _out - dist;          /* copy direct from output */\n              do {                        /* minimum length is three */\n                output[_out++] = output[from++];\n                output[_out++] = output[from++];\n                output[_out++] = output[from++];\n                len -= 3;\n              } while (len > 2);\n              if (len) {\n                output[_out++] = output[from++];\n                if (len > 1) {\n                  output[_out++] = output[from++];\n                }\n              }\n            }\n          }\n          else if ((op & 64) === 0) {          /* 2nd level distance code */\n            here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n            continue dodist;\n          }\n          else {\n            strm.msg = 'invalid distance code';\n            state.mode = BAD;\n            break top;\n          }\n\n          break; // need to emulate goto via \"continue\"\n        }\n      }\n      else if ((op & 64) === 0) {              /* 2nd level length code */\n        here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n        continue dolen;\n      }\n      else if (op & 32) {                     /* end-of-block */\n        //Tracevv((stderr, \"inflate:         end of block\\n\"));\n        state.mode = TYPE;\n        break top;\n      }\n      else {\n        strm.msg = 'invalid literal/length code';\n        state.mode = BAD;\n        break top;\n      }\n\n      break; // need to emulate goto via \"continue\"\n    }\n  } while (_in < last && _out < end);\n\n  /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n  len = bits >> 3;\n  _in -= len;\n  bits -= len << 3;\n  hold &= (1 << bits) - 1;\n\n  /* update state and return */\n  strm.next_in = _in;\n  strm.next_out = _out;\n  strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n  strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n  state.hold = hold;\n  state.bits = bits;\n  return;\n};\n\n},{}],49:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils         = require('../utils/common');\nvar adler32       = require('./adler32');\nvar crc32         = require('./crc32');\nvar inflate_fast  = require('./inffast');\nvar inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH      = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH    = 2;\n//var Z_FULL_FLUSH    = 3;\nvar Z_FINISH        = 4;\nvar Z_BLOCK         = 5;\nvar Z_TREES         = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK            = 0;\nvar Z_STREAM_END    = 1;\nvar Z_NEED_DICT     = 2;\n//var Z_ERRNO         = -1;\nvar Z_STREAM_ERROR  = -2;\nvar Z_DATA_ERROR    = -3;\nvar Z_MEM_ERROR     = -4;\nvar Z_BUF_ERROR     = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED  = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar    HEAD = 1;       /* i: waiting for magic header */\nvar    FLAGS = 2;      /* i: waiting for method and flags (gzip) */\nvar    TIME = 3;       /* i: waiting for modification time (gzip) */\nvar    OS = 4;         /* i: waiting for extra flags and operating system (gzip) */\nvar    EXLEN = 5;      /* i: waiting for extra length (gzip) */\nvar    EXTRA = 6;      /* i: waiting for extra bytes (gzip) */\nvar    NAME = 7;       /* i: waiting for end of file name (gzip) */\nvar    COMMENT = 8;    /* i: waiting for end of comment (gzip) */\nvar    HCRC = 9;       /* i: waiting for header crc (gzip) */\nvar    DICTID = 10;    /* i: waiting for dictionary check value */\nvar    DICT = 11;      /* waiting for inflateSetDictionary() call */\nvar        TYPE = 12;      /* i: waiting for type bits, including last-flag bit */\nvar        TYPEDO = 13;    /* i: same, but skip check to exit inflate on new block */\nvar        STORED = 14;    /* i: waiting for stored size (length and complement) */\nvar        COPY_ = 15;     /* i/o: same as COPY below, but only first time in */\nvar        COPY = 16;      /* i/o: waiting for input or output to copy stored block */\nvar        TABLE = 17;     /* i: waiting for dynamic block table lengths */\nvar        LENLENS = 18;   /* i: waiting for code length code lengths */\nvar        CODELENS = 19;  /* i: waiting for length/lit and distance code lengths */\nvar            LEN_ = 20;      /* i: same as LEN below, but only first time in */\nvar            LEN = 21;       /* i: waiting for length/lit/eob code */\nvar            LENEXT = 22;    /* i: waiting for length extra bits */\nvar            DIST = 23;      /* i: waiting for distance code */\nvar            DISTEXT = 24;   /* i: waiting for distance extra bits */\nvar            MATCH = 25;     /* o: waiting for output space to copy string */\nvar            LIT = 26;       /* o: waiting for output space to write literal */\nvar    CHECK = 27;     /* i: waiting for 32-bit check value */\nvar    LENGTH = 28;    /* i: waiting for 32-bit length (gzip) */\nvar    DONE = 29;      /* finished check, done -- remain here until reset */\nvar    BAD = 30;       /* got a data error -- remain here until reset */\nvar    MEM = 31;       /* got an inflate() memory error -- remain here until reset */\nvar    SYNC = 32;      /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH =  (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar MAX_WBITS = 15;\n/* 32K LZ77 window */\nvar DEF_WBITS = MAX_WBITS;\n\n\nfunction zswap32(q) {\n  return  (((q >>> 24) & 0xff) +\n          ((q >>> 8) & 0xff00) +\n          ((q & 0xff00) << 8) +\n          ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n  this.mode = 0;             /* current inflate mode */\n  this.last = false;          /* true if processing last block */\n  this.wrap = 0;              /* bit 0 true for zlib, bit 1 true for gzip */\n  this.havedict = false;      /* true if dictionary provided */\n  this.flags = 0;             /* gzip header method and flags (0 if zlib) */\n  this.dmax = 0;              /* zlib header max distance (INFLATE_STRICT) */\n  this.check = 0;             /* protected copy of check value */\n  this.total = 0;             /* protected copy of output count */\n  // TODO: may be {}\n  this.head = null;           /* where to save gzip header information */\n\n  /* sliding window */\n  this.wbits = 0;             /* log base 2 of requested window size */\n  this.wsize = 0;             /* window size or zero if not using window */\n  this.whave = 0;             /* valid bytes in the window */\n  this.wnext = 0;             /* window write index */\n  this.window = null;         /* allocated sliding window, if needed */\n\n  /* bit accumulator */\n  this.hold = 0;              /* input bit accumulator */\n  this.bits = 0;              /* number of bits in \"in\" */\n\n  /* for string and stored block copying */\n  this.length = 0;            /* literal or length of data to copy */\n  this.offset = 0;            /* distance back to copy string from */\n\n  /* for table and code decoding */\n  this.extra = 0;             /* extra bits needed */\n\n  /* fixed and dynamic code tables */\n  this.lencode = null;          /* starting table for length/literal codes */\n  this.distcode = null;         /* starting table for distance codes */\n  this.lenbits = 0;           /* index bits for lencode */\n  this.distbits = 0;          /* index bits for distcode */\n\n  /* dynamic table building */\n  this.ncode = 0;             /* number of code length code lengths */\n  this.nlen = 0;              /* number of length code lengths */\n  this.ndist = 0;             /* number of distance code lengths */\n  this.have = 0;              /* number of code lengths in lens[] */\n  this.next = null;              /* next available space in codes[] */\n\n  this.lens = new utils.Buf16(320); /* temporary storage for code lengths */\n  this.work = new utils.Buf16(288); /* work area for code table building */\n\n  /*\n   because we don't have pointers in js, we use lencode and distcode directly\n   as buffers so we don't need codes\n  */\n  //this.codes = new utils.Buf32(ENOUGH);       /* space for code tables */\n  this.lendyn = null;              /* dynamic table for length/literal codes (JS specific) */\n  this.distdyn = null;             /* dynamic table for distance codes (JS specific) */\n  this.sane = 0;                   /* if false, allow invalid distance too far */\n  this.back = 0;                   /* bits back of last unprocessed length/lit */\n  this.was = 0;                    /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n  var state;\n\n  if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n  state = strm.state;\n  strm.total_in = strm.total_out = state.total = 0;\n  strm.msg = ''; /*Z_NULL*/\n  if (state.wrap) {       /* to support ill-conceived Java test suite */\n    strm.adler = state.wrap & 1;\n  }\n  state.mode = HEAD;\n  state.last = 0;\n  state.havedict = 0;\n  state.dmax = 32768;\n  state.head = null/*Z_NULL*/;\n  state.hold = 0;\n  state.bits = 0;\n  //state.lencode = state.distcode = state.next = state.codes;\n  state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);\n  state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);\n\n  state.sane = 1;\n  state.back = -1;\n  //Tracev((stderr, \"inflate: reset\\n\"));\n  return Z_OK;\n}\n\nfunction inflateReset(strm) {\n  var state;\n\n  if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n  state = strm.state;\n  state.wsize = 0;\n  state.whave = 0;\n  state.wnext = 0;\n  return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n  var wrap;\n  var state;\n\n  /* get the state */\n  if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n  state = strm.state;\n\n  /* extract wrap request from windowBits parameter */\n  if (windowBits < 0) {\n    wrap = 0;\n    windowBits = -windowBits;\n  }\n  else {\n    wrap = (windowBits >> 4) + 1;\n    if (windowBits < 48) {\n      windowBits &= 15;\n    }\n  }\n\n  /* set number of window bits, free window if different */\n  if (windowBits && (windowBits < 8 || windowBits > 15)) {\n    return Z_STREAM_ERROR;\n  }\n  if (state.window !== null && state.wbits !== windowBits) {\n    state.window = null;\n  }\n\n  /* update state and reset the rest of it */\n  state.wrap = wrap;\n  state.wbits = windowBits;\n  return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n  var ret;\n  var state;\n\n  if (!strm) { return Z_STREAM_ERROR; }\n  //strm.msg = Z_NULL;                 /* in case we return an error */\n\n  state = new InflateState();\n\n  //if (state === Z_NULL) return Z_MEM_ERROR;\n  //Tracev((stderr, \"inflate: allocated\\n\"));\n  strm.state = state;\n  state.window = null/*Z_NULL*/;\n  ret = inflateReset2(strm, windowBits);\n  if (ret !== Z_OK) {\n    strm.state = null/*Z_NULL*/;\n  }\n  return ret;\n}\n\nfunction inflateInit(strm) {\n  return inflateInit2(strm, DEF_WBITS);\n}\n\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding.  Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter.  This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time.  However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix, distfix; // We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n  /* build fixed huffman tables if first call (may not be thread safe) */\n  if (virgin) {\n    var sym;\n\n    lenfix = new utils.Buf32(512);\n    distfix = new utils.Buf32(32);\n\n    /* literal/length table */\n    sym = 0;\n    while (sym < 144) { state.lens[sym++] = 8; }\n    while (sym < 256) { state.lens[sym++] = 9; }\n    while (sym < 280) { state.lens[sym++] = 7; }\n    while (sym < 288) { state.lens[sym++] = 8; }\n\n    inflate_table(LENS,  state.lens, 0, 288, lenfix,   0, state.work, { bits: 9 });\n\n    /* distance table */\n    sym = 0;\n    while (sym < 32) { state.lens[sym++] = 5; }\n\n    inflate_table(DISTS, state.lens, 0, 32,   distfix, 0, state.work, { bits: 5 });\n\n    /* do this just once */\n    virgin = false;\n  }\n\n  state.lencode = lenfix;\n  state.lenbits = 9;\n  state.distcode = distfix;\n  state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning.  If window does not exist yet, create it.  This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n  var dist;\n  var state = strm.state;\n\n  /* if it hasn't been done already, allocate space for the window */\n  if (state.window === null) {\n    state.wsize = 1 << state.wbits;\n    state.wnext = 0;\n    state.whave = 0;\n\n    state.window = new utils.Buf8(state.wsize);\n  }\n\n  /* copy state->wsize or less output bytes into the circular window */\n  if (copy >= state.wsize) {\n    utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n    state.wnext = 0;\n    state.whave = state.wsize;\n  }\n  else {\n    dist = state.wsize - state.wnext;\n    if (dist > copy) {\n      dist = copy;\n    }\n    //zmemcpy(state->window + state->wnext, end - copy, dist);\n    utils.arraySet(state.window, src, end - copy, dist, state.wnext);\n    copy -= dist;\n    if (copy) {\n      //zmemcpy(state->window, end - copy, copy);\n      utils.arraySet(state.window, src, end - copy, copy, 0);\n      state.wnext = copy;\n      state.whave = state.wsize;\n    }\n    else {\n      state.wnext += dist;\n      if (state.wnext === state.wsize) { state.wnext = 0; }\n      if (state.whave < state.wsize) { state.whave += dist; }\n    }\n  }\n  return 0;\n}\n\nfunction inflate(strm, flush) {\n  var state;\n  var input, output;          // input/output buffers\n  var next;                   /* next input INDEX */\n  var put;                    /* next output INDEX */\n  var have, left;             /* available input and output */\n  var hold;                   /* bit buffer */\n  var bits;                   /* bits in bit buffer */\n  var _in, _out;              /* save starting available input and output */\n  var copy;                   /* number of stored or match bytes to copy */\n  var from;                   /* where to copy match bytes from */\n  var from_source;\n  var here = 0;               /* current decoding table entry */\n  var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n  //var last;                   /* parent table entry */\n  var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n  var len;                    /* length to copy for repeats, bits to drop */\n  var ret;                    /* return code */\n  var hbuf = new utils.Buf8(4);    /* buffer for gzip header crc calculation */\n  var opts;\n\n  var n; // temporary var for NEED_BITS\n\n  var order = /* permutation of code lengths */\n    [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n  if (!strm || !strm.state || !strm.output ||\n      (!strm.input && strm.avail_in !== 0)) {\n    return Z_STREAM_ERROR;\n  }\n\n  state = strm.state;\n  if (state.mode === TYPE) { state.mode = TYPEDO; }    /* skip check */\n\n\n  //--- LOAD() ---\n  put = strm.next_out;\n  output = strm.output;\n  left = strm.avail_out;\n  next = strm.next_in;\n  input = strm.input;\n  have = strm.avail_in;\n  hold = state.hold;\n  bits = state.bits;\n  //---\n\n  _in = have;\n  _out = left;\n  ret = Z_OK;\n\n  inf_leave: // goto emulation\n  for (;;) {\n    switch (state.mode) {\n    case HEAD:\n      if (state.wrap === 0) {\n        state.mode = TYPEDO;\n        break;\n      }\n      //=== NEEDBITS(16);\n      while (bits < 16) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      if ((state.wrap & 2) && hold === 0x8b1f) {  /* gzip header */\n        state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n        //=== CRC2(state.check, hold);\n        hbuf[0] = hold & 0xff;\n        hbuf[1] = (hold >>> 8) & 0xff;\n        state.check = crc32(state.check, hbuf, 2, 0);\n        //===//\n\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        state.mode = FLAGS;\n        break;\n      }\n      state.flags = 0;           /* expect zlib header */\n      if (state.head) {\n        state.head.done = false;\n      }\n      if (!(state.wrap & 1) ||   /* check if zlib header allowed */\n        (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n        strm.msg = 'incorrect header check';\n        state.mode = BAD;\n        break;\n      }\n      if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n        strm.msg = 'unknown compression method';\n        state.mode = BAD;\n        break;\n      }\n      //--- DROPBITS(4) ---//\n      hold >>>= 4;\n      bits -= 4;\n      //---//\n      len = (hold & 0x0f)/*BITS(4)*/ + 8;\n      if (state.wbits === 0) {\n        state.wbits = len;\n      }\n      else if (len > state.wbits) {\n        strm.msg = 'invalid window size';\n        state.mode = BAD;\n        break;\n      }\n      state.dmax = 1 << len;\n      //Tracev((stderr, \"inflate:   zlib header ok\\n\"));\n      strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n      state.mode = hold & 0x200 ? DICTID : TYPE;\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      break;\n    case FLAGS:\n      //=== NEEDBITS(16); */\n      while (bits < 16) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      state.flags = hold;\n      if ((state.flags & 0xff) !== Z_DEFLATED) {\n        strm.msg = 'unknown compression method';\n        state.mode = BAD;\n        break;\n      }\n      if (state.flags & 0xe000) {\n        strm.msg = 'unknown header flags set';\n        state.mode = BAD;\n        break;\n      }\n      if (state.head) {\n        state.head.text = ((hold >> 8) & 1);\n      }\n      if (state.flags & 0x0200) {\n        //=== CRC2(state.check, hold);\n        hbuf[0] = hold & 0xff;\n        hbuf[1] = (hold >>> 8) & 0xff;\n        state.check = crc32(state.check, hbuf, 2, 0);\n        //===//\n      }\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      state.mode = TIME;\n      /* falls through */\n    case TIME:\n      //=== NEEDBITS(32); */\n      while (bits < 32) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      if (state.head) {\n        state.head.time = hold;\n      }\n      if (state.flags & 0x0200) {\n        //=== CRC4(state.check, hold)\n        hbuf[0] = hold & 0xff;\n        hbuf[1] = (hold >>> 8) & 0xff;\n        hbuf[2] = (hold >>> 16) & 0xff;\n        hbuf[3] = (hold >>> 24) & 0xff;\n        state.check = crc32(state.check, hbuf, 4, 0);\n        //===\n      }\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      state.mode = OS;\n      /* falls through */\n    case OS:\n      //=== NEEDBITS(16); */\n      while (bits < 16) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      if (state.head) {\n        state.head.xflags = (hold & 0xff);\n        state.head.os = (hold >> 8);\n      }\n      if (state.flags & 0x0200) {\n        //=== CRC2(state.check, hold);\n        hbuf[0] = hold & 0xff;\n        hbuf[1] = (hold >>> 8) & 0xff;\n        state.check = crc32(state.check, hbuf, 2, 0);\n        //===//\n      }\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      state.mode = EXLEN;\n      /* falls through */\n    case EXLEN:\n      if (state.flags & 0x0400) {\n        //=== NEEDBITS(16); */\n        while (bits < 16) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.length = hold;\n        if (state.head) {\n          state.head.extra_len = hold;\n        }\n        if (state.flags & 0x0200) {\n          //=== CRC2(state.check, hold);\n          hbuf[0] = hold & 0xff;\n          hbuf[1] = (hold >>> 8) & 0xff;\n          state.check = crc32(state.check, hbuf, 2, 0);\n          //===//\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n      }\n      else if (state.head) {\n        state.head.extra = null/*Z_NULL*/;\n      }\n      state.mode = EXTRA;\n      /* falls through */\n    case EXTRA:\n      if (state.flags & 0x0400) {\n        copy = state.length;\n        if (copy > have) { copy = have; }\n        if (copy) {\n          if (state.head) {\n            len = state.head.extra_len - state.length;\n            if (!state.head.extra) {\n              // Use untyped array for more conveniend processing later\n              state.head.extra = new Array(state.head.extra_len);\n            }\n            utils.arraySet(\n              state.head.extra,\n              input,\n              next,\n              // extra field is limited to 65536 bytes\n              // - no need for additional size check\n              copy,\n              /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n              len\n            );\n            //zmemcpy(state.head.extra + len, next,\n            //        len + copy > state.head.extra_max ?\n            //        state.head.extra_max - len : copy);\n          }\n          if (state.flags & 0x0200) {\n            state.check = crc32(state.check, input, copy, next);\n          }\n          have -= copy;\n          next += copy;\n          state.length -= copy;\n        }\n        if (state.length) { break inf_leave; }\n      }\n      state.length = 0;\n      state.mode = NAME;\n      /* falls through */\n    case NAME:\n      if (state.flags & 0x0800) {\n        if (have === 0) { break inf_leave; }\n        copy = 0;\n        do {\n          // TODO: 2 or 1 bytes?\n          len = input[next + copy++];\n          /* use constant limit because in js we should not preallocate memory */\n          if (state.head && len &&\n              (state.length < 65536 /*state.head.name_max*/)) {\n            state.head.name += String.fromCharCode(len);\n          }\n        } while (len && copy < have);\n\n        if (state.flags & 0x0200) {\n          state.check = crc32(state.check, input, copy, next);\n        }\n        have -= copy;\n        next += copy;\n        if (len) { break inf_leave; }\n      }\n      else if (state.head) {\n        state.head.name = null;\n      }\n      state.length = 0;\n      state.mode = COMMENT;\n      /* falls through */\n    case COMMENT:\n      if (state.flags & 0x1000) {\n        if (have === 0) { break inf_leave; }\n        copy = 0;\n        do {\n          len = input[next + copy++];\n          /* use constant limit because in js we should not preallocate memory */\n          if (state.head && len &&\n              (state.length < 65536 /*state.head.comm_max*/)) {\n            state.head.comment += String.fromCharCode(len);\n          }\n        } while (len && copy < have);\n        if (state.flags & 0x0200) {\n          state.check = crc32(state.check, input, copy, next);\n        }\n        have -= copy;\n        next += copy;\n        if (len) { break inf_leave; }\n      }\n      else if (state.head) {\n        state.head.comment = null;\n      }\n      state.mode = HCRC;\n      /* falls through */\n    case HCRC:\n      if (state.flags & 0x0200) {\n        //=== NEEDBITS(16); */\n        while (bits < 16) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if (hold !== (state.check & 0xffff)) {\n          strm.msg = 'header crc mismatch';\n          state.mode = BAD;\n          break;\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n      }\n      if (state.head) {\n        state.head.hcrc = ((state.flags >> 9) & 1);\n        state.head.done = true;\n      }\n      strm.adler = state.check = 0;\n      state.mode = TYPE;\n      break;\n    case DICTID:\n      //=== NEEDBITS(32); */\n      while (bits < 32) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      strm.adler = state.check = zswap32(hold);\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      state.mode = DICT;\n      /* falls through */\n    case DICT:\n      if (state.havedict === 0) {\n        //--- RESTORE() ---\n        strm.next_out = put;\n        strm.avail_out = left;\n        strm.next_in = next;\n        strm.avail_in = have;\n        state.hold = hold;\n        state.bits = bits;\n        //---\n        return Z_NEED_DICT;\n      }\n      strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n      state.mode = TYPE;\n      /* falls through */\n    case TYPE:\n      if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n      /* falls through */\n    case TYPEDO:\n      if (state.last) {\n        //--- BYTEBITS() ---//\n        hold >>>= bits & 7;\n        bits -= bits & 7;\n        //---//\n        state.mode = CHECK;\n        break;\n      }\n      //=== NEEDBITS(3); */\n      while (bits < 3) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      state.last = (hold & 0x01)/*BITS(1)*/;\n      //--- DROPBITS(1) ---//\n      hold >>>= 1;\n      bits -= 1;\n      //---//\n\n      switch ((hold & 0x03)/*BITS(2)*/) {\n      case 0:                             /* stored block */\n        //Tracev((stderr, \"inflate:     stored block%s\\n\",\n        //        state.last ? \" (last)\" : \"\"));\n        state.mode = STORED;\n        break;\n      case 1:                             /* fixed block */\n        fixedtables(state);\n        //Tracev((stderr, \"inflate:     fixed codes block%s\\n\",\n        //        state.last ? \" (last)\" : \"\"));\n        state.mode = LEN_;             /* decode codes */\n        if (flush === Z_TREES) {\n          //--- DROPBITS(2) ---//\n          hold >>>= 2;\n          bits -= 2;\n          //---//\n          break inf_leave;\n        }\n        break;\n      case 2:                             /* dynamic block */\n        //Tracev((stderr, \"inflate:     dynamic codes block%s\\n\",\n        //        state.last ? \" (last)\" : \"\"));\n        state.mode = TABLE;\n        break;\n      case 3:\n        strm.msg = 'invalid block type';\n        state.mode = BAD;\n      }\n      //--- DROPBITS(2) ---//\n      hold >>>= 2;\n      bits -= 2;\n      //---//\n      break;\n    case STORED:\n      //--- BYTEBITS() ---// /* go to byte boundary */\n      hold >>>= bits & 7;\n      bits -= bits & 7;\n      //---//\n      //=== NEEDBITS(32); */\n      while (bits < 32) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n        strm.msg = 'invalid stored block lengths';\n        state.mode = BAD;\n        break;\n      }\n      state.length = hold & 0xffff;\n      //Tracev((stderr, \"inflate:       stored length %u\\n\",\n      //        state.length));\n      //=== INITBITS();\n      hold = 0;\n      bits = 0;\n      //===//\n      state.mode = COPY_;\n      if (flush === Z_TREES) { break inf_leave; }\n      /* falls through */\n    case COPY_:\n      state.mode = COPY;\n      /* falls through */\n    case COPY:\n      copy = state.length;\n      if (copy) {\n        if (copy > have) { copy = have; }\n        if (copy > left) { copy = left; }\n        if (copy === 0) { break inf_leave; }\n        //--- zmemcpy(put, next, copy); ---\n        utils.arraySet(output, input, next, copy, put);\n        //---//\n        have -= copy;\n        next += copy;\n        left -= copy;\n        put += copy;\n        state.length -= copy;\n        break;\n      }\n      //Tracev((stderr, \"inflate:       stored end\\n\"));\n      state.mode = TYPE;\n      break;\n    case TABLE:\n      //=== NEEDBITS(14); */\n      while (bits < 14) {\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n      }\n      //===//\n      state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n      //--- DROPBITS(5) ---//\n      hold >>>= 5;\n      bits -= 5;\n      //---//\n      state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n      //--- DROPBITS(5) ---//\n      hold >>>= 5;\n      bits -= 5;\n      //---//\n      state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n      //--- DROPBITS(4) ---//\n      hold >>>= 4;\n      bits -= 4;\n      //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n      if (state.nlen > 286 || state.ndist > 30) {\n        strm.msg = 'too many length or distance symbols';\n        state.mode = BAD;\n        break;\n      }\n//#endif\n      //Tracev((stderr, \"inflate:       table sizes ok\\n\"));\n      state.have = 0;\n      state.mode = LENLENS;\n      /* falls through */\n    case LENLENS:\n      while (state.have < state.ncode) {\n        //=== NEEDBITS(3);\n        while (bits < 3) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n        //--- DROPBITS(3) ---//\n        hold >>>= 3;\n        bits -= 3;\n        //---//\n      }\n      while (state.have < 19) {\n        state.lens[order[state.have++]] = 0;\n      }\n      // We have separate tables & no pointers. 2 commented lines below not needed.\n      //state.next = state.codes;\n      //state.lencode = state.next;\n      // Switch to use dynamic table\n      state.lencode = state.lendyn;\n      state.lenbits = 7;\n\n      opts = { bits: state.lenbits };\n      ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n      state.lenbits = opts.bits;\n\n      if (ret) {\n        strm.msg = 'invalid code lengths set';\n        state.mode = BAD;\n        break;\n      }\n      //Tracev((stderr, \"inflate:       code lengths ok\\n\"));\n      state.have = 0;\n      state.mode = CODELENS;\n      /* falls through */\n    case CODELENS:\n      while (state.have < state.nlen + state.ndist) {\n        for (;;) {\n          here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n          here_bits = here >>> 24;\n          here_op = (here >>> 16) & 0xff;\n          here_val = here & 0xffff;\n\n          if ((here_bits) <= bits) { break; }\n          //--- PULLBYTE() ---//\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n          //---//\n        }\n        if (here_val < 16) {\n          //--- DROPBITS(here.bits) ---//\n          hold >>>= here_bits;\n          bits -= here_bits;\n          //---//\n          state.lens[state.have++] = here_val;\n        }\n        else {\n          if (here_val === 16) {\n            //=== NEEDBITS(here.bits + 2);\n            n = here_bits + 2;\n            while (bits < n) {\n              if (have === 0) { break inf_leave; }\n              have--;\n              hold += input[next++] << bits;\n              bits += 8;\n            }\n            //===//\n            //--- DROPBITS(here.bits) ---//\n            hold >>>= here_bits;\n            bits -= here_bits;\n            //---//\n            if (state.have === 0) {\n              strm.msg = 'invalid bit length repeat';\n              state.mode = BAD;\n              break;\n            }\n            len = state.lens[state.have - 1];\n            copy = 3 + (hold & 0x03);//BITS(2);\n            //--- DROPBITS(2) ---//\n            hold >>>= 2;\n            bits -= 2;\n            //---//\n          }\n          else if (here_val === 17) {\n            //=== NEEDBITS(here.bits + 3);\n            n = here_bits + 3;\n            while (bits < n) {\n              if (have === 0) { break inf_leave; }\n              have--;\n              hold += input[next++] << bits;\n              bits += 8;\n            }\n            //===//\n            //--- DROPBITS(here.bits) ---//\n            hold >>>= here_bits;\n            bits -= here_bits;\n            //---//\n            len = 0;\n            copy = 3 + (hold & 0x07);//BITS(3);\n            //--- DROPBITS(3) ---//\n            hold >>>= 3;\n            bits -= 3;\n            //---//\n          }\n          else {\n            //=== NEEDBITS(here.bits + 7);\n            n = here_bits + 7;\n            while (bits < n) {\n              if (have === 0) { break inf_leave; }\n              have--;\n              hold += input[next++] << bits;\n              bits += 8;\n            }\n            //===//\n            //--- DROPBITS(here.bits) ---//\n            hold >>>= here_bits;\n            bits -= here_bits;\n            //---//\n            len = 0;\n            copy = 11 + (hold & 0x7f);//BITS(7);\n            //--- DROPBITS(7) ---//\n            hold >>>= 7;\n            bits -= 7;\n            //---//\n          }\n          if (state.have + copy > state.nlen + state.ndist) {\n            strm.msg = 'invalid bit length repeat';\n            state.mode = BAD;\n            break;\n          }\n          while (copy--) {\n            state.lens[state.have++] = len;\n          }\n        }\n      }\n\n      /* handle error breaks in while */\n      if (state.mode === BAD) { break; }\n\n      /* check for end-of-block code (better have one) */\n      if (state.lens[256] === 0) {\n        strm.msg = 'invalid code -- missing end-of-block';\n        state.mode = BAD;\n        break;\n      }\n\n      /* build code tables -- note: do not change the lenbits or distbits\n         values here (9 and 6) without reading the comments in inftrees.h\n         concerning the ENOUGH constants, which depend on those values */\n      state.lenbits = 9;\n\n      opts = { bits: state.lenbits };\n      ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n      // We have separate tables & no pointers. 2 commented lines below not needed.\n      // state.next_index = opts.table_index;\n      state.lenbits = opts.bits;\n      // state.lencode = state.next;\n\n      if (ret) {\n        strm.msg = 'invalid literal/lengths set';\n        state.mode = BAD;\n        break;\n      }\n\n      state.distbits = 6;\n      //state.distcode.copy(state.codes);\n      // Switch to use dynamic table\n      state.distcode = state.distdyn;\n      opts = { bits: state.distbits };\n      ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n      // We have separate tables & no pointers. 2 commented lines below not needed.\n      // state.next_index = opts.table_index;\n      state.distbits = opts.bits;\n      // state.distcode = state.next;\n\n      if (ret) {\n        strm.msg = 'invalid distances set';\n        state.mode = BAD;\n        break;\n      }\n      //Tracev((stderr, 'inflate:       codes ok\\n'));\n      state.mode = LEN_;\n      if (flush === Z_TREES) { break inf_leave; }\n      /* falls through */\n    case LEN_:\n      state.mode = LEN;\n      /* falls through */\n    case LEN:\n      if (have >= 6 && left >= 258) {\n        //--- RESTORE() ---\n        strm.next_out = put;\n        strm.avail_out = left;\n        strm.next_in = next;\n        strm.avail_in = have;\n        state.hold = hold;\n        state.bits = bits;\n        //---\n        inflate_fast(strm, _out);\n        //--- LOAD() ---\n        put = strm.next_out;\n        output = strm.output;\n        left = strm.avail_out;\n        next = strm.next_in;\n        input = strm.input;\n        have = strm.avail_in;\n        hold = state.hold;\n        bits = state.bits;\n        //---\n\n        if (state.mode === TYPE) {\n          state.back = -1;\n        }\n        break;\n      }\n      state.back = 0;\n      for (;;) {\n        here = state.lencode[hold & ((1 << state.lenbits) - 1)];  /*BITS(state.lenbits)*/\n        here_bits = here >>> 24;\n        here_op = (here >>> 16) & 0xff;\n        here_val = here & 0xffff;\n\n        if (here_bits <= bits) { break; }\n        //--- PULLBYTE() ---//\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n        //---//\n      }\n      if (here_op && (here_op & 0xf0) === 0) {\n        last_bits = here_bits;\n        last_op = here_op;\n        last_val = here_val;\n        for (;;) {\n          here = state.lencode[last_val +\n                  ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n          here_bits = here >>> 24;\n          here_op = (here >>> 16) & 0xff;\n          here_val = here & 0xffff;\n\n          if ((last_bits + here_bits) <= bits) { break; }\n          //--- PULLBYTE() ---//\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n          //---//\n        }\n        //--- DROPBITS(last.bits) ---//\n        hold >>>= last_bits;\n        bits -= last_bits;\n        //---//\n        state.back += last_bits;\n      }\n      //--- DROPBITS(here.bits) ---//\n      hold >>>= here_bits;\n      bits -= here_bits;\n      //---//\n      state.back += here_bits;\n      state.length = here_val;\n      if (here_op === 0) {\n        //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n        //        \"inflate:         literal '%c'\\n\" :\n        //        \"inflate:         literal 0x%02x\\n\", here.val));\n        state.mode = LIT;\n        break;\n      }\n      if (here_op & 32) {\n        //Tracevv((stderr, \"inflate:         end of block\\n\"));\n        state.back = -1;\n        state.mode = TYPE;\n        break;\n      }\n      if (here_op & 64) {\n        strm.msg = 'invalid literal/length code';\n        state.mode = BAD;\n        break;\n      }\n      state.extra = here_op & 15;\n      state.mode = LENEXT;\n      /* falls through */\n    case LENEXT:\n      if (state.extra) {\n        //=== NEEDBITS(state.extra);\n        n = state.extra;\n        while (bits < n) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n        //--- DROPBITS(state.extra) ---//\n        hold >>>= state.extra;\n        bits -= state.extra;\n        //---//\n        state.back += state.extra;\n      }\n      //Tracevv((stderr, \"inflate:         length %u\\n\", state.length));\n      state.was = state.length;\n      state.mode = DIST;\n      /* falls through */\n    case DIST:\n      for (;;) {\n        here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n        here_bits = here >>> 24;\n        here_op = (here >>> 16) & 0xff;\n        here_val = here & 0xffff;\n\n        if ((here_bits) <= bits) { break; }\n        //--- PULLBYTE() ---//\n        if (have === 0) { break inf_leave; }\n        have--;\n        hold += input[next++] << bits;\n        bits += 8;\n        //---//\n      }\n      if ((here_op & 0xf0) === 0) {\n        last_bits = here_bits;\n        last_op = here_op;\n        last_val = here_val;\n        for (;;) {\n          here = state.distcode[last_val +\n                  ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n          here_bits = here >>> 24;\n          here_op = (here >>> 16) & 0xff;\n          here_val = here & 0xffff;\n\n          if ((last_bits + here_bits) <= bits) { break; }\n          //--- PULLBYTE() ---//\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n          //---//\n        }\n        //--- DROPBITS(last.bits) ---//\n        hold >>>= last_bits;\n        bits -= last_bits;\n        //---//\n        state.back += last_bits;\n      }\n      //--- DROPBITS(here.bits) ---//\n      hold >>>= here_bits;\n      bits -= here_bits;\n      //---//\n      state.back += here_bits;\n      if (here_op & 64) {\n        strm.msg = 'invalid distance code';\n        state.mode = BAD;\n        break;\n      }\n      state.offset = here_val;\n      state.extra = (here_op) & 15;\n      state.mode = DISTEXT;\n      /* falls through */\n    case DISTEXT:\n      if (state.extra) {\n        //=== NEEDBITS(state.extra);\n        n = state.extra;\n        while (bits < n) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n        //--- DROPBITS(state.extra) ---//\n        hold >>>= state.extra;\n        bits -= state.extra;\n        //---//\n        state.back += state.extra;\n      }\n//#ifdef INFLATE_STRICT\n      if (state.offset > state.dmax) {\n        strm.msg = 'invalid distance too far back';\n        state.mode = BAD;\n        break;\n      }\n//#endif\n      //Tracevv((stderr, \"inflate:         distance %u\\n\", state.offset));\n      state.mode = MATCH;\n      /* falls through */\n    case MATCH:\n      if (left === 0) { break inf_leave; }\n      copy = _out - left;\n      if (state.offset > copy) {         /* copy from window */\n        copy = state.offset - copy;\n        if (copy > state.whave) {\n          if (state.sane) {\n            strm.msg = 'invalid distance too far back';\n            state.mode = BAD;\n            break;\n          }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n//          Trace((stderr, \"inflate.c too far\\n\"));\n//          copy -= state.whave;\n//          if (copy > state.length) { copy = state.length; }\n//          if (copy > left) { copy = left; }\n//          left -= copy;\n//          state.length -= copy;\n//          do {\n//            output[put++] = 0;\n//          } while (--copy);\n//          if (state.length === 0) { state.mode = LEN; }\n//          break;\n//#endif\n        }\n        if (copy > state.wnext) {\n          copy -= state.wnext;\n          from = state.wsize - copy;\n        }\n        else {\n          from = state.wnext - copy;\n        }\n        if (copy > state.length) { copy = state.length; }\n        from_source = state.window;\n      }\n      else {                              /* copy from output */\n        from_source = output;\n        from = put - state.offset;\n        copy = state.length;\n      }\n      if (copy > left) { copy = left; }\n      left -= copy;\n      state.length -= copy;\n      do {\n        output[put++] = from_source[from++];\n      } while (--copy);\n      if (state.length === 0) { state.mode = LEN; }\n      break;\n    case LIT:\n      if (left === 0) { break inf_leave; }\n      output[put++] = state.length;\n      left--;\n      state.mode = LEN;\n      break;\n    case CHECK:\n      if (state.wrap) {\n        //=== NEEDBITS(32);\n        while (bits < 32) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          // Use '|' insdead of '+' to make sure that result is signed\n          hold |= input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        _out -= left;\n        strm.total_out += _out;\n        state.total += _out;\n        if (_out) {\n          strm.adler = state.check =\n              /*UPDATE(state.check, put - _out, _out);*/\n              (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n        }\n        _out = left;\n        // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n        if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n          strm.msg = 'incorrect data check';\n          state.mode = BAD;\n          break;\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        //Tracev((stderr, \"inflate:   check matches trailer\\n\"));\n      }\n      state.mode = LENGTH;\n      /* falls through */\n    case LENGTH:\n      if (state.wrap && state.flags) {\n        //=== NEEDBITS(32);\n        while (bits < 32) {\n          if (have === 0) { break inf_leave; }\n          have--;\n          hold += input[next++] << bits;\n          bits += 8;\n        }\n        //===//\n        if (hold !== (state.total & 0xffffffff)) {\n          strm.msg = 'incorrect length check';\n          state.mode = BAD;\n          break;\n        }\n        //=== INITBITS();\n        hold = 0;\n        bits = 0;\n        //===//\n        //Tracev((stderr, \"inflate:   length matches trailer\\n\"));\n      }\n      state.mode = DONE;\n      /* falls through */\n    case DONE:\n      ret = Z_STREAM_END;\n      break inf_leave;\n    case BAD:\n      ret = Z_DATA_ERROR;\n      break inf_leave;\n    case MEM:\n      return Z_MEM_ERROR;\n    case SYNC:\n      /* falls through */\n    default:\n      return Z_STREAM_ERROR;\n    }\n  }\n\n  // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n  /*\n     Return from inflate(), updating the total counts and the check value.\n     If there was no progress during the inflate() call, return a buffer\n     error.  Call updatewindow() to create and/or update the window state.\n     Note: a memory error from inflate() is non-recoverable.\n   */\n\n  //--- RESTORE() ---\n  strm.next_out = put;\n  strm.avail_out = left;\n  strm.next_in = next;\n  strm.avail_in = have;\n  state.hold = hold;\n  state.bits = bits;\n  //---\n\n  if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n                      (state.mode < CHECK || flush !== Z_FINISH))) {\n    if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n      state.mode = MEM;\n      return Z_MEM_ERROR;\n    }\n  }\n  _in -= strm.avail_in;\n  _out -= strm.avail_out;\n  strm.total_in += _in;\n  strm.total_out += _out;\n  state.total += _out;\n  if (state.wrap && _out) {\n    strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n      (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n  }\n  strm.data_type = state.bits + (state.last ? 64 : 0) +\n                    (state.mode === TYPE ? 128 : 0) +\n                    (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n  if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n    ret = Z_BUF_ERROR;\n  }\n  return ret;\n}\n\nfunction inflateEnd(strm) {\n\n  if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n    return Z_STREAM_ERROR;\n  }\n\n  var state = strm.state;\n  if (state.window) {\n    state.window = null;\n  }\n  strm.state = null;\n  return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n  var state;\n\n  /* check state */\n  if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n  state = strm.state;\n  if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n  /* save header structure */\n  state.head = head;\n  head.done = false;\n  return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n  var dictLength = dictionary.length;\n\n  var state;\n  var dictid;\n  var ret;\n\n  /* check state */\n  if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n  state = strm.state;\n\n  if (state.wrap !== 0 && state.mode !== DICT) {\n    return Z_STREAM_ERROR;\n  }\n\n  /* check for correct dictionary identifier */\n  if (state.mode === DICT) {\n    dictid = 1; /* adler32(0, null, 0)*/\n    /* dictid = adler32(dictid, dictionary, dictLength); */\n    dictid = adler32(dictid, dictionary, dictLength, 0);\n    if (dictid !== state.check) {\n      return Z_DATA_ERROR;\n    }\n  }\n  /* copy dictionary to window using updatewindow(), which will amend the\n   existing dictionary if appropriate */\n  ret = updatewindow(strm, dictionary, dictLength, dictLength);\n  if (ret) {\n    state.mode = MEM;\n    return Z_MEM_ERROR;\n  }\n  state.havedict = 1;\n  // Tracev((stderr, \"inflate:   dictionary set\\n\"));\n  return Z_OK;\n}\n\nexports.inflateReset = inflateReset;\nexports.inflateReset2 = inflateReset2;\nexports.inflateResetKeep = inflateResetKeep;\nexports.inflateInit = inflateInit;\nexports.inflateInit2 = inflateInit2;\nexports.inflate = inflate;\nexports.inflateEnd = inflateEnd;\nexports.inflateGetHeader = inflateGetHeader;\nexports.inflateSetDictionary = inflateSetDictionary;\nexports.inflateInfo = 'pako inflate (from Nodeca project)';\n\n/* Not implemented\nexports.inflateCopy = inflateCopy;\nexports.inflateGetDictionary = inflateGetDictionary;\nexports.inflateMark = inflateMark;\nexports.inflatePrime = inflatePrime;\nexports.inflateSync = inflateSync;\nexports.inflateSyncPoint = inflateSyncPoint;\nexports.inflateUndermine = inflateUndermine;\n*/\n\n},{\"../utils/common\":41,\"./adler32\":43,\"./crc32\":45,\"./inffast\":48,\"./inftrees\":50}],50:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n  3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n  35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n  16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n  19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n  1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n  257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n  8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n  16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n  23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n  28, 28, 29, 29, 64, 64\n];\n\nmodule.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n  var bits = opts.bits;\n      //here = opts.here; /* table entry for duplication */\n\n  var len = 0;               /* a code's length in bits */\n  var sym = 0;               /* index of code symbols */\n  var min = 0, max = 0;          /* minimum and maximum code lengths */\n  var root = 0;              /* number of index bits for root table */\n  var curr = 0;              /* number of index bits for current table */\n  var drop = 0;              /* code bits to drop for sub-table */\n  var left = 0;                   /* number of prefix codes available */\n  var used = 0;              /* code entries in table used */\n  var huff = 0;              /* Huffman code */\n  var incr;              /* for incrementing code, index */\n  var fill;              /* index for replicating entries */\n  var low;               /* low bits for current root entry */\n  var mask;              /* mask for low root bits */\n  var next;             /* next available space in table */\n  var base = null;     /* base value table to use */\n  var base_index = 0;\n//  var shoextra;    /* extra bits table to use */\n  var end;                    /* use base and extra for symbol > end */\n  var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1];    /* number of codes of each length */\n  var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1];     /* offsets in table for each length */\n  var extra = null;\n  var extra_index = 0;\n\n  var here_bits, here_op, here_val;\n\n  /*\n   Process a set of code lengths to create a canonical Huffman code.  The\n   code lengths are lens[0..codes-1].  Each length corresponds to the\n   symbols 0..codes-1.  The Huffman code is generated by first sorting the\n   symbols by length from short to long, and retaining the symbol order\n   for codes with equal lengths.  Then the code starts with all zero bits\n   for the first code of the shortest length, and the codes are integer\n   increments for the same length, and zeros are appended as the length\n   increases.  For the deflate format, these bits are stored backwards\n   from their more natural integer increment ordering, and so when the\n   decoding tables are built in the large loop below, the integer codes\n   are incremented backwards.\n\n   This routine assumes, but does not check, that all of the entries in\n   lens[] are in the range 0..MAXBITS.  The caller must assure this.\n   1..MAXBITS is interpreted as that code length.  zero means that that\n   symbol does not occur in this code.\n\n   The codes are sorted by computing a count of codes for each length,\n   creating from that a table of starting indices for each length in the\n   sorted table, and then entering the symbols in order in the sorted\n   table.  The sorted table is work[], with that space being provided by\n   the caller.\n\n   The length counts are used for other purposes as well, i.e. finding\n   the minimum and maximum length codes, determining if there are any\n   codes at all, checking for a valid set of lengths, and looking ahead\n   at length counts to determine sub-table sizes when building the\n   decoding tables.\n   */\n\n  /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n  for (len = 0; len <= MAXBITS; len++) {\n    count[len] = 0;\n  }\n  for (sym = 0; sym < codes; sym++) {\n    count[lens[lens_index + sym]]++;\n  }\n\n  /* bound code lengths, force root to be within code lengths */\n  root = bits;\n  for (max = MAXBITS; max >= 1; max--) {\n    if (count[max] !== 0) { break; }\n  }\n  if (root > max) {\n    root = max;\n  }\n  if (max === 0) {                     /* no symbols to code at all */\n    //table.op[opts.table_index] = 64;  //here.op = (var char)64;    /* invalid code marker */\n    //table.bits[opts.table_index] = 1;   //here.bits = (var char)1;\n    //table.val[opts.table_index++] = 0;   //here.val = (var short)0;\n    table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n    //table.op[opts.table_index] = 64;\n    //table.bits[opts.table_index] = 1;\n    //table.val[opts.table_index++] = 0;\n    table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n    opts.bits = 1;\n    return 0;     /* no symbols, but wait for decoding to report error */\n  }\n  for (min = 1; min < max; min++) {\n    if (count[min] !== 0) { break; }\n  }\n  if (root < min) {\n    root = min;\n  }\n\n  /* check for an over-subscribed or incomplete set of lengths */\n  left = 1;\n  for (len = 1; len <= MAXBITS; len++) {\n    left <<= 1;\n    left -= count[len];\n    if (left < 0) {\n      return -1;\n    }        /* over-subscribed */\n  }\n  if (left > 0 && (type === CODES || max !== 1)) {\n    return -1;                      /* incomplete set */\n  }\n\n  /* generate offsets into symbol table for each length for sorting */\n  offs[1] = 0;\n  for (len = 1; len < MAXBITS; len++) {\n    offs[len + 1] = offs[len] + count[len];\n  }\n\n  /* sort symbols by length, by symbol order within each length */\n  for (sym = 0; sym < codes; sym++) {\n    if (lens[lens_index + sym] !== 0) {\n      work[offs[lens[lens_index + sym]]++] = sym;\n    }\n  }\n\n  /*\n   Create and fill in decoding tables.  In this loop, the table being\n   filled is at next and has curr index bits.  The code being used is huff\n   with length len.  That code is converted to an index by dropping drop\n   bits off of the bottom.  For codes where len is less than drop + curr,\n   those top drop + curr - len bits are incremented through all values to\n   fill the table with replicated entries.\n\n   root is the number of index bits for the root table.  When len exceeds\n   root, sub-tables are created pointed to by the root entry with an index\n   of the low root bits of huff.  This is saved in low to check for when a\n   new sub-table should be started.  drop is zero when the root table is\n   being filled, and drop is root when sub-tables are being filled.\n\n   When a new sub-table is needed, it is necessary to look ahead in the\n   code lengths to determine what size sub-table is needed.  The length\n   counts are used for this, and so count[] is decremented as codes are\n   entered in the tables.\n\n   used keeps track of how many table entries have been allocated from the\n   provided *table space.  It is checked for LENS and DIST tables against\n   the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n   the initial root table size constants.  See the comments in inftrees.h\n   for more information.\n\n   sym increments through all symbols, and the loop terminates when\n   all codes of length max, i.e. all codes, have been processed.  This\n   routine permits incomplete codes, so another loop after this one fills\n   in the rest of the decoding tables with invalid code markers.\n   */\n\n  /* set up for code type */\n  // poor man optimization - use if-else instead of switch,\n  // to avoid deopts in old v8\n  if (type === CODES) {\n    base = extra = work;    /* dummy value--not used */\n    end = 19;\n\n  } else if (type === LENS) {\n    base = lbase;\n    base_index -= 257;\n    extra = lext;\n    extra_index -= 257;\n    end = 256;\n\n  } else {                    /* DISTS */\n    base = dbase;\n    extra = dext;\n    end = -1;\n  }\n\n  /* initialize opts for loop */\n  huff = 0;                   /* starting code */\n  sym = 0;                    /* starting code symbol */\n  len = min;                  /* starting code length */\n  next = table_index;              /* current table to fill in */\n  curr = root;                /* current table index bits */\n  drop = 0;                   /* current bits to drop from code for index */\n  low = -1;                   /* trigger new sub-table when len > root */\n  used = 1 << root;          /* use root table entries */\n  mask = used - 1;            /* mask for comparing low */\n\n  /* check available table space */\n  if ((type === LENS && used > ENOUGH_LENS) ||\n    (type === DISTS && used > ENOUGH_DISTS)) {\n    return 1;\n  }\n\n  /* process all codes and make table entries */\n  for (;;) {\n    /* create table entry */\n    here_bits = len - drop;\n    if (work[sym] < end) {\n      here_op = 0;\n      here_val = work[sym];\n    }\n    else if (work[sym] > end) {\n      here_op = extra[extra_index + work[sym]];\n      here_val = base[base_index + work[sym]];\n    }\n    else {\n      here_op = 32 + 64;         /* end of block */\n      here_val = 0;\n    }\n\n    /* replicate for those indices with low len bits equal to huff */\n    incr = 1 << (len - drop);\n    fill = 1 << curr;\n    min = fill;                 /* save offset to next table */\n    do {\n      fill -= incr;\n      table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n    } while (fill !== 0);\n\n    /* backwards increment the len-bit code huff */\n    incr = 1 << (len - 1);\n    while (huff & incr) {\n      incr >>= 1;\n    }\n    if (incr !== 0) {\n      huff &= incr - 1;\n      huff += incr;\n    } else {\n      huff = 0;\n    }\n\n    /* go to next symbol, update count, len */\n    sym++;\n    if (--count[len] === 0) {\n      if (len === max) { break; }\n      len = lens[lens_index + work[sym]];\n    }\n\n    /* create new sub-table if needed */\n    if (len > root && (huff & mask) !== low) {\n      /* if first time, transition to sub-tables */\n      if (drop === 0) {\n        drop = root;\n      }\n\n      /* increment past last table */\n      next += min;            /* here min is 1 << curr */\n\n      /* determine length of next table */\n      curr = len - drop;\n      left = 1 << curr;\n      while (curr + drop < max) {\n        left -= count[curr + drop];\n        if (left <= 0) { break; }\n        curr++;\n        left <<= 1;\n      }\n\n      /* check for enough space */\n      used += 1 << curr;\n      if ((type === LENS && used > ENOUGH_LENS) ||\n        (type === DISTS && used > ENOUGH_DISTS)) {\n        return 1;\n      }\n\n      /* point entry in root table to sub-table */\n      low = huff & mask;\n      /*table.op[low] = curr;\n      table.bits[low] = root;\n      table.val[low] = next - opts.table_index;*/\n      table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n    }\n  }\n\n  /* fill in remaining table entry if code is incomplete (guaranteed to have\n   at most one remaining entry, since if the code is incomplete, the\n   maximum code length that was allowed to get this far is one bit) */\n  if (huff !== 0) {\n    //table.op[next + huff] = 64;            /* invalid code marker */\n    //table.bits[next + huff] = len - drop;\n    //table.val[next + huff] = 0;\n    table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n  }\n\n  /* set return parameters */\n  //opts.table_index += used;\n  opts.bits = root;\n  return 0;\n};\n\n},{\"../utils/common\":41}],51:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nmodule.exports = {\n  2:      'need dictionary',     /* Z_NEED_DICT       2  */\n  1:      'stream end',          /* Z_STREAM_END      1  */\n  0:      '',                    /* Z_OK              0  */\n  '-1':   'file error',          /* Z_ERRNO         (-1) */\n  '-2':   'stream error',        /* Z_STREAM_ERROR  (-2) */\n  '-3':   'data error',          /* Z_DATA_ERROR    (-3) */\n  '-4':   'insufficient memory', /* Z_MEM_ERROR     (-4) */\n  '-5':   'buffer error',        /* Z_BUF_ERROR     (-5) */\n  '-6':   'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n},{}],52:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nvar utils = require('../utils/common');\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n//var Z_FILTERED          = 1;\n//var Z_HUFFMAN_ONLY      = 2;\n//var Z_RLE               = 3;\nvar Z_FIXED               = 4;\n//var Z_DEFAULT_STRATEGY  = 0;\n\n/* Possible values of the data_type field (though see inflate()) */\nvar Z_BINARY              = 0;\nvar Z_TEXT                = 1;\n//var Z_ASCII             = 1; // = Z_TEXT\nvar Z_UNKNOWN             = 2;\n\n/*============================================================================*/\n\n\nfunction zero(buf) { var len = buf.length; while (--len >= 0) { buf[len] = 0; } }\n\n// From zutil.h\n\nvar STORED_BLOCK = 0;\nvar STATIC_TREES = 1;\nvar DYN_TREES    = 2;\n/* The three kinds of block type */\n\nvar MIN_MATCH    = 3;\nvar MAX_MATCH    = 258;\n/* The minimum and maximum match lengths */\n\n// From deflate.h\n/* ===========================================================================\n * Internal compression state.\n */\n\nvar LENGTH_CODES  = 29;\n/* number of length codes, not counting the special END_BLOCK code */\n\nvar LITERALS      = 256;\n/* number of literal bytes 0..255 */\n\nvar L_CODES       = LITERALS + 1 + LENGTH_CODES;\n/* number of Literal or Length codes, including the END_BLOCK code */\n\nvar D_CODES       = 30;\n/* number of distance codes */\n\nvar BL_CODES      = 19;\n/* number of codes used to transfer the bit lengths */\n\nvar HEAP_SIZE     = 2 * L_CODES + 1;\n/* maximum heap size */\n\nvar MAX_BITS      = 15;\n/* All codes must not exceed MAX_BITS bits */\n\nvar Buf_size      = 16;\n/* size of bit buffer in bi_buf */\n\n\n/* ===========================================================================\n * Constants\n */\n\nvar MAX_BL_BITS = 7;\n/* Bit length codes must not exceed MAX_BL_BITS bits */\n\nvar END_BLOCK   = 256;\n/* end of block literal code */\n\nvar REP_3_6     = 16;\n/* repeat previous bit length 3-6 times (2 bits of repeat count) */\n\nvar REPZ_3_10   = 17;\n/* repeat a zero length 3-10 times  (3 bits of repeat count) */\n\nvar REPZ_11_138 = 18;\n/* repeat a zero length 11-138 times  (7 bits of repeat count) */\n\n/* eslint-disable comma-spacing,array-bracket-spacing */\nvar extra_lbits =   /* extra bits for each length code */\n  [0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0];\n\nvar extra_dbits =   /* extra bits for each distance code */\n  [0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13];\n\nvar extra_blbits =  /* extra bits for each bit length code */\n  [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7];\n\nvar bl_order =\n  [16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];\n/* eslint-enable comma-spacing,array-bracket-spacing */\n\n/* The lengths of the bit length codes are sent in order of decreasing\n * probability, to avoid transmitting the lengths for unused bit length codes.\n */\n\n/* ===========================================================================\n * Local data. These are initialized only once.\n */\n\n// We pre-fill arrays with 0 to avoid uninitialized gaps\n\nvar DIST_CODE_LEN = 512; /* see definition of array dist_code below */\n\n// !!!! Use flat array insdead of structure, Freq = i*2, Len = i*2+1\nvar static_ltree  = new Array((L_CODES + 2) * 2);\nzero(static_ltree);\n/* The static literal tree. Since the bit lengths are imposed, there is no\n * need for the L_CODES extra codes used during heap construction. However\n * The codes 286 and 287 are needed to build a canonical tree (see _tr_init\n * below).\n */\n\nvar static_dtree  = new Array(D_CODES * 2);\nzero(static_dtree);\n/* The static distance tree. (Actually a trivial tree since all codes use\n * 5 bits.)\n */\n\nvar _dist_code    = new Array(DIST_CODE_LEN);\nzero(_dist_code);\n/* Distance codes. The first 256 values correspond to the distances\n * 3 .. 258, the last 256 values correspond to the top 8 bits of\n * the 15 bit distances.\n */\n\nvar _length_code  = new Array(MAX_MATCH - MIN_MATCH + 1);\nzero(_length_code);\n/* length code for each normalized match length (0 == MIN_MATCH) */\n\nvar base_length   = new Array(LENGTH_CODES);\nzero(base_length);\n/* First normalized length for each code (0 = MIN_MATCH) */\n\nvar base_dist     = new Array(D_CODES);\nzero(base_dist);\n/* First normalized distance for each code (0 = distance of 1) */\n\n\nfunction StaticTreeDesc(static_tree, extra_bits, extra_base, elems, max_length) {\n\n  this.static_tree  = static_tree;  /* static tree or NULL */\n  this.extra_bits   = extra_bits;   /* extra bits for each code or NULL */\n  this.extra_base   = extra_base;   /* base index for extra_bits */\n  this.elems        = elems;        /* max number of elements in the tree */\n  this.max_length   = max_length;   /* max bit length for the codes */\n\n  // show if `static_tree` has data or dummy - needed for monomorphic objects\n  this.has_stree    = static_tree && static_tree.length;\n}\n\n\nvar static_l_desc;\nvar static_d_desc;\nvar static_bl_desc;\n\n\nfunction TreeDesc(dyn_tree, stat_desc) {\n  this.dyn_tree = dyn_tree;     /* the dynamic tree */\n  this.max_code = 0;            /* largest code with non zero frequency */\n  this.stat_desc = stat_desc;   /* the corresponding static tree */\n}\n\n\n\nfunction d_code(dist) {\n  return dist < 256 ? _dist_code[dist] : _dist_code[256 + (dist >>> 7)];\n}\n\n\n/* ===========================================================================\n * Output a short LSB first on the stream.\n * IN assertion: there is enough room in pendingBuf.\n */\nfunction put_short(s, w) {\n//    put_byte(s, (uch)((w) & 0xff));\n//    put_byte(s, (uch)((ush)(w) >> 8));\n  s.pending_buf[s.pending++] = (w) & 0xff;\n  s.pending_buf[s.pending++] = (w >>> 8) & 0xff;\n}\n\n\n/* ===========================================================================\n * Send a value on a given number of bits.\n * IN assertion: length <= 16 and value fits in length bits.\n */\nfunction send_bits(s, value, length) {\n  if (s.bi_valid > (Buf_size - length)) {\n    s.bi_buf |= (value << s.bi_valid) & 0xffff;\n    put_short(s, s.bi_buf);\n    s.bi_buf = value >> (Buf_size - s.bi_valid);\n    s.bi_valid += length - Buf_size;\n  } else {\n    s.bi_buf |= (value << s.bi_valid) & 0xffff;\n    s.bi_valid += length;\n  }\n}\n\n\nfunction send_code(s, c, tree) {\n  send_bits(s, tree[c * 2]/*.Code*/, tree[c * 2 + 1]/*.Len*/);\n}\n\n\n/* ===========================================================================\n * Reverse the first len bits of a code, using straightforward code (a faster\n * method would use a table)\n * IN assertion: 1 <= len <= 15\n */\nfunction bi_reverse(code, len) {\n  var res = 0;\n  do {\n    res |= code & 1;\n    code >>>= 1;\n    res <<= 1;\n  } while (--len > 0);\n  return res >>> 1;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer, keeping at most 7 bits in it.\n */\nfunction bi_flush(s) {\n  if (s.bi_valid === 16) {\n    put_short(s, s.bi_buf);\n    s.bi_buf = 0;\n    s.bi_valid = 0;\n\n  } else if (s.bi_valid >= 8) {\n    s.pending_buf[s.pending++] = s.bi_buf & 0xff;\n    s.bi_buf >>= 8;\n    s.bi_valid -= 8;\n  }\n}\n\n\n/* ===========================================================================\n * Compute the optimal bit lengths for a tree and update the total bit length\n * for the current block.\n * IN assertion: the fields freq and dad are set, heap[heap_max] and\n *    above are the tree nodes sorted by increasing frequency.\n * OUT assertions: the field len is set to the optimal bit length, the\n *     array bl_count contains the frequencies for each bit length.\n *     The length opt_len is updated; static_len is also updated if stree is\n *     not null.\n */\nfunction gen_bitlen(s, desc)\n//    deflate_state *s;\n//    tree_desc *desc;    /* the tree descriptor */\n{\n  var tree            = desc.dyn_tree;\n  var max_code        = desc.max_code;\n  var stree           = desc.stat_desc.static_tree;\n  var has_stree       = desc.stat_desc.has_stree;\n  var extra           = desc.stat_desc.extra_bits;\n  var base            = desc.stat_desc.extra_base;\n  var max_length      = desc.stat_desc.max_length;\n  var h;              /* heap index */\n  var n, m;           /* iterate over the tree elements */\n  var bits;           /* bit length */\n  var xbits;          /* extra bits */\n  var f;              /* frequency */\n  var overflow = 0;   /* number of elements with bit length too large */\n\n  for (bits = 0; bits <= MAX_BITS; bits++) {\n    s.bl_count[bits] = 0;\n  }\n\n  /* In a first pass, compute the optimal bit lengths (which may\n   * overflow in the case of the bit length tree).\n   */\n  tree[s.heap[s.heap_max] * 2 + 1]/*.Len*/ = 0; /* root of the heap */\n\n  for (h = s.heap_max + 1; h < HEAP_SIZE; h++) {\n    n = s.heap[h];\n    bits = tree[tree[n * 2 + 1]/*.Dad*/ * 2 + 1]/*.Len*/ + 1;\n    if (bits > max_length) {\n      bits = max_length;\n      overflow++;\n    }\n    tree[n * 2 + 1]/*.Len*/ = bits;\n    /* We overwrite tree[n].Dad which is no longer needed */\n\n    if (n > max_code) { continue; } /* not a leaf node */\n\n    s.bl_count[bits]++;\n    xbits = 0;\n    if (n >= base) {\n      xbits = extra[n - base];\n    }\n    f = tree[n * 2]/*.Freq*/;\n    s.opt_len += f * (bits + xbits);\n    if (has_stree) {\n      s.static_len += f * (stree[n * 2 + 1]/*.Len*/ + xbits);\n    }\n  }\n  if (overflow === 0) { return; }\n\n  // Trace((stderr,\"\\nbit length overflow\\n\"));\n  /* This happens for example on obj2 and pic of the Calgary corpus */\n\n  /* Find the first bit length which could increase: */\n  do {\n    bits = max_length - 1;\n    while (s.bl_count[bits] === 0) { bits--; }\n    s.bl_count[bits]--;      /* move one leaf down the tree */\n    s.bl_count[bits + 1] += 2; /* move one overflow item as its brother */\n    s.bl_count[max_length]--;\n    /* The brother of the overflow item also moves one step up,\n     * but this does not affect bl_count[max_length]\n     */\n    overflow -= 2;\n  } while (overflow > 0);\n\n  /* Now recompute all bit lengths, scanning in increasing frequency.\n   * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all\n   * lengths instead of fixing only the wrong ones. This idea is taken\n   * from 'ar' written by Haruhiko Okumura.)\n   */\n  for (bits = max_length; bits !== 0; bits--) {\n    n = s.bl_count[bits];\n    while (n !== 0) {\n      m = s.heap[--h];\n      if (m > max_code) { continue; }\n      if (tree[m * 2 + 1]/*.Len*/ !== bits) {\n        // Trace((stderr,\"code %d bits %d->%d\\n\", m, tree[m].Len, bits));\n        s.opt_len += (bits - tree[m * 2 + 1]/*.Len*/) * tree[m * 2]/*.Freq*/;\n        tree[m * 2 + 1]/*.Len*/ = bits;\n      }\n      n--;\n    }\n  }\n}\n\n\n/* ===========================================================================\n * Generate the codes for a given tree and bit counts (which need not be\n * optimal).\n * IN assertion: the array bl_count contains the bit length statistics for\n * the given tree and the field len is set for all tree elements.\n * OUT assertion: the field code is set for all tree elements of non\n *     zero code length.\n */\nfunction gen_codes(tree, max_code, bl_count)\n//    ct_data *tree;             /* the tree to decorate */\n//    int max_code;              /* largest code with non zero frequency */\n//    ushf *bl_count;            /* number of codes at each bit length */\n{\n  var next_code = new Array(MAX_BITS + 1); /* next code value for each bit length */\n  var code = 0;              /* running code value */\n  var bits;                  /* bit index */\n  var n;                     /* code index */\n\n  /* The distribution counts are first used to generate the code values\n   * without bit reversal.\n   */\n  for (bits = 1; bits <= MAX_BITS; bits++) {\n    next_code[bits] = code = (code + bl_count[bits - 1]) << 1;\n  }\n  /* Check that the bit counts in bl_count are consistent. The last code\n   * must be all ones.\n   */\n  //Assert (code + bl_count[MAX_BITS]-1 == (1<<MAX_BITS)-1,\n  //        \"inconsistent bit counts\");\n  //Tracev((stderr,\"\\ngen_codes: max_code %d \", max_code));\n\n  for (n = 0;  n <= max_code; n++) {\n    var len = tree[n * 2 + 1]/*.Len*/;\n    if (len === 0) { continue; }\n    /* Now reverse the bits */\n    tree[n * 2]/*.Code*/ = bi_reverse(next_code[len]++, len);\n\n    //Tracecv(tree != static_ltree, (stderr,\"\\nn %3d %c l %2d c %4x (%x) \",\n    //     n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len]-1));\n  }\n}\n\n\n/* ===========================================================================\n * Initialize the various 'constant' tables.\n */\nfunction tr_static_init() {\n  var n;        /* iterates over tree elements */\n  var bits;     /* bit counter */\n  var length;   /* length value */\n  var code;     /* code value */\n  var dist;     /* distance index */\n  var bl_count = new Array(MAX_BITS + 1);\n  /* number of codes at each bit length for an optimal tree */\n\n  // do check in _tr_init()\n  //if (static_init_done) return;\n\n  /* For some embedded targets, global variables are not initialized: */\n/*#ifdef NO_INIT_GLOBAL_POINTERS\n  static_l_desc.static_tree = static_ltree;\n  static_l_desc.extra_bits = extra_lbits;\n  static_d_desc.static_tree = static_dtree;\n  static_d_desc.extra_bits = extra_dbits;\n  static_bl_desc.extra_bits = extra_blbits;\n#endif*/\n\n  /* Initialize the mapping length (0..255) -> length code (0..28) */\n  length = 0;\n  for (code = 0; code < LENGTH_CODES - 1; code++) {\n    base_length[code] = length;\n    for (n = 0; n < (1 << extra_lbits[code]); n++) {\n      _length_code[length++] = code;\n    }\n  }\n  //Assert (length == 256, \"tr_static_init: length != 256\");\n  /* Note that the length 255 (match length 258) can be represented\n   * in two different ways: code 284 + 5 bits or code 285, so we\n   * overwrite length_code[255] to use the best encoding:\n   */\n  _length_code[length - 1] = code;\n\n  /* Initialize the mapping dist (0..32K) -> dist code (0..29) */\n  dist = 0;\n  for (code = 0; code < 16; code++) {\n    base_dist[code] = dist;\n    for (n = 0; n < (1 << extra_dbits[code]); n++) {\n      _dist_code[dist++] = code;\n    }\n  }\n  //Assert (dist == 256, \"tr_static_init: dist != 256\");\n  dist >>= 7; /* from now on, all distances are divided by 128 */\n  for (; code < D_CODES; code++) {\n    base_dist[code] = dist << 7;\n    for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) {\n      _dist_code[256 + dist++] = code;\n    }\n  }\n  //Assert (dist == 256, \"tr_static_init: 256+dist != 512\");\n\n  /* Construct the codes of the static literal tree */\n  for (bits = 0; bits <= MAX_BITS; bits++) {\n    bl_count[bits] = 0;\n  }\n\n  n = 0;\n  while (n <= 143) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 8;\n    n++;\n    bl_count[8]++;\n  }\n  while (n <= 255) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 9;\n    n++;\n    bl_count[9]++;\n  }\n  while (n <= 279) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 7;\n    n++;\n    bl_count[7]++;\n  }\n  while (n <= 287) {\n    static_ltree[n * 2 + 1]/*.Len*/ = 8;\n    n++;\n    bl_count[8]++;\n  }\n  /* Codes 286 and 287 do not exist, but we must include them in the\n   * tree construction to get a canonical Huffman tree (longest code\n   * all ones)\n   */\n  gen_codes(static_ltree, L_CODES + 1, bl_count);\n\n  /* The static distance tree is trivial: */\n  for (n = 0; n < D_CODES; n++) {\n    static_dtree[n * 2 + 1]/*.Len*/ = 5;\n    static_dtree[n * 2]/*.Code*/ = bi_reverse(n, 5);\n  }\n\n  // Now data ready and we can init static trees\n  static_l_desc = new StaticTreeDesc(static_ltree, extra_lbits, LITERALS + 1, L_CODES, MAX_BITS);\n  static_d_desc = new StaticTreeDesc(static_dtree, extra_dbits, 0,          D_CODES, MAX_BITS);\n  static_bl_desc = new StaticTreeDesc(new Array(0), extra_blbits, 0,         BL_CODES, MAX_BL_BITS);\n\n  //static_init_done = true;\n}\n\n\n/* ===========================================================================\n * Initialize a new block.\n */\nfunction init_block(s) {\n  var n; /* iterates over tree elements */\n\n  /* Initialize the trees. */\n  for (n = 0; n < L_CODES;  n++) { s.dyn_ltree[n * 2]/*.Freq*/ = 0; }\n  for (n = 0; n < D_CODES;  n++) { s.dyn_dtree[n * 2]/*.Freq*/ = 0; }\n  for (n = 0; n < BL_CODES; n++) { s.bl_tree[n * 2]/*.Freq*/ = 0; }\n\n  s.dyn_ltree[END_BLOCK * 2]/*.Freq*/ = 1;\n  s.opt_len = s.static_len = 0;\n  s.last_lit = s.matches = 0;\n}\n\n\n/* ===========================================================================\n * Flush the bit buffer and align the output on a byte boundary\n */\nfunction bi_windup(s)\n{\n  if (s.bi_valid > 8) {\n    put_short(s, s.bi_buf);\n  } else if (s.bi_valid > 0) {\n    //put_byte(s, (Byte)s->bi_buf);\n    s.pending_buf[s.pending++] = s.bi_buf;\n  }\n  s.bi_buf = 0;\n  s.bi_valid = 0;\n}\n\n/* ===========================================================================\n * Copy a stored block, storing first the length and its\n * one's complement if requested.\n */\nfunction copy_block(s, buf, len, header)\n//DeflateState *s;\n//charf    *buf;    /* the input data */\n//unsigned len;     /* its length */\n//int      header;  /* true if block header must be written */\n{\n  bi_windup(s);        /* align on byte boundary */\n\n  if (header) {\n    put_short(s, len);\n    put_short(s, ~len);\n  }\n//  while (len--) {\n//    put_byte(s, *buf++);\n//  }\n  utils.arraySet(s.pending_buf, s.window, buf, len, s.pending);\n  s.pending += len;\n}\n\n/* ===========================================================================\n * Compares to subtrees, using the tree depth as tie breaker when\n * the subtrees have equal frequency. This minimizes the worst case length.\n */\nfunction smaller(tree, n, m, depth) {\n  var _n2 = n * 2;\n  var _m2 = m * 2;\n  return (tree[_n2]/*.Freq*/ < tree[_m2]/*.Freq*/ ||\n         (tree[_n2]/*.Freq*/ === tree[_m2]/*.Freq*/ && depth[n] <= depth[m]));\n}\n\n/* ===========================================================================\n * Restore the heap property by moving down the tree starting at node k,\n * exchanging a node with the smallest of its two sons if necessary, stopping\n * when the heap property is re-established (each father smaller than its\n * two sons).\n */\nfunction pqdownheap(s, tree, k)\n//    deflate_state *s;\n//    ct_data *tree;  /* the tree to restore */\n//    int k;               /* node to move down */\n{\n  var v = s.heap[k];\n  var j = k << 1;  /* left son of k */\n  while (j <= s.heap_len) {\n    /* Set j to the smallest of the two sons: */\n    if (j < s.heap_len &&\n      smaller(tree, s.heap[j + 1], s.heap[j], s.depth)) {\n      j++;\n    }\n    /* Exit if v is smaller than both sons */\n    if (smaller(tree, v, s.heap[j], s.depth)) { break; }\n\n    /* Exchange v with the smallest son */\n    s.heap[k] = s.heap[j];\n    k = j;\n\n    /* And continue down the tree, setting j to the left son of k */\n    j <<= 1;\n  }\n  s.heap[k] = v;\n}\n\n\n// inlined manually\n// var SMALLEST = 1;\n\n/* ===========================================================================\n * Send the block data compressed using the given Huffman trees\n */\nfunction compress_block(s, ltree, dtree)\n//    deflate_state *s;\n//    const ct_data *ltree; /* literal tree */\n//    const ct_data *dtree; /* distance tree */\n{\n  var dist;           /* distance of matched string */\n  var lc;             /* match length or unmatched char (if dist == 0) */\n  var lx = 0;         /* running index in l_buf */\n  var code;           /* the code to send */\n  var extra;          /* number of extra bits to send */\n\n  if (s.last_lit !== 0) {\n    do {\n      dist = (s.pending_buf[s.d_buf + lx * 2] << 8) | (s.pending_buf[s.d_buf + lx * 2 + 1]);\n      lc = s.pending_buf[s.l_buf + lx];\n      lx++;\n\n      if (dist === 0) {\n        send_code(s, lc, ltree); /* send a literal byte */\n        //Tracecv(isgraph(lc), (stderr,\" '%c' \", lc));\n      } else {\n        /* Here, lc is the match length - MIN_MATCH */\n        code = _length_code[lc];\n        send_code(s, code + LITERALS + 1, ltree); /* send the length code */\n        extra = extra_lbits[code];\n        if (extra !== 0) {\n          lc -= base_length[code];\n          send_bits(s, lc, extra);       /* send the extra length bits */\n        }\n        dist--; /* dist is now the match distance - 1 */\n        code = d_code(dist);\n        //Assert (code < D_CODES, \"bad d_code\");\n\n        send_code(s, code, dtree);       /* send the distance code */\n        extra = extra_dbits[code];\n        if (extra !== 0) {\n          dist -= base_dist[code];\n          send_bits(s, dist, extra);   /* send the extra distance bits */\n        }\n      } /* literal or match pair ? */\n\n      /* Check that the overlay between pending_buf and d_buf+l_buf is ok: */\n      //Assert((uInt)(s->pending) < s->lit_bufsize + 2*lx,\n      //       \"pendingBuf overflow\");\n\n    } while (lx < s.last_lit);\n  }\n\n  send_code(s, END_BLOCK, ltree);\n}\n\n\n/* ===========================================================================\n * Construct one Huffman tree and assigns the code bit strings and lengths.\n * Update the total bit length for the current block.\n * IN assertion: the field freq is set for all tree elements.\n * OUT assertions: the fields len and code are set to the optimal bit length\n *     and corresponding code. The length opt_len is updated; static_len is\n *     also updated if stree is not null. The field max_code is set.\n */\nfunction build_tree(s, desc)\n//    deflate_state *s;\n//    tree_desc *desc; /* the tree descriptor */\n{\n  var tree     = desc.dyn_tree;\n  var stree    = desc.stat_desc.static_tree;\n  var has_stree = desc.stat_desc.has_stree;\n  var elems    = desc.stat_desc.elems;\n  var n, m;          /* iterate over heap elements */\n  var max_code = -1; /* largest code with non zero frequency */\n  var node;          /* new node being created */\n\n  /* Construct the initial heap, with least frequent element in\n   * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1].\n   * heap[0] is not used.\n   */\n  s.heap_len = 0;\n  s.heap_max = HEAP_SIZE;\n\n  for (n = 0; n < elems; n++) {\n    if (tree[n * 2]/*.Freq*/ !== 0) {\n      s.heap[++s.heap_len] = max_code = n;\n      s.depth[n] = 0;\n\n    } else {\n      tree[n * 2 + 1]/*.Len*/ = 0;\n    }\n  }\n\n  /* The pkzip format requires that at least one distance code exists,\n   * and that at least one bit should be sent even if there is only one\n   * possible code. So to avoid special checks later on we force at least\n   * two codes of non zero frequency.\n   */\n  while (s.heap_len < 2) {\n    node = s.heap[++s.heap_len] = (max_code < 2 ? ++max_code : 0);\n    tree[node * 2]/*.Freq*/ = 1;\n    s.depth[node] = 0;\n    s.opt_len--;\n\n    if (has_stree) {\n      s.static_len -= stree[node * 2 + 1]/*.Len*/;\n    }\n    /* node is 0 or 1 so it does not have extra bits */\n  }\n  desc.max_code = max_code;\n\n  /* The elements heap[heap_len/2+1 .. heap_len] are leaves of the tree,\n   * establish sub-heaps of increasing lengths:\n   */\n  for (n = (s.heap_len >> 1/*int /2*/); n >= 1; n--) { pqdownheap(s, tree, n); }\n\n  /* Construct the Huffman tree by repeatedly combining the least two\n   * frequent nodes.\n   */\n  node = elems;              /* next internal node of the tree */\n  do {\n    //pqremove(s, tree, n);  /* n = node of least frequency */\n    /*** pqremove ***/\n    n = s.heap[1/*SMALLEST*/];\n    s.heap[1/*SMALLEST*/] = s.heap[s.heap_len--];\n    pqdownheap(s, tree, 1/*SMALLEST*/);\n    /***/\n\n    m = s.heap[1/*SMALLEST*/]; /* m = node of next least frequency */\n\n    s.heap[--s.heap_max] = n; /* keep the nodes sorted by frequency */\n    s.heap[--s.heap_max] = m;\n\n    /* Create a new node father of n and m */\n    tree[node * 2]/*.Freq*/ = tree[n * 2]/*.Freq*/ + tree[m * 2]/*.Freq*/;\n    s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;\n    tree[n * 2 + 1]/*.Dad*/ = tree[m * 2 + 1]/*.Dad*/ = node;\n\n    /* and insert the new node in the heap */\n    s.heap[1/*SMALLEST*/] = node++;\n    pqdownheap(s, tree, 1/*SMALLEST*/);\n\n  } while (s.heap_len >= 2);\n\n  s.heap[--s.heap_max] = s.heap[1/*SMALLEST*/];\n\n  /* At this point, the fields freq and dad are set. We can now\n   * generate the bit lengths.\n   */\n  gen_bitlen(s, desc);\n\n  /* The field len is now set, we can generate the bit codes */\n  gen_codes(tree, max_code, s.bl_count);\n}\n\n\n/* ===========================================================================\n * Scan a literal or distance tree to determine the frequencies of the codes\n * in the bit length tree.\n */\nfunction scan_tree(s, tree, max_code)\n//    deflate_state *s;\n//    ct_data *tree;   /* the tree to be scanned */\n//    int max_code;    /* and its largest code of non zero frequency */\n{\n  var n;                     /* iterates over all tree elements */\n  var prevlen = -1;          /* last emitted length */\n  var curlen;                /* length of current code */\n\n  var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n  var count = 0;             /* repeat count of the current code */\n  var max_count = 7;         /* max repeat count */\n  var min_count = 4;         /* min repeat count */\n\n  if (nextlen === 0) {\n    max_count = 138;\n    min_count = 3;\n  }\n  tree[(max_code + 1) * 2 + 1]/*.Len*/ = 0xffff; /* guard */\n\n  for (n = 0; n <= max_code; n++) {\n    curlen = nextlen;\n    nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n    if (++count < max_count && curlen === nextlen) {\n      continue;\n\n    } else if (count < min_count) {\n      s.bl_tree[curlen * 2]/*.Freq*/ += count;\n\n    } else if (curlen !== 0) {\n\n      if (curlen !== prevlen) { s.bl_tree[curlen * 2]/*.Freq*/++; }\n      s.bl_tree[REP_3_6 * 2]/*.Freq*/++;\n\n    } else if (count <= 10) {\n      s.bl_tree[REPZ_3_10 * 2]/*.Freq*/++;\n\n    } else {\n      s.bl_tree[REPZ_11_138 * 2]/*.Freq*/++;\n    }\n\n    count = 0;\n    prevlen = curlen;\n\n    if (nextlen === 0) {\n      max_count = 138;\n      min_count = 3;\n\n    } else if (curlen === nextlen) {\n      max_count = 6;\n      min_count = 3;\n\n    } else {\n      max_count = 7;\n      min_count = 4;\n    }\n  }\n}\n\n\n/* ===========================================================================\n * Send a literal or distance tree in compressed form, using the codes in\n * bl_tree.\n */\nfunction send_tree(s, tree, max_code)\n//    deflate_state *s;\n//    ct_data *tree; /* the tree to be scanned */\n//    int max_code;       /* and its largest code of non zero frequency */\n{\n  var n;                     /* iterates over all tree elements */\n  var prevlen = -1;          /* last emitted length */\n  var curlen;                /* length of current code */\n\n  var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */\n\n  var count = 0;             /* repeat count of the current code */\n  var max_count = 7;         /* max repeat count */\n  var min_count = 4;         /* min repeat count */\n\n  /* tree[max_code+1].Len = -1; */  /* guard already set */\n  if (nextlen === 0) {\n    max_count = 138;\n    min_count = 3;\n  }\n\n  for (n = 0; n <= max_code; n++) {\n    curlen = nextlen;\n    nextlen = tree[(n + 1) * 2 + 1]/*.Len*/;\n\n    if (++count < max_count && curlen === nextlen) {\n      continue;\n\n    } else if (count < min_count) {\n      do { send_code(s, curlen, s.bl_tree); } while (--count !== 0);\n\n    } else if (curlen !== 0) {\n      if (curlen !== prevlen) {\n        send_code(s, curlen, s.bl_tree);\n        count--;\n      }\n      //Assert(count >= 3 && count <= 6, \" 3_6?\");\n      send_code(s, REP_3_6, s.bl_tree);\n      send_bits(s, count - 3, 2);\n\n    } else if (count <= 10) {\n      send_code(s, REPZ_3_10, s.bl_tree);\n      send_bits(s, count - 3, 3);\n\n    } else {\n      send_code(s, REPZ_11_138, s.bl_tree);\n      send_bits(s, count - 11, 7);\n    }\n\n    count = 0;\n    prevlen = curlen;\n    if (nextlen === 0) {\n      max_count = 138;\n      min_count = 3;\n\n    } else if (curlen === nextlen) {\n      max_count = 6;\n      min_count = 3;\n\n    } else {\n      max_count = 7;\n      min_count = 4;\n    }\n  }\n}\n\n\n/* ===========================================================================\n * Construct the Huffman tree for the bit lengths and return the index in\n * bl_order of the last bit length code to send.\n */\nfunction build_bl_tree(s) {\n  var max_blindex;  /* index of last bit length code of non zero freq */\n\n  /* Determine the bit length frequencies for literal and distance trees */\n  scan_tree(s, s.dyn_ltree, s.l_desc.max_code);\n  scan_tree(s, s.dyn_dtree, s.d_desc.max_code);\n\n  /* Build the bit length tree: */\n  build_tree(s, s.bl_desc);\n  /* opt_len now includes the length of the tree representations, except\n   * the lengths of the bit lengths codes and the 5+5+4 bits for the counts.\n   */\n\n  /* Determine the number of bit length codes to send. The pkzip format\n   * requires that at least 4 bit length codes be sent. (appnote.txt says\n   * 3 but the actual value used is 4.)\n   */\n  for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) {\n    if (s.bl_tree[bl_order[max_blindex] * 2 + 1]/*.Len*/ !== 0) {\n      break;\n    }\n  }\n  /* Update opt_len to include the bit length tree and counts */\n  s.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;\n  //Tracev((stderr, \"\\ndyn trees: dyn %ld, stat %ld\",\n  //        s->opt_len, s->static_len));\n\n  return max_blindex;\n}\n\n\n/* ===========================================================================\n * Send the header for a block using dynamic Huffman trees: the counts, the\n * lengths of the bit length codes, the literal tree and the distance tree.\n * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.\n */\nfunction send_all_trees(s, lcodes, dcodes, blcodes)\n//    deflate_state *s;\n//    int lcodes, dcodes, blcodes; /* number of codes for each tree */\n{\n  var rank;                    /* index in bl_order */\n\n  //Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, \"not enough codes\");\n  //Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,\n  //        \"too many codes\");\n  //Tracev((stderr, \"\\nbl counts: \"));\n  send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */\n  send_bits(s, dcodes - 1,   5);\n  send_bits(s, blcodes - 4,  4); /* not -3 as stated in appnote.txt */\n  for (rank = 0; rank < blcodes; rank++) {\n    //Tracev((stderr, \"\\nbl code %2d \", bl_order[rank]));\n    send_bits(s, s.bl_tree[bl_order[rank] * 2 + 1]/*.Len*/, 3);\n  }\n  //Tracev((stderr, \"\\nbl tree: sent %ld\", s->bits_sent));\n\n  send_tree(s, s.dyn_ltree, lcodes - 1); /* literal tree */\n  //Tracev((stderr, \"\\nlit tree: sent %ld\", s->bits_sent));\n\n  send_tree(s, s.dyn_dtree, dcodes - 1); /* distance tree */\n  //Tracev((stderr, \"\\ndist tree: sent %ld\", s->bits_sent));\n}\n\n\n/* ===========================================================================\n * Check if the data type is TEXT or BINARY, using the following algorithm:\n * - TEXT if the two conditions below are satisfied:\n *    a) There are no non-portable control characters belonging to the\n *       \"black list\" (0..6, 14..25, 28..31).\n *    b) There is at least one printable character belonging to the\n *       \"white list\" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).\n * - BINARY otherwise.\n * - The following partially-portable control characters form a\n *   \"gray list\" that is ignored in this detection algorithm:\n *   (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).\n * IN assertion: the fields Freq of dyn_ltree are set.\n */\nfunction detect_data_type(s) {\n  /* black_mask is the bit mask of black-listed bytes\n   * set bits 0..6, 14..25, and 28..31\n   * 0xf3ffc07f = binary 11110011111111111100000001111111\n   */\n  var black_mask = 0xf3ffc07f;\n  var n;\n\n  /* Check for non-textual (\"black-listed\") bytes. */\n  for (n = 0; n <= 31; n++, black_mask >>>= 1) {\n    if ((black_mask & 1) && (s.dyn_ltree[n * 2]/*.Freq*/ !== 0)) {\n      return Z_BINARY;\n    }\n  }\n\n  /* Check for textual (\"white-listed\") bytes. */\n  if (s.dyn_ltree[9 * 2]/*.Freq*/ !== 0 || s.dyn_ltree[10 * 2]/*.Freq*/ !== 0 ||\n      s.dyn_ltree[13 * 2]/*.Freq*/ !== 0) {\n    return Z_TEXT;\n  }\n  for (n = 32; n < LITERALS; n++) {\n    if (s.dyn_ltree[n * 2]/*.Freq*/ !== 0) {\n      return Z_TEXT;\n    }\n  }\n\n  /* There are no \"black-listed\" or \"white-listed\" bytes:\n   * this stream either is empty or has tolerated (\"gray-listed\") bytes only.\n   */\n  return Z_BINARY;\n}\n\n\nvar static_init_done = false;\n\n/* ===========================================================================\n * Initialize the tree data structures for a new zlib stream.\n */\nfunction _tr_init(s)\n{\n\n  if (!static_init_done) {\n    tr_static_init();\n    static_init_done = true;\n  }\n\n  s.l_desc  = new TreeDesc(s.dyn_ltree, static_l_desc);\n  s.d_desc  = new TreeDesc(s.dyn_dtree, static_d_desc);\n  s.bl_desc = new TreeDesc(s.bl_tree, static_bl_desc);\n\n  s.bi_buf = 0;\n  s.bi_valid = 0;\n\n  /* Initialize the first block of the first file: */\n  init_block(s);\n}\n\n\n/* ===========================================================================\n * Send a stored block\n */\nfunction _tr_stored_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf;       /* input block */\n//ulg stored_len;   /* length of input block */\n//int last;         /* one if this is the last block for a file */\n{\n  send_bits(s, (STORED_BLOCK << 1) + (last ? 1 : 0), 3);    /* send block type */\n  copy_block(s, buf, stored_len, true); /* with header */\n}\n\n\n/* ===========================================================================\n * Send one empty static block to give enough lookahead for inflate.\n * This takes 10 bits, of which 7 may remain in the bit buffer.\n */\nfunction _tr_align(s) {\n  send_bits(s, STATIC_TREES << 1, 3);\n  send_code(s, END_BLOCK, static_ltree);\n  bi_flush(s);\n}\n\n\n/* ===========================================================================\n * Determine the best encoding for the current block: dynamic trees, static\n * trees or store, and output the encoded block to the zip file.\n */\nfunction _tr_flush_block(s, buf, stored_len, last)\n//DeflateState *s;\n//charf *buf;       /* input block, or NULL if too old */\n//ulg stored_len;   /* length of input block */\n//int last;         /* one if this is the last block for a file */\n{\n  var opt_lenb, static_lenb;  /* opt_len and static_len in bytes */\n  var max_blindex = 0;        /* index of last bit length code of non zero freq */\n\n  /* Build the Huffman trees unless a stored block is forced */\n  if (s.level > 0) {\n\n    /* Check if the file is binary or text */\n    if (s.strm.data_type === Z_UNKNOWN) {\n      s.strm.data_type = detect_data_type(s);\n    }\n\n    /* Construct the literal and distance trees */\n    build_tree(s, s.l_desc);\n    // Tracev((stderr, \"\\nlit data: dyn %ld, stat %ld\", s->opt_len,\n    //        s->static_len));\n\n    build_tree(s, s.d_desc);\n    // Tracev((stderr, \"\\ndist data: dyn %ld, stat %ld\", s->opt_len,\n    //        s->static_len));\n    /* At this point, opt_len and static_len are the total bit lengths of\n     * the compressed block data, excluding the tree representations.\n     */\n\n    /* Build the bit length tree for the above two trees, and get the index\n     * in bl_order of the last bit length code to send.\n     */\n    max_blindex = build_bl_tree(s);\n\n    /* Determine the best encoding. Compute the block lengths in bytes. */\n    opt_lenb = (s.opt_len + 3 + 7) >>> 3;\n    static_lenb = (s.static_len + 3 + 7) >>> 3;\n\n    // Tracev((stderr, \"\\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u \",\n    //        opt_lenb, s->opt_len, static_lenb, s->static_len, stored_len,\n    //        s->last_lit));\n\n    if (static_lenb <= opt_lenb) { opt_lenb = static_lenb; }\n\n  } else {\n    // Assert(buf != (char*)0, \"lost buf\");\n    opt_lenb = static_lenb = stored_len + 5; /* force a stored block */\n  }\n\n  if ((stored_len + 4 <= opt_lenb) && (buf !== -1)) {\n    /* 4: two words for the lengths */\n\n    /* The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE.\n     * Otherwise we can't have processed more than WSIZE input bytes since\n     * the last block flush, because compression would have been\n     * successful. If LIT_BUFSIZE <= WSIZE, it is never too late to\n     * transform a block into a stored block.\n     */\n    _tr_stored_block(s, buf, stored_len, last);\n\n  } else if (s.strategy === Z_FIXED || static_lenb === opt_lenb) {\n\n    send_bits(s, (STATIC_TREES << 1) + (last ? 1 : 0), 3);\n    compress_block(s, static_ltree, static_dtree);\n\n  } else {\n    send_bits(s, (DYN_TREES << 1) + (last ? 1 : 0), 3);\n    send_all_trees(s, s.l_desc.max_code + 1, s.d_desc.max_code + 1, max_blindex + 1);\n    compress_block(s, s.dyn_ltree, s.dyn_dtree);\n  }\n  // Assert (s->compressed_len == s->bits_sent, \"bad compressed size\");\n  /* The above check is made mod 2^32, for files larger than 512 MB\n   * and uLong implemented on 32 bits.\n   */\n  init_block(s);\n\n  if (last) {\n    bi_windup(s);\n  }\n  // Tracev((stderr,\"\\ncomprlen %lu(%lu) \", s->compressed_len>>3,\n  //       s->compressed_len-7*last));\n}\n\n/* ===========================================================================\n * Save the match info and tally the frequency counts. Return true if\n * the current block must be flushed.\n */\nfunction _tr_tally(s, dist, lc)\n//    deflate_state *s;\n//    unsigned dist;  /* distance of matched string */\n//    unsigned lc;    /* match length-MIN_MATCH or unmatched char (if dist==0) */\n{\n  //var out_length, in_length, dcode;\n\n  s.pending_buf[s.d_buf + s.last_lit * 2]     = (dist >>> 8) & 0xff;\n  s.pending_buf[s.d_buf + s.last_lit * 2 + 1] = dist & 0xff;\n\n  s.pending_buf[s.l_buf + s.last_lit] = lc & 0xff;\n  s.last_lit++;\n\n  if (dist === 0) {\n    /* lc is the unmatched char */\n    s.dyn_ltree[lc * 2]/*.Freq*/++;\n  } else {\n    s.matches++;\n    /* Here, lc is the match length - MIN_MATCH */\n    dist--;             /* dist = match distance - 1 */\n    //Assert((ush)dist < (ush)MAX_DIST(s) &&\n    //       (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) &&\n    //       (ush)d_code(dist) < (ush)D_CODES,  \"_tr_tally: bad match\");\n\n    s.dyn_ltree[(_length_code[lc] + LITERALS + 1) * 2]/*.Freq*/++;\n    s.dyn_dtree[d_code(dist) * 2]/*.Freq*/++;\n  }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n\n//#ifdef TRUNCATE_BLOCK\n//  /* Try to guess if it is profitable to stop the current block here */\n//  if ((s.last_lit & 0x1fff) === 0 && s.level > 2) {\n//    /* Compute an upper bound for the compressed length */\n//    out_length = s.last_lit*8;\n//    in_length = s.strstart - s.block_start;\n//\n//    for (dcode = 0; dcode < D_CODES; dcode++) {\n//      out_length += s.dyn_dtree[dcode*2]/*.Freq*/ * (5 + extra_dbits[dcode]);\n//    }\n//    out_length >>>= 3;\n//    //Tracev((stderr,\"\\nlast_lit %u, in %ld, out ~%ld(%ld%%) \",\n//    //       s->last_lit, in_length, out_length,\n//    //       100L - out_length*100L/in_length));\n//    if (s.matches < (s.last_lit>>1)/*int /2*/ && out_length < (in_length>>1)/*int /2*/) {\n//      return true;\n//    }\n//  }\n//#endif\n\n  return (s.last_lit === s.lit_bufsize - 1);\n  /* We avoid equality with lit_bufsize because of wraparound at 64K\n   * on 16 bit machines and because stored blocks are restricted to\n   * 64K-1 bytes.\n   */\n}\n\nexports._tr_init  = _tr_init;\nexports._tr_stored_block = _tr_stored_block;\nexports._tr_flush_block  = _tr_flush_block;\nexports._tr_tally = _tr_tally;\nexports._tr_align = _tr_align;\n\n},{\"../utils/common\":41}],53:[function(require,module,exports){\n'use strict';\n\n// (C) 1995-2013 Jean-loup Gailly and Mark Adler\n// (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin\n//\n// This software is provided 'as-is', without any express or implied\n// warranty. In no event will the authors be held liable for any damages\n// arising from the use of this software.\n//\n// Permission is granted to anyone to use this software for any purpose,\n// including commercial applications, and to alter it and redistribute it\n// freely, subject to the following restrictions:\n//\n// 1. The origin of this software must not be misrepresented; you must not\n//   claim that you wrote the original software. If you use this software\n//   in a product, an acknowledgment in the product documentation would be\n//   appreciated but is not required.\n// 2. Altered source versions must be plainly marked as such, and must not be\n//   misrepresented as being the original software.\n// 3. This notice may not be removed or altered from any source distribution.\n\nfunction ZStream() {\n  /* next input byte */\n  this.input = null; // JS specific, because we have no pointers\n  this.next_in = 0;\n  /* number of bytes available at input */\n  this.avail_in = 0;\n  /* total number of input bytes read so far */\n  this.total_in = 0;\n  /* next output byte should be put there */\n  this.output = null; // JS specific, because we have no pointers\n  this.next_out = 0;\n  /* remaining free space at output */\n  this.avail_out = 0;\n  /* total number of bytes output so far */\n  this.total_out = 0;\n  /* last error message, NULL if no error */\n  this.msg = ''/*Z_NULL*/;\n  /* not visible by applications */\n  this.state = null;\n  /* best guess about the data type: binary or text */\n  this.data_type = 2/*Z_UNKNOWN*/;\n  /* adler32 value of the uncompressed data */\n  this.adler = 0;\n}\n\nmodule.exports = ZStream;\n\n},{}],54:[function(require,module,exports){\n(function (global){\n(function (global, undefined) {\n    \"use strict\";\n\n    if (global.setImmediate) {\n        return;\n    }\n\n    var nextHandle = 1; // Spec says greater than zero\n    var tasksByHandle = {};\n    var currentlyRunningATask = false;\n    var doc = global.document;\n    var registerImmediate;\n\n    function setImmediate(callback) {\n      // Callback can either be a function or a string\n      if (typeof callback !== \"function\") {\n        callback = new Function(\"\" + callback);\n      }\n      // Copy function arguments\n      var args = new Array(arguments.length - 1);\n      for (var i = 0; i < args.length; i++) {\n          args[i] = arguments[i + 1];\n      }\n      // Store and register the task\n      var task = { callback: callback, args: args };\n      tasksByHandle[nextHandle] = task;\n      registerImmediate(nextHandle);\n      return nextHandle++;\n    }\n\n    function clearImmediate(handle) {\n        delete tasksByHandle[handle];\n    }\n\n    function run(task) {\n        var callback = task.callback;\n        var args = task.args;\n        switch (args.length) {\n        case 0:\n            callback();\n            break;\n        case 1:\n            callback(args[0]);\n            break;\n        case 2:\n            callback(args[0], args[1]);\n            break;\n        case 3:\n            callback(args[0], args[1], args[2]);\n            break;\n        default:\n            callback.apply(undefined, args);\n            break;\n        }\n    }\n\n    function runIfPresent(handle) {\n        // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n        // So if we're currently running a task, we'll need to delay this invocation.\n        if (currentlyRunningATask) {\n            // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n            // \"too much recursion\" error.\n            setTimeout(runIfPresent, 0, handle);\n        } else {\n            var task = tasksByHandle[handle];\n            if (task) {\n                currentlyRunningATask = true;\n                try {\n                    run(task);\n                } finally {\n                    clearImmediate(handle);\n                    currentlyRunningATask = false;\n                }\n            }\n        }\n    }\n\n    function installNextTickImplementation() {\n        registerImmediate = function(handle) {\n            process.nextTick(function () { runIfPresent(handle); });\n        };\n    }\n\n    function canUsePostMessage() {\n        // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n        // where `global.postMessage` means something completely different and can't be used for this purpose.\n        if (global.postMessage && !global.importScripts) {\n            var postMessageIsAsynchronous = true;\n            var oldOnMessage = global.onmessage;\n            global.onmessage = function() {\n                postMessageIsAsynchronous = false;\n            };\n            global.postMessage(\"\", \"*\");\n            global.onmessage = oldOnMessage;\n            return postMessageIsAsynchronous;\n        }\n    }\n\n    function installPostMessageImplementation() {\n        // Installs an event handler on `global` for the `message` event: see\n        // * https://developer.mozilla.org/en/DOM/window.postMessage\n        // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n        var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n        var onGlobalMessage = function(event) {\n            if (event.source === global &&\n                typeof event.data === \"string\" &&\n                event.data.indexOf(messagePrefix) === 0) {\n                runIfPresent(+event.data.slice(messagePrefix.length));\n            }\n        };\n\n        if (global.addEventListener) {\n            global.addEventListener(\"message\", onGlobalMessage, false);\n        } else {\n            global.attachEvent(\"onmessage\", onGlobalMessage);\n        }\n\n        registerImmediate = function(handle) {\n            global.postMessage(messagePrefix + handle, \"*\");\n        };\n    }\n\n    function installMessageChannelImplementation() {\n        var channel = new MessageChannel();\n        channel.port1.onmessage = function(event) {\n            var handle = event.data;\n            runIfPresent(handle);\n        };\n\n        registerImmediate = function(handle) {\n            channel.port2.postMessage(handle);\n        };\n    }\n\n    function installReadyStateChangeImplementation() {\n        var html = doc.documentElement;\n        registerImmediate = function(handle) {\n            // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n            // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n            var script = doc.createElement(\"script\");\n            script.onreadystatechange = function () {\n                runIfPresent(handle);\n                script.onreadystatechange = null;\n                html.removeChild(script);\n                script = null;\n            };\n            html.appendChild(script);\n        };\n    }\n\n    function installSetTimeoutImplementation() {\n        registerImmediate = function(handle) {\n            setTimeout(runIfPresent, 0, handle);\n        };\n    }\n\n    // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.\n    var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);\n    attachTo = attachTo && attachTo.setTimeout ? attachTo : global;\n\n    // Don't get fooled by e.g. browserify environments.\n    if ({}.toString.call(global.process) === \"[object process]\") {\n        // For Node.js before 0.9\n        installNextTickImplementation();\n\n    } else if (canUsePostMessage()) {\n        // For non-IE10 modern browsers\n        installPostMessageImplementation();\n\n    } else if (global.MessageChannel) {\n        // For web workers, where supported\n        installMessageChannelImplementation();\n\n    } else if (doc && \"onreadystatechange\" in doc.createElement(\"script\")) {\n        // For IE 6–8\n        installReadyStateChangeImplementation();\n\n    } else {\n        // For older browsers\n        installSetTimeoutImplementation();\n    }\n\n    attachTo.setImmediate = setImmediate;\n    attachTo.clearImmediate = clearImmediate;\n}(typeof self === \"undefined\" ? typeof global === \"undefined\" ? this : global : self));\n\n}).call(this,typeof global !== \"undefined\" ? global : typeof self !== \"undefined\" ? self : typeof window !== \"undefined\" ? window : {})\n},{}]},{},[10])(10)\n});"
  },
  {
    "path": "docs/APPNOTE.TXT",
    "content": "File:    APPNOTE.TXT - .ZIP File Format Specification\r\nVersion: 6.3.2 \r\nRevised: September 28, 2007\r\nCopyright (c) 1989 - 2007 PKWARE Inc., All Rights Reserved.\r\n\r\nThe use of certain technological aspects disclosed in the current\r\nAPPNOTE is available pursuant to the below section entitled\r\n\"Incorporating PKWARE Proprietary Technology into Your Product\".\r\n\r\nI. Purpose\r\n----------\r\n\r\nThis specification is intended to define a cross-platform,\r\ninteroperable file storage and transfer format.  Since its \r\nfirst publication in 1989, PKWARE has remained committed to \r\nensuring the interoperability of the .ZIP file format through \r\npublication and maintenance of this specification.  We trust that \r\nall .ZIP compatible vendors and application developers that have \r\nadopted and benefited from this format will share and support \r\nthis commitment to interoperability.\r\n\r\nII. Contacting PKWARE\r\n---------------------\r\n\r\n     PKWARE, Inc.\r\n     648 N. Plankinton Avenue, Suite 220\r\n     Milwaukee, WI 53203\r\n     +1-414-289-9788\r\n     +1-414-289-9789 FAX\r\n     zipformat@pkware.com\r\n\r\nIII. Disclaimer\r\n---------------\r\n\r\nAlthough PKWARE will attempt to supply current and accurate\r\ninformation relating to its file formats, algorithms, and the\r\nsubject programs, the possibility of error or omission cannot \r\nbe eliminated. PKWARE therefore expressly disclaims any warranty \r\nthat the information contained in the associated materials relating \r\nto the subject programs and/or the format of the files created or\r\naccessed by the subject programs and/or the algorithms used by\r\nthe subject programs, or any other matter, is current, correct or\r\naccurate as delivered.  Any risk of damage due to any possible\r\ninaccurate information is assumed by the user of the information.\r\nFurthermore, the information relating to the subject programs\r\nand/or the file formats created or accessed by the subject\r\nprograms and/or the algorithms used by the subject programs is\r\nsubject to change without notice.\r\n\r\nIf the version of this file is marked as a NOTIFICATION OF CHANGE,\r\nthe content defines an Early Feature Specification (EFS) change \r\nto the .ZIP file format that may be subject to modification prior \r\nto publication of the Final Feature Specification (FFS).  This\r\ndocument may also contain information on Planned Feature \r\nSpecifications (PFS) defining recognized future extensions.\r\n\r\nIV. Change Log\r\n--------------\r\n\r\nVersion       Change Description                        Date\r\n-------       ------------------                       ----------\r\n5.2           -Single Password Symmetric Encryption    06/02/2003\r\n               storage\r\n\r\n6.1.0         -Smartcard compatibility                 01/20/2004\r\n              -Documentation on certificate storage\r\n\r\n6.2.0         -Introduction of Central Directory       04/26/2004\r\n               Encryption for encrypting metadata\r\n              -Added OS/X to Version Made By values\r\n\r\n6.2.1         -Added Extra Field placeholder for       04/01/2005\r\n               POSZIP using ID 0x4690\r\n\r\n              -Clarified size field on \r\n               \"zip64 end of central directory record\"\r\n\r\n6.2.2         -Documented Final Feature Specification  01/06/2006\r\n               for Strong Encryption\r\n\r\n              -Clarifications and typographical \r\n               corrections\r\n\r\n6.3.0         -Added tape positioning storage          09/29/2006\r\n               parameters\r\n\r\n              -Expanded list of supported hash algorithms\r\n\r\n              -Expanded list of supported compression\r\n               algorithms\r\n\r\n              -Expanded list of supported encryption\r\n               algorithms\r\n\r\n              -Added option for Unicode filename \r\n               storage\r\n\r\n              -Clarifications for consistent use\r\n               of Data Descriptor records\r\n\r\n              -Added additional \"Extra Field\" \r\n               definitions\r\n\r\n6.3.1         -Corrected standard hash values for      04/11/2007\r\n               SHA-256/384/512\r\n\r\n6.3.2         -Added compression method 97             09/28/2007\r\n\r\n              -Documented InfoZIP \"Extra Field\"\r\n               values for UTF-8 file name and\r\n               file comment storage\r\n\r\nV. General Format of a .ZIP file\r\n--------------------------------\r\n\r\n  Files stored in arbitrary order.  Large .ZIP files can span multiple\r\n  volumes or be split into user-defined segment sizes. All values\r\n  are stored in little-endian byte order unless otherwise specified. \r\n\r\n  Overall .ZIP file format:\r\n\r\n    [local file header 1]\r\n    [file data 1]\r\n    [data descriptor 1]\r\n    . \r\n    .\r\n    .\r\n    [local file header n]\r\n    [file data n]\r\n    [data descriptor n]\r\n    [archive decryption header] \r\n    [archive extra data record] \r\n    [central directory]\r\n    [zip64 end of central directory record]\r\n    [zip64 end of central directory locator] \r\n    [end of central directory record]\r\n\r\n\r\n  A.  Local file header:\r\n\r\n        local file header signature     4 bytes  (0x04034b50)\r\n        version needed to extract       2 bytes\r\n        general purpose bit flag        2 bytes\r\n        compression method              2 bytes\r\n        last mod file time              2 bytes\r\n        last mod file date              2 bytes\r\n        crc-32                          4 bytes\r\n        compressed size                 4 bytes\r\n        uncompressed size               4 bytes\r\n        file name length                2 bytes\r\n        extra field length              2 bytes\r\n\r\n        file name (variable size)\r\n        extra field (variable size)\r\n\r\n  B.  File data\r\n\r\n      Immediately following the local header for a file\r\n      is the compressed or stored data for the file. \r\n      The series of [local file header][file data][data\r\n      descriptor] repeats for each file in the .ZIP archive. \r\n\r\n  C.  Data descriptor:\r\n\r\n        crc-32                          4 bytes\r\n        compressed size                 4 bytes\r\n        uncompressed size               4 bytes\r\n\r\n      This descriptor exists only if bit 3 of the general\r\n      purpose bit flag is set (see below).  It is byte aligned\r\n      and immediately follows the last byte of compressed data.\r\n      This descriptor is used only when it was not possible to\r\n      seek in the output .ZIP file, e.g., when the output .ZIP file\r\n      was standard output or a non-seekable device.  For ZIP64(tm) format\r\n      archives, the compressed and uncompressed sizes are 8 bytes each.\r\n\r\n      When compressing files, compressed and uncompressed sizes \r\n      should be stored in ZIP64 format (as 8 byte values) when a \r\n      files size exceeds 0xFFFFFFFF.   However ZIP64 format may be \r\n      used regardless of the size of a file.  When extracting, if \r\n      the zip64 extended information extra field is present for \r\n      the file the compressed and uncompressed sizes will be 8\r\n      byte values.  \r\n\r\n      Although not originally assigned a signature, the value \r\n      0x08074b50 has commonly been adopted as a signature value \r\n      for the data descriptor record.  Implementers should be \r\n      aware that ZIP files may be encountered with or without this \r\n      signature marking data descriptors and should account for\r\n      either case when reading ZIP files to ensure compatibility.\r\n      When writing ZIP files, it is recommended to include the\r\n      signature value marking the data descriptor record.  When\r\n      the signature is used, the fields currently defined for\r\n      the data descriptor record will immediately follow the\r\n      signature.\r\n\r\n      An extensible data descriptor will be released in a future\r\n      version of this APPNOTE.  This new record is intended to\r\n      resolve conflicts with the use of this record going forward,\r\n      and to provide better support for streamed file processing.\r\n\r\n      When the Central Directory Encryption method is used, the data\r\n      descriptor record is not required, but may be used.  If present,\r\n      and bit 3 of the general purpose bit field is set to indicate\r\n      its presence, the values in fields of the data descriptor\r\n      record should be set to binary zeros.\r\n\r\n  D.  Archive decryption header:  \r\n\r\n      The Archive Decryption Header is introduced in version 6.2\r\n      of the ZIP format specification.  This record exists in support\r\n      of the Central Directory Encryption Feature implemented as part of \r\n      the Strong Encryption Specification as described in this document.\r\n      When the Central Directory Structure is encrypted, this decryption\r\n      header will precede the encrypted data segment.  The encrypted\r\n      data segment will consist of the Archive extra data record (if\r\n      present) and the encrypted Central Directory Structure data.\r\n      The format of this data record is identical to the Decryption\r\n      header record preceding compressed file data.  If the central \r\n      directory structure is encrypted, the location of the start of\r\n      this data record is determined using the Start of Central Directory\r\n      field in the Zip64 End of Central Directory record.  Refer to the \r\n      section on the Strong Encryption Specification for information\r\n      on the fields used in the Archive Decryption Header record.\r\n\r\n\r\n  E.  Archive extra data record: \r\n\r\n        archive extra data signature    4 bytes  (0x08064b50)\r\n        extra field length              4 bytes\r\n        extra field data                (variable size)\r\n\r\n      The Archive Extra Data Record is introduced in version 6.2\r\n      of the ZIP format specification.  This record exists in support\r\n      of the Central Directory Encryption Feature implemented as part of \r\n      the Strong Encryption Specification as described in this document.\r\n      When present, this record immediately precedes the central \r\n      directory data structure.  The size of this data record will be\r\n      included in the Size of the Central Directory field in the\r\n      End of Central Directory record.  If the central directory structure\r\n      is compressed, but not encrypted, the location of the start of\r\n      this data record is determined using the Start of Central Directory\r\n      field in the Zip64 End of Central Directory record.  \r\n\r\n\r\n  F.  Central directory structure:\r\n\r\n      [file header 1]\r\n      .\r\n      .\r\n      . \r\n      [file header n]\r\n      [digital signature] \r\n\r\n      File header:\r\n\r\n        central file header signature   4 bytes  (0x02014b50)\r\n        version made by                 2 bytes\r\n        version needed to extract       2 bytes\r\n        general purpose bit flag        2 bytes\r\n        compression method              2 bytes\r\n        last mod file time              2 bytes\r\n        last mod file date              2 bytes\r\n        crc-32                          4 bytes\r\n        compressed size                 4 bytes\r\n        uncompressed size               4 bytes\r\n        file name length                2 bytes\r\n        extra field length              2 bytes\r\n        file comment length             2 bytes\r\n        disk number start               2 bytes\r\n        internal file attributes        2 bytes\r\n        external file attributes        4 bytes\r\n        relative offset of local header 4 bytes\r\n\r\n        file name (variable size)\r\n        extra field (variable size)\r\n        file comment (variable size)\r\n\r\n      Digital signature:\r\n\r\n        header signature                4 bytes  (0x05054b50)\r\n        size of data                    2 bytes\r\n        signature data (variable size)\r\n\r\n      With the introduction of the Central Directory Encryption \r\n      feature in version 6.2 of this specification, the Central \r\n      Directory Structure may be stored both compressed and encrypted. \r\n      Although not required, it is assumed when encrypting the\r\n      Central Directory Structure, that it will be compressed\r\n      for greater storage efficiency.  Information on the\r\n      Central Directory Encryption feature can be found in the section\r\n      describing the Strong Encryption Specification. The Digital \r\n      Signature record will be neither compressed nor encrypted.\r\n\r\n  G.  Zip64 end of central directory record\r\n\r\n        zip64 end of central dir \r\n        signature                       4 bytes  (0x06064b50)\r\n        size of zip64 end of central\r\n        directory record                8 bytes\r\n        version made by                 2 bytes\r\n        version needed to extract       2 bytes\r\n        number of this disk             4 bytes\r\n        number of the disk with the \r\n        start of the central directory  4 bytes\r\n        total number of entries in the\r\n        central directory on this disk  8 bytes\r\n        total number of entries in the\r\n        central directory               8 bytes\r\n        size of the central directory   8 bytes\r\n        offset of start of central\r\n        directory with respect to\r\n        the starting disk number        8 bytes\r\n        zip64 extensible data sector    (variable size)\r\n\r\n        The value stored into the \"size of zip64 end of central\r\n        directory record\" should be the size of the remaining\r\n        record and should not include the leading 12 bytes.\r\n  \r\n        Size = SizeOfFixedFields + SizeOfVariableData - 12.\r\n\r\n        The above record structure defines Version 1 of the \r\n        zip64 end of central directory record. Version 1 was \r\n        implemented in versions of this specification preceding \r\n        6.2 in support of the ZIP64 large file feature. The \r\n        introduction of the Central Directory Encryption feature \r\n        implemented in version 6.2 as part of the Strong Encryption \r\n        Specification defines Version 2 of this record structure. \r\n        Refer to the section describing the Strong Encryption \r\n        Specification for details on the version 2 format for \r\n        this record.\r\n\r\n        Special purpose data may reside in the zip64 extensible data\r\n        sector field following either a V1 or V2 version of this\r\n        record.  To ensure identification of this special purpose data\r\n        it must include an identifying header block consisting of the\r\n        following:\r\n\r\n           Header ID  -  2 bytes\r\n           Data Size  -  4 bytes\r\n\r\n        The Header ID field indicates the type of data that is in the \r\n        data block that follows.\r\n\r\n        Data Size identifies the number of bytes that follow for this\r\n        data block type.\r\n\r\n        Multiple special purpose data blocks may be present, but each\r\n        must be preceded by a Header ID and Data Size field.  Current\r\n        mappings of Header ID values supported in this field are as\r\n        defined in APPENDIX C.\r\n\r\n  H.  Zip64 end of central directory locator\r\n\r\n        zip64 end of central dir locator \r\n        signature                       4 bytes  (0x07064b50)\r\n        number of the disk with the\r\n        start of the zip64 end of \r\n        central directory               4 bytes\r\n        relative offset of the zip64\r\n        end of central directory record 8 bytes\r\n        total number of disks           4 bytes\r\n        \r\n  I.  End of central directory record:\r\n\r\n        end of central dir signature    4 bytes  (0x06054b50)\r\n        number of this disk             2 bytes\r\n        number of the disk with the\r\n        start of the central directory  2 bytes\r\n        total number of entries in the\r\n        central directory on this disk  2 bytes\r\n        total number of entries in\r\n        the central directory           2 bytes\r\n        size of the central directory   4 bytes\r\n        offset of start of central\r\n        directory with respect to\r\n        the starting disk number        4 bytes\r\n        .ZIP file comment length        2 bytes\r\n        .ZIP file comment       (variable size)\r\n\r\n  J.  Explanation of fields:\r\n\r\n      version made by (2 bytes)\r\n\r\n          The upper byte indicates the compatibility of the file\r\n          attribute information.  If the external file attributes \r\n          are compatible with MS-DOS and can be read by PKZIP for \r\n          DOS version 2.04g then this value will be zero.  If these \r\n          attributes are not compatible, then this value will \r\n          identify the host system on which the attributes are \r\n          compatible.  Software can use this information to determine\r\n          the line record format for text files etc.  The current\r\n          mappings are:\r\n\r\n          0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems)\r\n          1 - Amiga                     2 - OpenVMS\r\n          3 - UNIX                      4 - VM/CMS\r\n          5 - Atari ST                  6 - OS/2 H.P.F.S.\r\n          7 - Macintosh                 8 - Z-System\r\n          9 - CP/M                     10 - Windows NTFS\r\n         11 - MVS (OS/390 - Z/OS)      12 - VSE\r\n         13 - Acorn Risc               14 - VFAT\r\n         15 - alternate MVS            16 - BeOS\r\n         17 - Tandem                   18 - OS/400\r\n         19 - OS/X (Darwin)            20 thru 255 - unused\r\n\r\n          The lower byte indicates the ZIP specification version \r\n          (the version of this document) supported by the software \r\n          used to encode the file.  The value/10 indicates the major \r\n          version number, and the value mod 10 is the minor version \r\n          number.  \r\n\r\n      version needed to extract (2 bytes)\r\n\r\n          The minimum supported ZIP specification version needed to \r\n          extract the file, mapped as above.  This value is based on \r\n          the specific format features a ZIP program must support to \r\n          be able to extract the file.  If multiple features are\r\n          applied to a file, the minimum version should be set to the \r\n          feature having the highest value. New features or feature \r\n          changes affecting the published format specification will be \r\n          implemented using higher version numbers than the last \r\n          published value to avoid conflict.\r\n\r\n          Current minimum feature versions are as defined below:\r\n\r\n          1.0 - Default value\r\n          1.1 - File is a volume label\r\n          2.0 - File is a folder (directory)\r\n          2.0 - File is compressed using Deflate compression\r\n          2.0 - File is encrypted using traditional PKWARE encryption\r\n          2.1 - File is compressed using Deflate64(tm)\r\n          2.5 - File is compressed using PKWARE DCL Implode \r\n          2.7 - File is a patch data set \r\n          4.5 - File uses ZIP64 format extensions\r\n          4.6 - File is compressed using BZIP2 compression*\r\n          5.0 - File is encrypted using DES\r\n          5.0 - File is encrypted using 3DES\r\n          5.0 - File is encrypted using original RC2 encryption\r\n          5.0 - File is encrypted using RC4 encryption\r\n          5.1 - File is encrypted using AES encryption\r\n          5.1 - File is encrypted using corrected RC2 encryption**\r\n          5.2 - File is encrypted using corrected RC2-64 encryption**\r\n          6.1 - File is encrypted using non-OAEP key wrapping***\r\n          6.2 - Central directory encryption\r\n          6.3 - File is compressed using LZMA\r\n          6.3 - File is compressed using PPMd+\r\n          6.3 - File is encrypted using Blowfish\r\n          6.3 - File is encrypted using Twofish\r\n\r\n\r\n          * Early 7.x (pre-7.2) versions of PKZIP incorrectly set the\r\n          version needed to extract for BZIP2 compression to be 50\r\n          when it should have been 46.\r\n\r\n          ** Refer to the section on Strong Encryption Specification\r\n          for additional information regarding RC2 corrections.\r\n\r\n          *** Certificate encryption using non-OAEP key wrapping is the\r\n          intended mode of operation for all versions beginning with 6.1.\r\n          Support for OAEP key wrapping should only be used for\r\n          backward compatibility when sending ZIP files to be opened by\r\n          versions of PKZIP older than 6.1 (5.0 or 6.0).\r\n\r\n          + Files compressed using PPMd should set the version\r\n          needed to extract field to 6.3, however, not all ZIP \r\n          programs enforce this and may be unable to decompress \r\n          data files compressed using PPMd if this value is set.\r\n\r\n          When using ZIP64 extensions, the corresponding value in the\r\n          zip64 end of central directory record should also be set.  \r\n          This field should be set appropriately to indicate whether \r\n          Version 1 or Version 2 format is in use. \r\n\r\n      general purpose bit flag: (2 bytes)\r\n\r\n          Bit 0: If set, indicates that the file is encrypted.\r\n\r\n          (For Method 6 - Imploding)\r\n          Bit 1: If the compression method used was type 6,\r\n                 Imploding, then this bit, if set, indicates\r\n                 an 8K sliding dictionary was used.  If clear,\r\n                 then a 4K sliding dictionary was used.\r\n          Bit 2: If the compression method used was type 6,\r\n                 Imploding, then this bit, if set, indicates\r\n                 3 Shannon-Fano trees were used to encode the\r\n                 sliding dictionary output.  If clear, then 2\r\n                 Shannon-Fano trees were used.\r\n\r\n          (For Methods 8 and 9 - Deflating)\r\n          Bit 2  Bit 1\r\n            0      0    Normal (-en) compression option was used.\r\n            0      1    Maximum (-exx/-ex) compression option was used.\r\n            1      0    Fast (-ef) compression option was used.\r\n            1      1    Super Fast (-es) compression option was used.\r\n\r\n          (For Method 14 - LZMA)\r\n          Bit 1: If the compression method used was type 14,\r\n                 LZMA, then this bit, if set, indicates\r\n                 an end-of-stream (EOS) marker is used to\r\n                 mark the end of the compressed data stream.\r\n                 If clear, then an EOS marker is not present\r\n                 and the compressed data size must be known\r\n                 to extract.\r\n\r\n          Note:  Bits 1 and 2 are undefined if the compression\r\n                 method is any other.\r\n\r\n          Bit 3: If this bit is set, the fields crc-32, compressed \r\n                 size and uncompressed size are set to zero in the \r\n                 local header.  The correct values are put in the \r\n                 data descriptor immediately following the compressed\r\n                 data.  (Note: PKZIP version 2.04g for DOS only \r\n                 recognizes this bit for method 8 compression, newer \r\n                 versions of PKZIP recognize this bit for any \r\n                 compression method.)\r\n\r\n          Bit 4: Reserved for use with method 8, for enhanced\r\n                 deflating. \r\n\r\n          Bit 5: If this bit is set, this indicates that the file is \r\n                 compressed patched data.  (Note: Requires PKZIP \r\n                 version 2.70 or greater)\r\n\r\n          Bit 6: Strong encryption.  If this bit is set, you should\r\n                 set the version needed to extract value to at least\r\n                 50 and you must also set bit 0.  If AES encryption\r\n                 is used, the version needed to extract value must \r\n                 be at least 51.\r\n\r\n          Bit 7: Currently unused.\r\n\r\n          Bit 8: Currently unused.\r\n\r\n          Bit 9: Currently unused.\r\n\r\n          Bit 10: Currently unused.\r\n\r\n          Bit 11: Language encoding flag (EFS).  If this bit is set,\r\n                  the filename and comment fields for this file\r\n                  must be encoded using UTF-8. (see APPENDIX D)\r\n\r\n          Bit 12: Reserved by PKWARE for enhanced compression.\r\n\r\n          Bit 13: Used when encrypting the Central Directory to indicate \r\n                  selected data values in the Local Header are masked to\r\n                  hide their actual values.  See the section describing \r\n                  the Strong Encryption Specification for details.\r\n\r\n          Bit 14: Reserved by PKWARE.\r\n\r\n          Bit 15: Reserved by PKWARE.\r\n\r\n      compression method: (2 bytes)\r\n\r\n          (see accompanying documentation for algorithm\r\n          descriptions)\r\n\r\n          0 - The file is stored (no compression)\r\n          1 - The file is Shrunk\r\n          2 - The file is Reduced with compression factor 1\r\n          3 - The file is Reduced with compression factor 2\r\n          4 - The file is Reduced with compression factor 3\r\n          5 - The file is Reduced with compression factor 4\r\n          6 - The file is Imploded\r\n          7 - Reserved for Tokenizing compression algorithm\r\n          8 - The file is Deflated\r\n          9 - Enhanced Deflating using Deflate64(tm)\r\n         10 - PKWARE Data Compression Library Imploding (old IBM TERSE)\r\n         11 - Reserved by PKWARE\r\n         12 - File is compressed using BZIP2 algorithm\r\n         13 - Reserved by PKWARE\r\n         14 - LZMA (EFS)\r\n         15 - Reserved by PKWARE\r\n         16 - Reserved by PKWARE\r\n         17 - Reserved by PKWARE\r\n         18 - File is compressed using IBM TERSE (new)\r\n         19 - IBM LZ77 z Architecture (PFS)\r\n         97 - WavPack compressed data\r\n         98 - PPMd version I, Rev 1\r\n\r\n      date and time fields: (2 bytes each)\r\n\r\n          The date and time are encoded in standard MS-DOS format.\r\n          If input came from standard input, the date and time are\r\n          those at which compression was started for this data. \r\n          If encrypting the central directory and general purpose bit \r\n          flag 13 is set indicating masking, the value stored in the \r\n          Local Header will be zero. \r\n\r\n      CRC-32: (4 bytes)\r\n\r\n          The CRC-32 algorithm was generously contributed by\r\n          David Schwaderer and can be found in his excellent\r\n          book \"C Programmers Guide to NetBIOS\" published by\r\n          Howard W. Sams & Co. Inc.  The 'magic number' for\r\n          the CRC is 0xdebb20e3.  The proper CRC pre and post\r\n          conditioning is used, meaning that the CRC register\r\n          is pre-conditioned with all ones (a starting value\r\n          of 0xffffffff) and the value is post-conditioned by\r\n          taking the one's complement of the CRC residual.\r\n          If bit 3 of the general purpose flag is set, this\r\n          field is set to zero in the local header and the correct\r\n          value is put in the data descriptor and in the central\r\n          directory. When encrypting the central directory, if the\r\n          local header is not in ZIP64 format and general purpose \r\n          bit flag 13 is set indicating masking, the value stored \r\n          in the Local Header will be zero. \r\n\r\n      compressed size: (4 bytes)\r\n      uncompressed size: (4 bytes)\r\n\r\n          The size of the file compressed and uncompressed,\r\n          respectively.  When a decryption header is present it will\r\n          be placed in front of the file data and the value of the\r\n          compressed file size will include the bytes of the decryption\r\n          header.  If bit 3 of the general purpose bit flag is set, \r\n          these fields are set to zero in the local header and the \r\n          correct values are put in the data descriptor and\r\n          in the central directory.  If an archive is in ZIP64 format\r\n          and the value in this field is 0xFFFFFFFF, the size will be\r\n          in the corresponding 8 byte ZIP64 extended information \r\n          extra field.  When encrypting the central directory, if the\r\n          local header is not in ZIP64 format and general purpose bit \r\n          flag 13 is set indicating masking, the value stored for the \r\n          uncompressed size in the Local Header will be zero. \r\n\r\n      file name length: (2 bytes)\r\n      extra field length: (2 bytes)\r\n      file comment length: (2 bytes)\r\n\r\n          The length of the file name, extra field, and comment\r\n          fields respectively.  The combined length of any\r\n          directory record and these three fields should not\r\n          generally exceed 65,535 bytes.  If input came from standard\r\n          input, the file name length is set to zero.  \r\n\r\n      disk number start: (2 bytes)\r\n\r\n          The number of the disk on which this file begins.  If an \r\n          archive is in ZIP64 format and the value in this field is \r\n          0xFFFF, the size will be in the corresponding 4 byte zip64 \r\n          extended information extra field.\r\n\r\n      internal file attributes: (2 bytes)\r\n\r\n          Bits 1 and 2 are reserved for use by PKWARE.\r\n\r\n          The lowest bit of this field indicates, if set, that\r\n          the file is apparently an ASCII or text file.  If not\r\n          set, that the file apparently contains binary data.\r\n          The remaining bits are unused in version 1.0.\r\n\r\n          The 0x0002 bit of this field indicates, if set, that a \r\n          4 byte variable record length control field precedes each \r\n          logical record indicating the length of the record. The \r\n          record length control field is stored in little-endian byte\r\n          order.  This flag is independent of text control characters, \r\n          and if used in conjunction with text data, includes any \r\n          control characters in the total length of the record. This \r\n          value is provided for mainframe data transfer support.\r\n\r\n      external file attributes: (4 bytes)\r\n\r\n          The mapping of the external attributes is\r\n          host-system dependent (see 'version made by').  For\r\n          MS-DOS, the low order byte is the MS-DOS directory\r\n          attribute byte.  If input came from standard input, this\r\n          field is set to zero.\r\n\r\n      relative offset of local header: (4 bytes)\r\n\r\n          This is the offset from the start of the first disk on\r\n          which this file appears, to where the local header should\r\n          be found.  If an archive is in ZIP64 format and the value\r\n          in this field is 0xFFFFFFFF, the size will be in the \r\n          corresponding 8 byte zip64 extended information extra field.\r\n\r\n      file name: (Variable)\r\n\r\n          The name of the file, with optional relative path.\r\n          The path stored should not contain a drive or\r\n          device letter, or a leading slash.  All slashes\r\n          should be forward slashes '/' as opposed to\r\n          backwards slashes '\\' for compatibility with Amiga\r\n          and UNIX file systems etc.  If input came from standard\r\n          input, there is no file name field.  If encrypting\r\n          the central directory and general purpose bit flag 13 is set \r\n          indicating masking, the file name stored in the Local Header \r\n          will not be the actual file name.  A masking value consisting \r\n          of a unique hexadecimal value will be stored.  This value will \r\n          be sequentially incremented for each file in the archive. See\r\n          the section on the Strong Encryption Specification for details \r\n          on retrieving the encrypted file name. \r\n\r\n      extra field: (Variable)\r\n\r\n          This is for expansion.  If additional information\r\n          needs to be stored for special needs or for specific \r\n          platforms, it should be stored here.  Earlier versions \r\n          of the software can then safely skip this file, and \r\n          find the next file or header.  This field will be 0 \r\n          length in version 1.0.\r\n\r\n          In order to allow different programs and different types\r\n          of information to be stored in the 'extra' field in .ZIP\r\n          files, the following structure should be used for all\r\n          programs storing data in this field:\r\n\r\n          header1+data1 + header2+data2 . . .\r\n\r\n          Each header should consist of:\r\n\r\n            Header ID - 2 bytes\r\n            Data Size - 2 bytes\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          The Header ID field indicates the type of data that is in\r\n          the following data block.\r\n\r\n          Header ID's of 0 thru 31 are reserved for use by PKWARE.\r\n          The remaining ID's can be used by third party vendors for\r\n          proprietary usage.\r\n\r\n          The current Header ID mappings defined by PKWARE are:\r\n\r\n          0x0001        Zip64 extended information extra field\r\n          0x0007        AV Info\r\n          0x0008        Reserved for extended language encoding data (PFS)\r\n                        (see APPENDIX D)\r\n          0x0009        OS/2\r\n          0x000a        NTFS \r\n          0x000c        OpenVMS\r\n          0x000d        UNIX\r\n          0x000e        Reserved for file stream and fork descriptors\r\n          0x000f        Patch Descriptor\r\n          0x0014        PKCS#7 Store for X.509 Certificates\r\n          0x0015        X.509 Certificate ID and Signature for \r\n                        individual file\r\n          0x0016        X.509 Certificate ID for Central Directory\r\n          0x0017        Strong Encryption Header\r\n          0x0018        Record Management Controls\r\n          0x0019        PKCS#7 Encryption Recipient Certificate List\r\n          0x0065        IBM S/390 (Z390), AS/400 (I400) attributes \r\n                        - uncompressed\r\n          0x0066        Reserved for IBM S/390 (Z390), AS/400 (I400) \r\n                        attributes - compressed\r\n          0x4690        POSZIP 4690 (reserved) \r\n\r\n          Third party mappings commonly used are:\r\n\r\n\r\n          0x07c8        Macintosh\r\n          0x2605        ZipIt Macintosh\r\n          0x2705        ZipIt Macintosh 1.3.5+\r\n          0x2805        ZipIt Macintosh 1.3.5+\r\n          0x334d        Info-ZIP Macintosh\r\n          0x4341        Acorn/SparkFS \r\n          0x4453        Windows NT security descriptor (binary ACL)\r\n          0x4704        VM/CMS\r\n          0x470f        MVS\r\n          0x4b46        FWKCS MD5 (see below)\r\n          0x4c41        OS/2 access control list (text ACL)\r\n          0x4d49        Info-ZIP OpenVMS\r\n          0x4f4c        Xceed original location extra field\r\n          0x5356        AOS/VS (ACL)\r\n          0x5455        extended timestamp\r\n          0x554e        Xceed unicode extra field\r\n          0x5855        Info-ZIP UNIX (original, also OS/2, NT, etc)\r\n          0x6375        Info-ZIP Unicode Comment Extra Field\r\n          0x6542        BeOS/BeBox\r\n          0x7075        Info-ZIP Unicode Path Extra Field\r\n          0x756e        ASi UNIX\r\n          0x7855        Info-ZIP UNIX (new)\r\n          0xa220        Microsoft Open Packaging Growth Hint\r\n          0xfd4a        SMS/QDOS\r\n\r\n          Detailed descriptions of Extra Fields defined by third \r\n          party mappings will be documented as information on\r\n          these data structures is made available to PKWARE.  \r\n          PKWARE does not guarantee the accuracy of any published\r\n          third party data.\r\n\r\n          The Data Size field indicates the size of the following\r\n          data block. Programs can use this value to skip to the\r\n          next header block, passing over any data blocks that are\r\n          not of interest.\r\n\r\n          Note: As stated above, the size of the entire .ZIP file\r\n                header, including the file name, comment, and extra\r\n                field should not exceed 64K in size.\r\n\r\n          In case two different programs should appropriate the same\r\n          Header ID value, it is strongly recommended that each\r\n          program place a unique signature of at least two bytes in\r\n          size (and preferably 4 bytes or bigger) at the start of\r\n          each data area.  Every program should verify that its\r\n          unique signature is present, in addition to the Header ID\r\n          value being correct, before assuming that it is a block of\r\n          known type.\r\n\r\n         -Zip64 Extended Information Extra Field (0x0001):\r\n\r\n          The following is the layout of the zip64 extended \r\n          information \"extra\" block. If one of the size or\r\n          offset fields in the Local or Central directory\r\n          record is too small to hold the required data,\r\n          a Zip64 extended information record is created.\r\n          The order of the fields in the zip64 extended \r\n          information record is fixed, but the fields will\r\n          only appear if the corresponding Local or Central\r\n          directory record field is set to 0xFFFF or 0xFFFFFFFF.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value      Size       Description\r\n          -----      ----       -----------\r\n  (ZIP64) 0x0001     2 bytes    Tag for this \"extra\" block type\r\n          Size       2 bytes    Size of this \"extra\" block\r\n          Original \r\n          Size       8 bytes    Original uncompressed file size\r\n          Compressed\r\n          Size       8 bytes    Size of compressed data\r\n          Relative Header\r\n          Offset     8 bytes    Offset of local header record\r\n          Disk Start\r\n          Number     4 bytes    Number of the disk on which\r\n                                this file starts \r\n\r\n          This entry in the Local header must include BOTH original\r\n          and compressed file size fields. If encrypting the \r\n          central directory and bit 13 of the general purpose bit\r\n          flag is set indicating masking, the value stored in the\r\n          Local Header for the original file size will be zero.\r\n\r\n\r\n         -OS/2 Extra Field (0x0009):\r\n\r\n          The following is the layout of the OS/2 attributes \"extra\" \r\n          block.  (Last Revision  09/05/95)\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value       Size          Description\r\n          -----       ----          -----------\r\n  (OS/2)  0x0009      2 bytes       Tag for this \"extra\" block type\r\n          TSize       2 bytes       Size for the following data block\r\n          BSize       4 bytes       Uncompressed Block Size\r\n          CType       2 bytes       Compression type\r\n          EACRC       4 bytes       CRC value for uncompress block\r\n          (var)       variable      Compressed block\r\n\r\n          The OS/2 extended attribute structure (FEA2LIST) is \r\n          compressed and then stored in it's entirety within this \r\n          structure.  There will only ever be one \"block\" of data in \r\n          VarFields[].\r\n\r\n         -NTFS Extra Field (0x000a):\r\n\r\n          The following is the layout of the NTFS attributes \r\n          \"extra\" block. (Note: At this time the Mtime, Atime\r\n          and Ctime values may be used on any WIN32 system.)  \r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value      Size       Description\r\n          -----      ----       -----------\r\n  (NTFS)  0x000a     2 bytes    Tag for this \"extra\" block type\r\n          TSize      2 bytes    Size of the total \"extra\" block\r\n          Reserved   4 bytes    Reserved for future use\r\n          Tag1       2 bytes    NTFS attribute tag value #1\r\n          Size1      2 bytes    Size of attribute #1, in bytes\r\n          (var.)     Size1      Attribute #1 data\r\n          .\r\n          .\r\n          .\r\n          TagN       2 bytes    NTFS attribute tag value #N\r\n          SizeN      2 bytes    Size of attribute #N, in bytes\r\n          (var.)     SizeN      Attribute #N data\r\n\r\n          For NTFS, values for Tag1 through TagN are as follows:\r\n          (currently only one set of attributes is defined for NTFS)\r\n\r\n          Tag        Size       Description\r\n          -----      ----       -----------\r\n          0x0001     2 bytes    Tag for attribute #1 \r\n          Size1      2 bytes    Size of attribute #1, in bytes\r\n          Mtime      8 bytes    File last modification time\r\n          Atime      8 bytes    File last access time\r\n          Ctime      8 bytes    File creation time\r\n\r\n         -OpenVMS Extra Field (0x000c):\r\n\r\n          The following is the layout of the OpenVMS attributes \r\n          \"extra\" block.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value      Size       Description\r\n          -----      ----       -----------\r\n  (VMS)   0x000c     2 bytes    Tag for this \"extra\" block type\r\n          TSize      2 bytes    Size of the total \"extra\" block\r\n          CRC        4 bytes    32-bit CRC for remainder of the block\r\n          Tag1       2 bytes    OpenVMS attribute tag value #1\r\n          Size1      2 bytes    Size of attribute #1, in bytes\r\n          (var.)     Size1      Attribute #1 data\r\n          .\r\n          .\r\n          .\r\n          TagN       2 bytes    OpenVMS attribute tag value #N\r\n          SizeN      2 bytes    Size of attribute #N, in bytes\r\n          (var.)     SizeN      Attribute #N data\r\n\r\n          Rules:\r\n\r\n          1. There will be one or more of attributes present, which \r\n             will each be preceded by the above TagX & SizeX values.  \r\n             These values are identical to the ATR$C_XXXX and \r\n             ATR$S_XXXX constants which are defined in ATR.H under \r\n             OpenVMS C.  Neither of these values will ever be zero.\r\n\r\n          2. No word alignment or padding is performed.\r\n\r\n          3. A well-behaved PKZIP/OpenVMS program should never produce\r\n             more than one sub-block with the same TagX value.  Also,\r\n             there will never be more than one \"extra\" block of type\r\n             0x000c in a particular directory record.\r\n\r\n         -UNIX Extra Field (0x000d):\r\n\r\n          The following is the layout of the UNIX \"extra\" block.\r\n          Note: all fields are stored in Intel low-byte/high-byte \r\n          order.\r\n\r\n          Value       Size          Description\r\n          -----       ----          -----------\r\n  (UNIX)  0x000d      2 bytes       Tag for this \"extra\" block type\r\n          TSize       2 bytes       Size for the following data block\r\n          Atime       4 bytes       File last access time\r\n          Mtime       4 bytes       File last modification time\r\n          Uid         2 bytes       File user ID\r\n          Gid         2 bytes       File group ID\r\n          (var)       variable      Variable length data field\r\n\r\n          The variable length data field will contain file type \r\n          specific data.  Currently the only values allowed are\r\n          the original \"linked to\" file names for hard or symbolic \r\n          links, and the major and minor device node numbers for\r\n          character and block device nodes.  Since device nodes\r\n          cannot be either symbolic or hard links, only one set of\r\n          variable length data is stored.  Link files will have the\r\n          name of the original file stored.  This name is NOT NULL\r\n          terminated.  Its size can be determined by checking TSize -\r\n          12.  Device entries will have eight bytes stored as two 4\r\n          byte entries (in little endian format).  The first entry\r\n          will be the major device number, and the second the minor\r\n          device number.\r\n          \r\n         -PATCH Descriptor Extra Field (0x000f):\r\n\r\n          The following is the layout of the Patch Descriptor \"extra\"\r\n          block.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n  (Patch) 0x000f    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of the total \"extra\" block\r\n          Version   2 bytes  Version of the descriptor\r\n          Flags     4 bytes  Actions and reactions (see below) \r\n          OldSize   4 bytes  Size of the file about to be patched \r\n          OldCRC    4 bytes  32-bit CRC of the file to be patched \r\n          NewSize   4 bytes  Size of the resulting file \r\n          NewCRC    4 bytes  32-bit CRC of the resulting file \r\n\r\n          Actions and reactions\r\n\r\n          Bits          Description\r\n          ----          ----------------\r\n          0             Use for auto detection\r\n          1             Treat as a self-patch\r\n          2-3           RESERVED\r\n          4-5           Action (see below)\r\n          6-7           RESERVED\r\n          8-9           Reaction (see below) to absent file \r\n          10-11         Reaction (see below) to newer file\r\n          12-13         Reaction (see below) to unknown file\r\n          14-15         RESERVED\r\n          16-31         RESERVED\r\n\r\n          Actions\r\n\r\n          Action       Value\r\n          ------       ----- \r\n          none         0\r\n          add          1\r\n          delete       2\r\n          patch        3\r\n\r\n          Reactions\r\n \r\n          Reaction     Value\r\n          --------     -----\r\n          ask          0\r\n          skip         1\r\n          ignore       2\r\n          fail         3\r\n\r\n          Patch support is provided by PKPatchMaker(tm) technology and is \r\n          covered under U.S. Patents and Patents Pending. The use or \r\n          implementation in a product of certain technological aspects set\r\n          forth in the current APPNOTE, including those with regard to \r\n          strong encryption, patching, or extended tape operations requires\r\n          a license from PKWARE.  Please contact PKWARE with regard to \r\n          acquiring a license. \r\n\r\n         -PKCS#7 Store for X.509 Certificates (0x0014):\r\n\r\n          This field contains information about each of the certificates \r\n          files may be signed with. When the Central Directory Encryption \r\n          feature is enabled for a ZIP file, this record will appear in \r\n          the Archive Extra Data Record, otherwise it will appear in the \r\n          first central directory record and will be ignored in any \r\n          other record.\r\n          \r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n  (Store) 0x0014    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of the store data\r\n          TData     TSize    Data about the store\r\n\r\n\r\n         -X.509 Certificate ID and Signature for individual file (0x0015):\r\n\r\n          This field contains the information about which certificate in \r\n          the PKCS#7 store was used to sign a particular file. It also \r\n          contains the signature data. This field can appear multiple \r\n          times, but can only appear once per certificate.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n  (CID)   0x0015    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of data that follows\r\n          TData     TSize    Signature Data\r\n\r\n         -X.509 Certificate ID and Signature for central directory (0x0016):\r\n\r\n          This field contains the information about which certificate in \r\n          the PKCS#7 store was used to sign the central directory structure.\r\n          When the Central Directory Encryption feature is enabled for a \r\n          ZIP file, this record will appear in the Archive Extra Data Record, \r\n          otherwise it will appear in the first central directory record.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n  (CDID)  0x0016    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of data that follows\r\n          TData     TSize    Data\r\n\r\n         -Strong Encryption Header (0x0017):\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          0x0017    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of data that follows\r\n          Format    2 bytes  Format definition for this record\r\n          AlgID     2 bytes  Encryption algorithm identifier\r\n          Bitlen    2 bytes  Bit length of encryption key\r\n          Flags     2 bytes  Processing flags\r\n          CertData  TSize-8  Certificate decryption extra field data\r\n                             (refer to the explanation for CertData\r\n                              in the section describing the \r\n                              Certificate Processing Method under \r\n                              the Strong Encryption Specification)\r\n\r\n\r\n         -Record Management Controls (0x0018):\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n(Rec-CTL) 0x0018    2 bytes  Tag for this \"extra\" block type\r\n          CSize     2 bytes  Size of total extra block data\r\n          Tag1      2 bytes  Record control attribute 1\r\n          Size1     2 bytes  Size of attribute 1, in bytes\r\n          Data1     Size1    Attribute 1 data\r\n            .\r\n            .\r\n            .\r\n          TagN      2 bytes  Record control attribute N\r\n          SizeN     2 bytes  Size of attribute N, in bytes\r\n          DataN     SizeN    Attribute N data\r\n\r\n\r\n         -PKCS#7 Encryption Recipient Certificate List (0x0019): \r\n\r\n          This field contains information about each of the certificates\r\n          used in encryption processing and it can be used to identify who is\r\n          allowed to decrypt encrypted files.  This field should only appear \r\n          in the archive extra data record. This field is not required and \r\n          serves only to aide archive modifications by preserving public \r\n          encryption key data. Individual security requirements may dictate \r\n          that this data be omitted to deter information exposure.\r\n\r\n          Note: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n (CStore) 0x0019    2 bytes  Tag for this \"extra\" block type\r\n          TSize     2 bytes  Size of the store data\r\n          TData     TSize    Data about the store\r\n\r\n          TData:\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          Version   2 bytes  Format version number - must 0x0001 at this time\r\n          CStore    (var)    PKCS#7 data blob\r\n\r\n\r\n         -MVS Extra Field (0x0065):\r\n\r\n          The following is the layout of the MVS \"extra\" block.\r\n          Note: Some fields are stored in Big Endian format.\r\n          All text is in EBCDIC format unless otherwise specified.\r\n\r\n          Value       Size          Description\r\n          -----       ----          -----------\r\n  (MVS)   0x0065      2 bytes       Tag for this \"extra\" block type\r\n          TSize       2 bytes       Size for the following data block\r\n          ID          4 bytes       EBCDIC \"Z390\" 0xE9F3F9F0 or\r\n                                    \"T4MV\" for TargetFour\r\n          (var)       TSize-4       Attribute data (see APPENDIX B)\r\n\r\n\r\n         -OS/400 Extra Field (0x0065):\r\n\r\n          The following is the layout of the OS/400 \"extra\" block.\r\n          Note: Some fields are stored in Big Endian format.\r\n          All text is in EBCDIC format unless otherwise specified.\r\n\r\n          Value       Size          Description\r\n          -----       ----          -----------\r\n  (OS400) 0x0065      2 bytes       Tag for this \"extra\" block type\r\n          TSize       2 bytes       Size for the following data block\r\n          ID          4 bytes       EBCDIC \"I400\" 0xC9F4F0F0 or\r\n                                    \"T4MV\" for TargetFour\r\n          (var)       TSize-4       Attribute data (see APPENDIX A)\r\n\r\n\r\n          Third-party Mappings:\r\n          \r\n         -ZipIt Macintosh Extra Field (long) (0x2605):\r\n\r\n          The following is the layout of the ZipIt extra block \r\n          for Macintosh. The local-header and central-header versions \r\n          are identical. This block must be present if the file is \r\n          stored MacBinary-encoded and it should not be used if the file \r\n          is not stored MacBinary-encoded.\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n  (Mac2)  0x2605        Short       tag for this extra block type\r\n          TSize         Short       total data size for this block\r\n          \"ZPIT\"        beLong      extra-field signature\r\n          FnLen         Byte        length of FileName\r\n          FileName      variable    full Macintosh filename\r\n          FileType      Byte[4]     four-byte Mac file type string\r\n          Creator       Byte[4]     four-byte Mac creator string\r\n\r\n\r\n         -ZipIt Macintosh Extra Field (short, for files) (0x2705):\r\n\r\n          The following is the layout of a shortened variant of the\r\n          ZipIt extra block for Macintosh (without \"full name\" entry).\r\n          This variant is used by ZipIt 1.3.5 and newer for entries of\r\n          files (not directories) that do not have a MacBinary encoded\r\n          file. The local-header and central-header versions are identical.\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n  (Mac2b) 0x2705        Short       tag for this extra block type\r\n          TSize         Short       total data size for this block (12)\r\n          \"ZPIT\"        beLong      extra-field signature\r\n          FileType      Byte[4]     four-byte Mac file type string\r\n          Creator       Byte[4]     four-byte Mac creator string\r\n          fdFlags       beShort     attributes from FInfo.frFlags,\r\n                                    may be omitted\r\n          0x0000        beShort     reserved, may be omitted\r\n\r\n\r\n         -ZipIt Macintosh Extra Field (short, for directories) (0x2805):\r\n\r\n          The following is the layout of a shortened variant of the\r\n          ZipIt extra block for Macintosh used only for directory\r\n          entries. This variant is used by ZipIt 1.3.5 and newer to \r\n          save some optional Mac-specific information about directories.\r\n          The local-header and central-header versions are identical.\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n  (Mac2c) 0x2805        Short       tag for this extra block type\r\n          TSize         Short       total data size for this block (12)\r\n          \"ZPIT\"        beLong      extra-field signature\r\n          frFlags       beShort     attributes from DInfo.frFlags, may\r\n                                    be omitted\r\n          View          beShort     ZipIt view flag, may be omitted\r\n\r\n\r\n          The View field specifies ZipIt-internal settings as follows:\r\n\r\n          Bits of the Flags:\r\n              bit 0           if set, the folder is shown expanded (open)\r\n                              when the archive contents are viewed in ZipIt.\r\n              bits 1-15       reserved, zero;\r\n\r\n\r\n         -FWKCS MD5 Extra Field (0x4b46):\r\n\r\n          The FWKCS Contents_Signature System, used in\r\n          automatically identifying files independent of file name,\r\n          optionally adds and uses an extra field to support the\r\n          rapid creation of an enhanced contents_signature:\r\n\r\n              Header ID = 0x4b46\r\n              Data Size = 0x0013\r\n              Preface   = 'M','D','5'\r\n              followed by 16 bytes containing the uncompressed file's\r\n              128_bit MD5 hash(1), low byte first.\r\n\r\n          When FWKCS revises a .ZIP file central directory to add\r\n          this extra field for a file, it also replaces the\r\n          central directory entry for that file's uncompressed\r\n          file length with a measured value.\r\n\r\n          FWKCS provides an option to strip this extra field, if\r\n          present, from a .ZIP file central directory. In adding\r\n          this extra field, FWKCS preserves .ZIP file Authenticity\r\n          Verification; if stripping this extra field, FWKCS\r\n          preserves all versions of AV through PKZIP version 2.04g.\r\n\r\n          FWKCS, and FWKCS Contents_Signature System, are\r\n          trademarks of Frederick W. Kantor.\r\n\r\n          (1) R. Rivest, RFC1321.TXT, MIT Laboratory for Computer\r\n              Science and RSA Data Security, Inc., April 1992.\r\n              ll.76-77: \"The MD5 algorithm is being placed in the\r\n              public domain for review and possible adoption as a\r\n              standard.\"\r\n\r\n\r\n         -Info-ZIP Unicode Comment Extra Field (0x6375):\r\n\r\n          Stores the UTF-8 version of the file comment as stored in the\r\n          central directory header. (Last Revision 20070912)\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n   (UCom) 0x6375        Short       tag for this extra block type (\"uc\")\r\n          TSize         Short       total data size for this block\r\n          Version       1 byte      version of this extra field, currently 1\r\n          ComCRC32      4 bytes     Comment Field CRC32 Checksum\r\n          UnicodeCom    Variable    UTF-8 version of the entry comment\r\n\r\n          Currently Version is set to the number 1.  If there is a need\r\n          to change this field, the version will be incremented.  Changes\r\n          may not be backward compatible so this extra field should not be\r\n          used if the version is not recognized.\r\n\r\n          The ComCRC32 is the standard zip CRC32 checksum of the File Comment\r\n          field in the central directory header.  This is used to verify that\r\n          the comment field has not changed since the Unicode Comment extra field\r\n          was created.  This can happen if a utility changes the File Comment \r\n          field but does not update the UTF-8 Comment extra field.  If the CRC \r\n          check fails, this Unicode Comment extra field should be ignored and \r\n          the File Comment field in the header should be used instead.\r\n\r\n          The UnicodeCom field is the UTF-8 version of the File Comment field\r\n          in the header.  As UnicodeCom is defined to be UTF-8, no UTF-8 byte\r\n          order mark (BOM) is used.  The length of this field is determined by\r\n          subtracting the size of the previous fields from TSize.  If both the\r\n          File Name and Comment fields are UTF-8, the new General Purpose Bit\r\n          Flag, bit 11 (Language encoding flag (EFS)), can be used to indicate\r\n          both the header File Name and Comment fields are UTF-8 and, in this\r\n          case, the Unicode Path and Unicode Comment extra fields are not\r\n          needed and should not be created.  Note that, for backward\r\n          compatibility, bit 11 should only be used if the native character set\r\n          of the paths and comments being zipped up are already in UTF-8. It is\r\n          expected that the same file comment storage method, either general\r\n          purpose bit 11 or extra fields, be used in both the Local and Central\r\n          Directory Header for a file.\r\n\r\n\r\n         -Info-ZIP Unicode Path Extra Field (0x7075):\r\n\r\n          Stores the UTF-8 version of the file name field as stored in the\r\n          local header and central directory header. (Last Revision 20070912)\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n  (UPath) 0x7075        Short       tag for this extra block type (\"up\")\r\n          TSize         Short       total data size for this block\r\n          Version       1 byte      version of this extra field, currently 1\r\n          NameCRC32     4 bytes     File Name Field CRC32 Checksum\r\n          UnicodeName   Variable    UTF-8 version of the entry File Name\r\n\r\n          Currently Version is set to the number 1.  If there is a need\r\n          to change this field, the version will be incremented.  Changes\r\n          may not be backward compatible so this extra field should not be\r\n          used if the version is not recognized.\r\n\r\n          The NameCRC32 is the standard zip CRC32 checksum of the File Name\r\n          field in the header.  This is used to verify that the header\r\n          File Name field has not changed since the Unicode Path extra field\r\n          was created.  This can happen if a utility renames the File Name but\r\n          does not update the UTF-8 path extra field.  If the CRC check fails,\r\n          this UTF-8 Path Extra Field should be ignored and the File Name field\r\n          in the header should be used instead.\r\n\r\n          The UnicodeName is the UTF-8 version of the contents of the File Name\r\n          field in the header.  As UnicodeName is defined to be UTF-8, no UTF-8\r\n          byte order mark (BOM) is used.  The length of this field is determined\r\n          by subtracting the size of the previous fields from TSize.  If both\r\n          the File Name and Comment fields are UTF-8, the new General Purpose\r\n          Bit Flag, bit 11 (Language encoding flag (EFS)), can be used to\r\n          indicate that both the header File Name and Comment fields are UTF-8\r\n          and, in this case, the Unicode Path and Unicode Comment extra fields\r\n          are not needed and should not be created.  Note that, for backward\r\n          compatibility, bit 11 should only be used if the native character set\r\n          of the paths and comments being zipped up are already in UTF-8. It is\r\n          expected that the same file name storage method, either general\r\n          purpose bit 11 or extra fields, be used in both the Local and Central\r\n          Directory Header for a file.\r\n \r\n\r\n        -Microsoft Open Packaging Growth Hint (0xa220):\r\n\r\n          Value         Size        Description\r\n          -----         ----        -----------\r\n          0xa220        Short       tag for this extra block type\r\n          TSize         Short       size of Sig + PadVal + Padding\r\n          Sig           Short       verification signature (A028)\r\n          PadVal        Short       Initial padding value\r\n          Padding       variable    filled with NULL characters\r\n\r\n\r\n      file comment: (Variable)\r\n\r\n          The comment for this file.\r\n\r\n      number of this disk: (2 bytes)\r\n\r\n          The number of this disk, which contains central\r\n          directory end record. If an archive is in ZIP64 format\r\n          and the value in this field is 0xFFFF, the size will \r\n          be in the corresponding 4 byte zip64 end of central \r\n          directory field.\r\n\r\n\r\n      number of the disk with the start of the central\r\n      directory: (2 bytes)\r\n\r\n          The number of the disk on which the central\r\n          directory starts. If an archive is in ZIP64 format\r\n          and the value in this field is 0xFFFF, the size will \r\n          be in the corresponding 4 byte zip64 end of central \r\n          directory field.\r\n\r\n      total number of entries in the central dir on \r\n      this disk: (2 bytes)\r\n\r\n          The number of central directory entries on this disk.\r\n          If an archive is in ZIP64 format and the value in \r\n          this field is 0xFFFF, the size will be in the \r\n          corresponding 8 byte zip64 end of central \r\n          directory field.\r\n\r\n      total number of entries in the central dir: (2 bytes)\r\n\r\n          The total number of files in the .ZIP file. If an \r\n          archive is in ZIP64 format and the value in this field\r\n          is 0xFFFF, the size will be in the corresponding 8 byte \r\n          zip64 end of central directory field.\r\n\r\n      size of the central directory: (4 bytes)\r\n\r\n          The size (in bytes) of the entire central directory.\r\n          If an archive is in ZIP64 format and the value in \r\n          this field is 0xFFFFFFFF, the size will be in the \r\n          corresponding 8 byte zip64 end of central \r\n          directory field.\r\n\r\n      offset of start of central directory with respect to\r\n      the starting disk number:  (4 bytes)\r\n\r\n          Offset of the start of the central directory on the\r\n          disk on which the central directory starts. If an \r\n          archive is in ZIP64 format and the value in this \r\n          field is 0xFFFFFFFF, the size will be in the \r\n          corresponding 8 byte zip64 end of central \r\n          directory field.\r\n\r\n      .ZIP file comment length: (2 bytes)\r\n\r\n          The length of the comment for this .ZIP file.\r\n\r\n      .ZIP file comment: (Variable)\r\n\r\n          The comment for this .ZIP file.  ZIP file comment data\r\n          is stored unsecured.  No encryption or data authentication\r\n          is applied to this area at this time.  Confidential information\r\n          should not be stored in this section.\r\n\r\n      zip64 extensible data sector    (variable size)\r\n\r\n          (currently reserved for use by PKWARE)\r\n\r\n\r\n  K.  Splitting and Spanning ZIP files\r\n\r\n          Spanning is the process of segmenting a ZIP file across \r\n          multiple removable media. This support has typically only \r\n          been provided for DOS formatted floppy diskettes. \r\n\r\n          File splitting is a newer derivative of spanning.  \r\n          Splitting follows the same segmentation process as\r\n          spanning, however, it does not require writing each\r\n          segment to a unique removable medium and instead supports\r\n          placing all pieces onto local or non-removable locations\r\n          such as file systems, local drives, folders, etc...\r\n\r\n          A key difference between spanned and split ZIP files is\r\n          that all pieces of a spanned ZIP file have the same name.  \r\n          Since each piece is written to a separate volume, no name \r\n          collisions occur and each segment can reuse the original \r\n          .ZIP file name given to the archive.\r\n\r\n          Sequence ordering for DOS spanned archives uses the DOS \r\n          volume label to determine segment numbers.  Volume labels\r\n          for each segment are written using the form PKBACK#xxx, \r\n          where xxx is the segment number written as a decimal \r\n          value from 001 - nnn.\r\n\r\n          Split ZIP files are typically written to the same location\r\n          and are subject to name collisions if the spanned name\r\n          format is used since each segment will reside on the same \r\n          drive. To avoid name collisions, split archives are named \r\n          as follows.\r\n\r\n          Segment 1   = filename.z01\r\n          Segment n-1 = filename.z(n-1)\r\n          Segment n   = filename.zip\r\n\r\n          The .ZIP extension is used on the last segment to support\r\n          quickly reading the central directory.  The segment number\r\n          n should be a decimal value.\r\n\r\n          Spanned ZIP files may be PKSFX Self-extracting ZIP files.\r\n          PKSFX files may also be split, however, in this case\r\n          the first segment must be named filename.exe.  The first\r\n          segment of a split PKSFX archive must be large enough to\r\n          include the entire executable program.\r\n\r\n          Capacities for split archives are as follows.\r\n\r\n          Maximum number of segments = 4,294,967,295 - 1\r\n          Maximum .ZIP segment size = 4,294,967,295 bytes\r\n          Minimum segment size = 64K\r\n          Maximum PKSFX segment size = 2,147,483,647 bytes\r\n          \r\n          Segment sizes may be different however by convention, all \r\n          segment sizes should be the same with the exception of the \r\n          last, which may be smaller.  Local and central directory \r\n          header records must never be split across a segment boundary. \r\n          When writing a header record, if the number of bytes remaining \r\n          within a segment is less than the size of the header record,\r\n          end the current segment and write the header at the start\r\n          of the next segment.  The central directory may span segment\r\n          boundaries, but no single record in the central directory\r\n          should be split across segments.\r\n\r\n          Spanned/Split archives created using PKZIP for Windows\r\n          (V2.50 or greater), PKZIP Command Line (V2.50 or greater),\r\n          or PKZIP Explorer will include a special spanning \r\n          signature as the first 4 bytes of the first segment of\r\n          the archive.  This signature (0x08074b50) will be \r\n          followed immediately by the local header signature for\r\n          the first file in the archive.  \r\n\r\n          A special spanning marker may also appear in spanned/split \r\n          archives if the spanning or splitting process starts but \r\n          only requires one segment.  In this case the 0x08074b50 \r\n          signature will be replaced with the temporary spanning \r\n          marker signature of 0x30304b50.  Split archives can\r\n          only be uncompressed by other versions of PKZIP that\r\n          know how to create a split archive.\r\n\r\n          The signature value 0x08074b50 is also used by some\r\n          ZIP implementations as a marker for the Data Descriptor \r\n          record.  Conflict in this alternate assignment can be\r\n          avoided by ensuring the position of the signature\r\n          within the ZIP file to determine the use for which it\r\n          is intended.  \r\n\r\n  L.  General notes:\r\n\r\n      1)  All fields unless otherwise noted are unsigned and stored\r\n          in Intel low-byte:high-byte, low-word:high-word order.\r\n\r\n      2)  String fields are not null terminated, since the\r\n          length is given explicitly.\r\n\r\n      3)  The entries in the central directory may not necessarily\r\n          be in the same order that files appear in the .ZIP file.\r\n\r\n      4)  If one of the fields in the end of central directory\r\n          record is too small to hold required data, the field\r\n          should be set to -1 (0xFFFF or 0xFFFFFFFF) and the\r\n          ZIP64 format record should be created.\r\n\r\n      5)  The end of central directory record and the\r\n          Zip64 end of central directory locator record must\r\n          reside on the same disk when splitting or spanning\r\n          an archive.\r\n\r\nVI. Explanation of compression methods\r\n--------------------------------------\r\n\r\nUnShrinking - Method 1\r\n----------------------\r\n\r\nShrinking is a Dynamic Ziv-Lempel-Welch compression algorithm\r\nwith partial clearing.  The initial code size is 9 bits, and\r\nthe maximum code size is 13 bits.  Shrinking differs from\r\nconventional Dynamic Ziv-Lempel-Welch implementations in several\r\nrespects:\r\n\r\n1)  The code size is controlled by the compressor, and is not\r\n    automatically increased when codes larger than the current\r\n    code size are created (but not necessarily used).  When\r\n    the decompressor encounters the code sequence 256\r\n    (decimal) followed by 1, it should increase the code size\r\n    read from the input stream to the next bit size.  No\r\n    blocking of the codes is performed, so the next code at\r\n    the increased size should be read from the input stream\r\n    immediately after where the previous code at the smaller\r\n    bit size was read.  Again, the decompressor should not\r\n    increase the code size used until the sequence 256,1 is\r\n    encountered.\r\n\r\n2)  When the table becomes full, total clearing is not\r\n    performed.  Rather, when the compressor emits the code\r\n    sequence 256,2 (decimal), the decompressor should clear\r\n    all leaf nodes from the Ziv-Lempel tree, and continue to\r\n    use the current code size.  The nodes that are cleared\r\n    from the Ziv-Lempel tree are then re-used, with the lowest\r\n    code value re-used first, and the highest code value\r\n    re-used last.  The compressor can emit the sequence 256,2\r\n    at any time.\r\n\r\nExpanding - Methods 2-5\r\n-----------------------\r\n\r\nThe Reducing algorithm is actually a combination of two\r\ndistinct algorithms.  The first algorithm compresses repeated\r\nbyte sequences, and the second algorithm takes the compressed\r\nstream from the first algorithm and applies a probabilistic\r\ncompression method.\r\n\r\nThe probabilistic compression stores an array of 'follower\r\nsets' S(j), for j=0 to 255, corresponding to each possible\r\nASCII character.  Each set contains between 0 and 32\r\ncharacters, to be denoted as S(j)[0],...,S(j)[m], where m<32.\r\nThe sets are stored at the beginning of the data area for a\r\nReduced file, in reverse order, with S(255) first, and S(0)\r\nlast.\r\n\r\nThe sets are encoded as { N(j), S(j)[0],...,S(j)[N(j)-1] },\r\nwhere N(j) is the size of set S(j).  N(j) can be 0, in which\r\ncase the follower set for S(j) is empty.  Each N(j) value is\r\nencoded in 6 bits, followed by N(j) eight bit character values\r\ncorresponding to S(j)[0] to S(j)[N(j)-1] respectively.  If\r\nN(j) is 0, then no values for S(j) are stored, and the value\r\nfor N(j-1) immediately follows.\r\n\r\nImmediately after the follower sets, is the compressed data\r\nstream.  The compressed data stream can be interpreted for the\r\nprobabilistic decompression as follows:\r\n\r\nlet Last-Character <- 0.\r\nloop until done\r\n    if the follower set S(Last-Character) is empty then\r\n        read 8 bits from the input stream, and copy this\r\n        value to the output stream.\r\n    otherwise if the follower set S(Last-Character) is non-empty then\r\n        read 1 bit from the input stream.\r\n        if this bit is not zero then\r\n            read 8 bits from the input stream, and copy this\r\n            value to the output stream.\r\n        otherwise if this bit is zero then\r\n            read B(N(Last-Character)) bits from the input\r\n            stream, and assign this value to I.\r\n            Copy the value of S(Last-Character)[I] to the\r\n            output stream.\r\n\r\n    assign the last value placed on the output stream to\r\n    Last-Character.\r\nend loop\r\n\r\nB(N(j)) is defined as the minimal number of bits required to\r\nencode the value N(j)-1.\r\n\r\nThe decompressed stream from above can then be expanded to\r\nre-create the original file as follows:\r\n\r\nlet State <- 0.\r\n\r\nloop until done\r\n    read 8 bits from the input stream into C.\r\n    case State of\r\n        0:  if C is not equal to DLE (144 decimal) then\r\n                copy C to the output stream.\r\n            otherwise if C is equal to DLE then\r\n                let State <- 1.\r\n\r\n        1:  if C is non-zero then\r\n                let V <- C.\r\n                let Len <- L(V)\r\n                let State <- F(Len).\r\n            otherwise if C is zero then\r\n                copy the value 144 (decimal) to the output stream.\r\n                let State <- 0\r\n\r\n        2:  let Len <- Len + C\r\n            let State <- 3.\r\n\r\n        3:  move backwards D(V,C) bytes in the output stream\r\n            (if this position is before the start of the output\r\n            stream, then assume that all the data before the\r\n            start of the output stream is filled with zeros).\r\n            copy Len+3 bytes from this position to the output stream.\r\n            let State <- 0.\r\n    end case\r\nend loop\r\n\r\nThe functions F,L, and D are dependent on the 'compression\r\nfactor', 1 through 4, and are defined as follows:\r\n\r\nFor compression factor 1:\r\n    L(X) equals the lower 7 bits of X.\r\n    F(X) equals 2 if X equals 127 otherwise F(X) equals 3.\r\n    D(X,Y) equals the (upper 1 bit of X) * 256 + Y + 1.\r\nFor compression factor 2:\r\n    L(X) equals the lower 6 bits of X.\r\n    F(X) equals 2 if X equals 63 otherwise F(X) equals 3.\r\n    D(X,Y) equals the (upper 2 bits of X) * 256 + Y + 1.\r\nFor compression factor 3:\r\n    L(X) equals the lower 5 bits of X.\r\n    F(X) equals 2 if X equals 31 otherwise F(X) equals 3.\r\n    D(X,Y) equals the (upper 3 bits of X) * 256 + Y + 1.\r\nFor compression factor 4:\r\n    L(X) equals the lower 4 bits of X.\r\n    F(X) equals 2 if X equals 15 otherwise F(X) equals 3.\r\n    D(X,Y) equals the (upper 4 bits of X) * 256 + Y + 1.\r\n\r\nImploding - Method 6\r\n--------------------\r\n\r\nThe Imploding algorithm is actually a combination of two distinct\r\nalgorithms.  The first algorithm compresses repeated byte\r\nsequences using a sliding dictionary.  The second algorithm is\r\nused to compress the encoding of the sliding dictionary output,\r\nusing multiple Shannon-Fano trees.\r\n\r\nThe Imploding algorithm can use a 4K or 8K sliding dictionary\r\nsize. The dictionary size used can be determined by bit 1 in the\r\ngeneral purpose flag word; a 0 bit indicates a 4K dictionary\r\nwhile a 1 bit indicates an 8K dictionary.\r\n\r\nThe Shannon-Fano trees are stored at the start of the compressed\r\nfile. The number of trees stored is defined by bit 2 in the\r\ngeneral purpose flag word; a 0 bit indicates two trees stored, a\r\n1 bit indicates three trees are stored.  If 3 trees are stored,\r\nthe first Shannon-Fano tree represents the encoding of the\r\nLiteral characters, the second tree represents the encoding of\r\nthe Length information, the third represents the encoding of the\r\nDistance information.  When 2 Shannon-Fano trees are stored, the\r\nLength tree is stored first, followed by the Distance tree.\r\n\r\nThe Literal Shannon-Fano tree, if present is used to represent\r\nthe entire ASCII character set, and contains 256 values.  This\r\ntree is used to compress any data not compressed by the sliding\r\ndictionary algorithm.  When this tree is present, the Minimum\r\nMatch Length for the sliding dictionary is 3.  If this tree is\r\nnot present, the Minimum Match Length is 2.\r\n\r\nThe Length Shannon-Fano tree is used to compress the Length part\r\nof the (length,distance) pairs from the sliding dictionary\r\noutput.  The Length tree contains 64 values, ranging from the\r\nMinimum Match Length, to 63 plus the Minimum Match Length.\r\n\r\nThe Distance Shannon-Fano tree is used to compress the Distance\r\npart of the (length,distance) pairs from the sliding dictionary\r\noutput. The Distance tree contains 64 values, ranging from 0 to\r\n63, representing the upper 6 bits of the distance value.  The\r\ndistance values themselves will be between 0 and the sliding\r\ndictionary size, either 4K or 8K.\r\n\r\nThe Shannon-Fano trees themselves are stored in a compressed\r\nformat. The first byte of the tree data represents the number of\r\nbytes of data representing the (compressed) Shannon-Fano tree\r\nminus 1.  The remaining bytes represent the Shannon-Fano tree\r\ndata encoded as:\r\n\r\n    High 4 bits: Number of values at this bit length + 1. (1 - 16)\r\n    Low  4 bits: Bit Length needed to represent value + 1. (1 - 16)\r\n\r\nThe Shannon-Fano codes can be constructed from the bit lengths\r\nusing the following algorithm:\r\n\r\n1)  Sort the Bit Lengths in ascending order, while retaining the\r\n    order of the original lengths stored in the file.\r\n\r\n2)  Generate the Shannon-Fano trees:\r\n\r\n    Code <- 0\r\n    CodeIncrement <- 0\r\n    LastBitLength <- 0\r\n    i <- number of Shannon-Fano codes - 1   (either 255 or 63)\r\n\r\n    loop while i >= 0\r\n        Code = Code + CodeIncrement\r\n        if BitLength(i) <> LastBitLength then\r\n            LastBitLength=BitLength(i)\r\n            CodeIncrement = 1 shifted left (16 - LastBitLength)\r\n        ShannonCode(i) = Code\r\n        i <- i - 1\r\n    end loop\r\n\r\n3)  Reverse the order of all the bits in the above ShannonCode()\r\n    vector, so that the most significant bit becomes the least\r\n    significant bit.  For example, the value 0x1234 (hex) would\r\n    become 0x2C48 (hex).\r\n\r\n4)  Restore the order of Shannon-Fano codes as originally stored\r\n    within the file.\r\n\r\nExample:\r\n\r\n    This example will show the encoding of a Shannon-Fano tree\r\n    of size 8.  Notice that the actual Shannon-Fano trees used\r\n    for Imploding are either 64 or 256 entries in size.\r\n\r\nExample:   0x02, 0x42, 0x01, 0x13\r\n\r\n    The first byte indicates 3 values in this table.  Decoding the\r\n    bytes:\r\n            0x42 = 5 codes of 3 bits long\r\n            0x01 = 1 code  of 2 bits long\r\n            0x13 = 2 codes of 4 bits long\r\n\r\n    This would generate the original bit length array of:\r\n    (3, 3, 3, 3, 3, 2, 4, 4)\r\n\r\n    There are 8 codes in this table for the values 0 thru 7.  Using \r\n    the algorithm to obtain the Shannon-Fano codes produces:\r\n\r\n                                  Reversed     Order     Original\r\nVal  Sorted   Constructed Code      Value     Restored    Length\r\n---  ------   -----------------   --------    --------    ------\r\n0:     2      1100000000000000        11       101          3\r\n1:     3      1010000000000000       101       001          3\r\n2:     3      1000000000000000       001       110          3\r\n3:     3      0110000000000000       110       010          3\r\n4:     3      0100000000000000       010       100          3\r\n5:     3      0010000000000000       100        11          2\r\n6:     4      0001000000000000      1000      1000          4\r\n7:     4      0000000000000000      0000      0000          4\r\n\r\nThe values in the Val, Order Restored and Original Length columns\r\nnow represent the Shannon-Fano encoding tree that can be used for\r\ndecoding the Shannon-Fano encoded data.  How to parse the\r\nvariable length Shannon-Fano values from the data stream is beyond\r\nthe scope of this document.  (See the references listed at the end of\r\nthis document for more information.)  However, traditional decoding\r\nschemes used for Huffman variable length decoding, such as the\r\nGreenlaw algorithm, can be successfully applied.\r\n\r\nThe compressed data stream begins immediately after the\r\ncompressed Shannon-Fano data.  The compressed data stream can be\r\ninterpreted as follows:\r\n\r\nloop until done\r\n    read 1 bit from input stream.\r\n\r\n    if this bit is non-zero then       (encoded data is literal data)\r\n        if Literal Shannon-Fano tree is present\r\n            read and decode character using Literal Shannon-Fano tree.\r\n        otherwise\r\n            read 8 bits from input stream.\r\n        copy character to the output stream.\r\n    otherwise              (encoded data is sliding dictionary match)\r\n        if 8K dictionary size\r\n            read 7 bits for offset Distance (lower 7 bits of offset).\r\n        otherwise\r\n            read 6 bits for offset Distance (lower 6 bits of offset).\r\n\r\n        using the Distance Shannon-Fano tree, read and decode the\r\n          upper 6 bits of the Distance value.\r\n\r\n        using the Length Shannon-Fano tree, read and decode\r\n          the Length value.\r\n\r\n        Length <- Length + Minimum Match Length\r\n\r\n        if Length = 63 + Minimum Match Length\r\n            read 8 bits from the input stream,\r\n            add this value to Length.\r\n\r\n        move backwards Distance+1 bytes in the output stream, and\r\n        copy Length characters from this position to the output\r\n        stream.  (if this position is before the start of the output\r\n        stream, then assume that all the data before the start of\r\n        the output stream is filled with zeros).\r\nend loop\r\n\r\nTokenizing - Method 7\r\n---------------------\r\n\r\nThis method is not used by PKZIP.\r\n\r\nDeflating - Method 8\r\n--------------------\r\n\r\nThe Deflate algorithm is similar to the Implode algorithm using\r\na sliding dictionary of up to 32K with secondary compression\r\nfrom Huffman/Shannon-Fano codes.\r\n\r\nThe compressed data is stored in blocks with a header describing\r\nthe block and the Huffman codes used in the data block.  The header\r\nformat is as follows:\r\n\r\n   Bit 0: Last Block bit     This bit is set to 1 if this is the last\r\n                             compressed block in the data.\r\n   Bits 1-2: Block type\r\n      00 (0) - Block is stored - All stored data is byte aligned.\r\n               Skip bits until next byte, then next word = block \r\n               length, followed by the ones compliment of the block\r\n               length word. Remaining data in block is the stored \r\n               data.\r\n\r\n      01 (1) - Use fixed Huffman codes for literal and distance codes.\r\n               Lit Code    Bits             Dist Code   Bits\r\n               ---------   ----             ---------   ----\r\n                 0 - 143    8                 0 - 31      5\r\n               144 - 255    9\r\n               256 - 279    7\r\n               280 - 287    8\r\n\r\n               Literal codes 286-287 and distance codes 30-31 are \r\n               never used but participate in the huffman construction.\r\n\r\n      10 (2) - Dynamic Huffman codes.  (See expanding Huffman codes)\r\n\r\n      11 (3) - Reserved - Flag a \"Error in compressed data\" if seen.\r\n\r\nExpanding Huffman Codes\r\n-----------------------\r\nIf the data block is stored with dynamic Huffman codes, the Huffman\r\ncodes are sent in the following compressed format:\r\n\r\n   5 Bits: # of Literal codes sent - 256 (256 - 286)\r\n           All other codes are never sent.\r\n   5 Bits: # of Dist codes - 1           (1 - 32)\r\n   4 Bits: # of Bit Length codes - 3     (3 - 19)\r\n\r\nThe Huffman codes are sent as bit lengths and the codes are built as\r\ndescribed in the implode algorithm.  The bit lengths themselves are\r\ncompressed with Huffman codes.  There are 19 bit length codes:\r\n\r\n   0 - 15: Represent bit lengths of 0 - 15\r\n       16: Copy the previous bit length 3 - 6 times.\r\n           The next 2 bits indicate repeat length (0 = 3, ... ,3 = 6)\r\n              Example:  Codes 8, 16 (+2 bits 11), 16 (+2 bits 10) will\r\n                        expand to 12 bit lengths of 8 (1 + 6 + 5)\r\n       17: Repeat a bit length of 0 for 3 - 10 times. (3 bits of length)\r\n       18: Repeat a bit length of 0 for 11 - 138 times (7 bits of length)\r\n\r\nThe lengths of the bit length codes are sent packed 3 bits per value\r\n(0 - 7) in the following order:\r\n\r\n   16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15\r\n\r\nThe Huffman codes should be built as described in the Implode algorithm\r\nexcept codes are assigned starting at the shortest bit length, i.e. the\r\nshortest code should be all 0's rather than all 1's.  Also, codes with\r\na bit length of zero do not participate in the tree construction.  The\r\ncodes are then used to decode the bit lengths for the literal and \r\ndistance tables.\r\n\r\nThe bit lengths for the literal tables are sent first with the number\r\nof entries sent described by the 5 bits sent earlier.  There are up\r\nto 286 literal characters; the first 256 represent the respective 8\r\nbit character, code 256 represents the End-Of-Block code, the remaining\r\n29 codes represent copy lengths of 3 thru 258.  There are up to 30\r\ndistance codes representing distances from 1 thru 32k as described\r\nbelow.\r\n\r\n                             Length Codes\r\n                             ------------\r\n      Extra             Extra              Extra              Extra\r\n Code Bits Length  Code Bits Lengths  Code Bits Lengths  Code Bits Length(s)\r\n ---- ---- ------  ---- ---- -------  ---- ---- -------  ---- ---- ---------\r\n  257   0     3     265   1   11,12    273   3   35-42    281   5  131-162\r\n  258   0     4     266   1   13,14    274   3   43-50    282   5  163-194\r\n  259   0     5     267   1   15,16    275   3   51-58    283   5  195-226\r\n  260   0     6     268   1   17,18    276   3   59-66    284   5  227-257\r\n  261   0     7     269   2   19-22    277   4   67-82    285   0    258\r\n  262   0     8     270   2   23-26    278   4   83-98\r\n  263   0     9     271   2   27-30    279   4   99-114\r\n  264   0    10     272   2   31-34    280   4  115-130\r\n\r\n                            Distance Codes\r\n                            --------------\r\n      Extra           Extra             Extra               Extra\r\n Code Bits Dist  Code Bits  Dist   Code Bits Distance  Code Bits Distance\r\n ---- ---- ----  ---- ---- ------  ---- ---- --------  ---- ---- --------\r\n   0   0    1      8   3   17-24    16    7  257-384    24   11  4097-6144\r\n   1   0    2      9   3   25-32    17    7  385-512    25   11  6145-8192\r\n   2   0    3     10   4   33-48    18    8  513-768    26   12  8193-12288\r\n   3   0    4     11   4   49-64    19    8  769-1024   27   12 12289-16384\r\n   4   1   5,6    12   5   65-96    20    9 1025-1536   28   13 16385-24576\r\n   5   1   7,8    13   5   97-128   21    9 1537-2048   29   13 24577-32768\r\n   6   2   9-12   14   6  129-192   22   10 2049-3072\r\n   7   2  13-16   15   6  193-256   23   10 3073-4096\r\n\r\nThe compressed data stream begins immediately after the\r\ncompressed header data.  The compressed data stream can be\r\ninterpreted as follows:\r\n\r\ndo\r\n   read header from input stream.\r\n\r\n   if stored block\r\n      skip bits until byte aligned\r\n      read count and 1's compliment of count\r\n      copy count bytes data block\r\n   otherwise\r\n      loop until end of block code sent\r\n         decode literal character from input stream\r\n         if literal < 256\r\n            copy character to the output stream\r\n         otherwise\r\n            if literal = end of block\r\n               break from loop\r\n            otherwise\r\n               decode distance from input stream\r\n\r\n               move backwards distance bytes in the output stream, and\r\n               copy length characters from this position to the output\r\n               stream.\r\n      end loop\r\nwhile not last block\r\n\r\nif data descriptor exists\r\n   skip bits until byte aligned\r\n   read crc and sizes\r\nendif\r\n\r\nEnhanced Deflating - Method 9\r\n-----------------------------\r\n\r\nThe Enhanced Deflating algorithm is similar to Deflate but\r\nuses a sliding dictionary of up to 64K. Deflate64(tm) is supported\r\nby the Deflate extractor. \r\n\r\nBZIP2 - Method 12\r\n-----------------\r\n\r\nBZIP2 is an open-source data compression algorithm developed by \r\nJulian Seward.  Information and source code for this algorithm\r\ncan be found on the internet.\r\n\r\nLZMA - Method 14 (EFS)\r\n----------------------\r\n\r\nLZMA is a block-oriented, general purpose data compression algorithm  \r\ndeveloped and maintained by Igor Pavlov.  It is a derivative of LZ77\r\nthat utilizes Markov chains and a range coder.  Information and \r\nsource code for this algorithm can be found on the internet.  Consult \r\nwith the author of this algorithm for information on terms or \r\nrestrictions on use.\r\n\r\nSupport for LZMA within the ZIP format is defined as follows:   \r\n\r\nThe Compression method field within the ZIP Local and Central \r\nHeader records will be set to the value 14 to indicate data was\r\ncompressed using LZMA. \r\n\r\nThe Version needed to extract field within the ZIP Local and \r\nCentral Header records will be set to 6.3 to indicate the \r\nminimum ZIP format version supporting this feature.\r\n\r\nFile data compressed using the LZMA algorithm must be placed \r\nimmediately following the Local Header for the file.  If a \r\nstandard ZIP encryption header is required, it will follow \r\nthe Local Header and will precede the LZMA compressed file \r\ndata segment.  The location of LZMA compressed data segment \r\nwithin the ZIP format will be as shown:\r\n\r\n    [local header file 1]\r\n    [encryption header file 1]\r\n    [LZMA compressed data segment for file 1]\r\n    [data descriptor 1]\r\n    [local header file 2]\r\n\r\nThe encryption header and data descriptor records may\r\nbe conditionally present.  The LZMA Compressed Data Segment \r\nwill consist of an LZMA Properties Header followed by the \r\nLZMA Compressed Data as shown:\r\n\r\n    [LZMA properties header for file 1]\r\n    [LZMA compressed data for file 1]\r\n\r\nThe LZMA Compressed Data will be stored as provided by the \r\nLZMA compression library.  Compressed size, uncompressed \r\nsize and other file characteristics about the file being \r\ncompressed must be stored in standard ZIP storage format.\r\n\r\nThe LZMA Properties Header will store specific data required to \r\ndecompress the LZMA compressed Data.  This data is set by the \r\nLZMA compression engine using the function WriteCoderProperties() \r\nas documented within the LZMA SDK. \r\n \r\nStorage fields for the property information within the LZMA \r\nProperties Header are as follows:\r\n\r\n     LZMA Version Information 2 bytes\r\n     LZMA Properties Size 2 bytes\r\n     LZMA Properties Data variable, defined by \"LZMA Properties Size\"\r\n\r\nLZMA Version Information - this field identifies which version of \r\n     the LZMA SDK was used to compress a file.  The first byte will \r\n     store the major version number of the LZMA SDK and the second \r\n     byte will store the minor number.  \r\n\r\nLZMA Properties Size - this field defines the size of the remaining \r\n     property data.  Typically this size should be determined by the \r\n     version of the SDK.  This size field is included as a convenience\r\n     and to help avoid any ambiguity should it arise in the future due\r\n     to changes in this compression algorithm. \r\n\r\nLZMA Property Data - this variable sized field records the required \r\n     values for the decompressor as defined by the LZMA SDK.  The \r\n     data stored in this field should be obtained using the \r\n     WriteCoderProperties() in the version of the SDK defined by \r\n     the \"LZMA Version Information\" field.  \r\n\r\nThe layout of the \"LZMA Properties Data\" field is a function of the\r\nLZMA compression algorithm.  It is possible that this layout may be\r\nchanged by the author over time.  The data layout in version 4.32 \r\nof the LZMA SDK defines a 5 byte array that uses 4 bytes to store \r\nthe dictionary size in little-endian order. This is preceded by a \r\nsingle packed byte as the first element of the array that contains\r\nthe following fields:\r\n\r\n     PosStateBits\r\n     LiteralPosStateBits\r\n     LiteralContextBits\r\n\r\nRefer to the LZMA documentation for a more detailed explanation of \r\nthese fields.  \r\n\r\nData compressed with method 14, LZMA, may include an end-of-stream\r\n(EOS) marker ending the compressed data stream.  This marker is not\r\nrequired, but its use is highly recommended to facilitate processing\r\nand implementers should include the EOS marker whenever possible.\r\nWhen the EOS marker is used, general purpose bit 1 must be set.  If\r\ngeneral purpose bit 1 is not set, the EOS marker is not present.\r\n\r\nWavPack - Method 97\r\n-------------------\r\n\r\nInformation describing the use of compression method 97 is \r\nprovided by WinZIP International, LLC.  This method relies on the\r\nopen source WavPack audio compression utility developed by David Bryant.  \r\nInformation on WavPack is available at www.wavpack.com.  Please consult \r\nwith the author of this algorithm for information on terms and \r\nrestrictions on use.\r\n\r\nWavPack data for a file begins immediately after the end of the\r\nlocal header data.  This data is the output from WavPack compression\r\nroutines.  Within the ZIP file, the use of WavPack compression is\r\nindicated by setting the compression method field to a value of 97 \r\nin both the local header and the central directory header.  The Version \r\nneeded to extract and version made by fields use the same values as are \r\nused for data compressed using the Deflate algorithm.\r\n\r\nAn implementation note for storing digital sample data when using \r\nWavPack compression within ZIP files is that all of the bytes of\r\nthe sample data should be compressed.  This includes any unused\r\nbits up to the byte boundary.  An example is a 2 byte sample that\r\nuses only 12 bits for the sample data with 4 unused bits.  If only\r\n12 bits are passed as the sample size to the WavPack routines, the 4 \r\nunused bits will be set to 0 on extraction regardless of their original \r\nstate.  To avoid this, the full 16 bits of the sample data size\r\nshould be provided. \r\n\r\nPPMd - Method 98\r\n----------------\r\n\r\nPPMd is a data compression algorithm developed by Dmitry Shkarin\r\nwhich includes a carryless rangecoder developed by Dmitry Subbotin.\r\nThis algorithm is based on predictive phrase matching on multiple\r\norder contexts.  Information and source code for this algorithm\r\ncan be found on the internet. Consult with the author of this\r\nalgorithm for information on terms or restrictions on use.\r\n\r\nSupport for PPMd within the ZIP format currently is provided only \r\nfor version I, revision 1 of the algorithm.  Storage requirements\r\nfor using this algorithm are as follows:\r\n\r\nParameters needed to control the algorithm are stored in the two\r\nbytes immediately preceding the compressed data.  These bytes are\r\nused to store the following fields:\r\n\r\nModel order - sets the maximum model order, default is 8, possible\r\n              values are from 2 to 16 inclusive\r\n\r\nSub-allocator size - sets the size of sub-allocator in MB, default is 50,\r\n            possible values are from 1MB to 256MB inclusive\r\n\r\nModel restoration method - sets the method used to restart context\r\n            model at memory insufficiency, values are:\r\n\r\n            0 - restarts model from scratch - default\r\n            1 - cut off model - decreases performance by as much as 2x\r\n            2 - freeze context tree - not recommended\r\n\r\nAn example for packing these fields into the 2 byte storage field is\r\nillustrated below.  These values are stored in Intel low-byte/high-byte\r\norder.\r\n\r\nwPPMd = (Model order - 1) + \r\n        ((Sub-allocator size - 1) << 4) + \r\n        (Model restoration method << 12)\r\n\r\n\r\nVII. Traditional PKWARE Encryption\r\n----------------------------------\r\n\r\nThe following information discusses the decryption steps\r\nrequired to support traditional PKWARE encryption.  This\r\nform of encryption is considered weak by today's standards\r\nand its use is recommended only for situations with\r\nlow security needs or for compatibility with older .ZIP \r\napplications.\r\n\r\nDecryption\r\n----------\r\n\r\nPKWARE is grateful to Mr. Roger Schlafly for his expert contribution \r\ntowards the development of PKWARE's traditional encryption.\r\n\r\nPKZIP encrypts the compressed data stream.  Encrypted files must\r\nbe decrypted before they can be extracted.\r\n\r\nEach encrypted file has an extra 12 bytes stored at the start of\r\nthe data area defining the encryption header for that file.  The\r\nencryption header is originally set to random values, and then\r\nitself encrypted, using three, 32-bit keys.  The key values are\r\ninitialized using the supplied encryption password.  After each byte\r\nis encrypted, the keys are then updated using pseudo-random number\r\ngeneration techniques in combination with the same CRC-32 algorithm\r\nused in PKZIP and described elsewhere in this document.\r\n\r\nThe following is the basic steps required to decrypt a file:\r\n\r\n1) Initialize the three 32-bit keys with the password.\r\n2) Read and decrypt the 12-byte encryption header, further\r\n   initializing the encryption keys.\r\n3) Read and decrypt the compressed data stream using the\r\n   encryption keys.\r\n\r\nStep 1 - Initializing the encryption keys\r\n-----------------------------------------\r\n\r\nKey(0) <- 305419896\r\nKey(1) <- 591751049\r\nKey(2) <- 878082192\r\n\r\nloop for i <- 0 to length(password)-1\r\n    update_keys(password(i))\r\nend loop\r\n\r\nWhere update_keys() is defined as:\r\n\r\nupdate_keys(char):\r\n  Key(0) <- crc32(key(0),char)\r\n  Key(1) <- Key(1) + (Key(0) & 000000ffH)\r\n  Key(1) <- Key(1) * 134775813 + 1\r\n  Key(2) <- crc32(key(2),key(1) >> 24)\r\nend update_keys\r\n\r\nWhere crc32(old_crc,char) is a routine that given a CRC value and a\r\ncharacter, returns an updated CRC value after applying the CRC-32\r\nalgorithm described elsewhere in this document.\r\n\r\nStep 2 - Decrypting the encryption header\r\n-----------------------------------------\r\n\r\nThe purpose of this step is to further initialize the encryption\r\nkeys, based on random data, to render a plaintext attack on the\r\ndata ineffective.\r\n\r\nRead the 12-byte encryption header into Buffer, in locations\r\nBuffer(0) thru Buffer(11).\r\n\r\nloop for i <- 0 to 11\r\n    C <- buffer(i) ^ decrypt_byte()\r\n    update_keys(C)\r\n    buffer(i) <- C\r\nend loop\r\n\r\nWhere decrypt_byte() is defined as:\r\n\r\nunsigned char decrypt_byte()\r\n    local unsigned short temp\r\n    temp <- Key(2) | 2\r\n    decrypt_byte <- (temp * (temp ^ 1)) >> 8\r\nend decrypt_byte\r\n\r\nAfter the header is decrypted,  the last 1 or 2 bytes in Buffer\r\nshould be the high-order word/byte of the CRC for the file being\r\ndecrypted, stored in Intel low-byte/high-byte order.  Versions of\r\nPKZIP prior to 2.0 used a 2 byte CRC check; a 1 byte CRC check is\r\nused on versions after 2.0.  This can be used to test if the password\r\nsupplied is correct or not.\r\n\r\nStep 3 - Decrypting the compressed data stream\r\n----------------------------------------------\r\n\r\nThe compressed data stream can be decrypted as follows:\r\n\r\nloop until done\r\n    read a character into C\r\n    Temp <- C ^ decrypt_byte()\r\n    update_keys(temp)\r\n    output Temp\r\nend loop\r\n\r\n\r\nVIII. Strong Encryption Specification\r\n-------------------------------------\r\n\r\nThe Strong Encryption technology defined in this specification is \r\ncovered under a pending patent application. The use or implementation\r\nin a product of certain technological aspects set forth in the current\r\nAPPNOTE, including those with regard to strong encryption, patching, \r\nor extended tape operations requires a license from PKWARE. Portions\r\nof this Strong Encryption technology are available for use at no charge.\r\nContact PKWARE for licensing terms and conditions. Refer to section II\r\nof this APPNOTE (Contacting PKWARE) for information on how to \r\ncontact PKWARE. \r\n\r\nVersion 5.x of this specification introduced support for strong \r\nencryption algorithms.  These algorithms can be used with either \r\na password or an X.509v3 digital certificate to encrypt each file. \r\nThis format specification supports either password or certificate \r\nbased encryption to meet the security needs of today, to enable \r\ninteroperability between users within both PKI and non-PKI \r\nenvironments, and to ensure interoperability between different \r\ncomputing platforms that are running a ZIP program.  \r\n\r\nPassword based encryption is the most common form of encryption \r\npeople are familiar with.  However, inherent weaknesses with \r\npasswords (e.g. susceptibility to dictionary/brute force attack) \r\nas well as password management and support issues make certificate \r\nbased encryption a more secure and scalable option.  Industry \r\nefforts and support are defining and moving towards more advanced \r\nsecurity solutions built around X.509v3 digital certificates and \r\nPublic Key Infrastructures(PKI) because of the greater scalability, \r\nadministrative options, and more robust security over traditional \r\npassword based encryption. \r\n\r\nMost standard encryption algorithms are supported with this\r\nspecification. Reference implementations for many of these \r\nalgorithms are available from either commercial or open source \r\ndistributors.  Readily available cryptographic toolkits make\r\nimplementation of the encryption features straight-forward.  \r\nThis document is not intended to provide a treatise on data \r\nencryption principles or theory.  Its purpose is to document the \r\ndata structures required for implementing interoperable data \r\nencryption within the .ZIP format.  It is strongly recommended that \r\nyou have a good understanding of data encryption before reading \r\nfurther.\r\n\r\nThe algorithms introduced in Version 5.0 of this specification \r\ninclude:\r\n\r\n    RC2 40 bit, 64 bit, and 128 bit\r\n    RC4 40 bit, 64 bit, and 128 bit\r\n    DES\r\n    3DES 112 bit and 168 bit\r\n  \r\nVersion 5.1 adds support for the following:\r\n\r\n    AES 128 bit, 192 bit, and 256 bit\r\n\r\n\r\nVersion 6.1 introduces encryption data changes to support \r\ninteroperability with Smartcard and USB Token certificate storage \r\nmethods which do not support the OAEP strengthening standard.\r\n\r\nVersion 6.2 introduces support for encrypting metadata by compressing \r\nand encrypting the central directory data structure to reduce information \r\nleakage.   Information leakage can occur in legacy ZIP applications \r\nthrough exposure of information about a file even though that file is \r\nstored encrypted.  The information exposed consists of file \r\ncharacteristics stored within the records and fields defined by this \r\nspecification.  This includes data such as a files name, its original \r\nsize, timestamp and CRC32 value. \r\n\r\nVersion 6.3 introduces support for encrypting data using the Blowfish\r\nand Twofish algorithms.  These are symmetric block ciphers developed \r\nby Bruce Schneier.  Blowfish supports using a variable length key from \r\n32 to 448 bits.  Block size is 64 bits.  Implementations should use 16\r\nrounds and the only mode supported within ZIP files is CBC. Twofish \r\nsupports key sizes 128, 192 and 256 bits.  Block size is 128 bits.  \r\nImplementations should use 16 rounds and the only mode supported within\r\nZIP files is CBC.  Information and source code for both Blowfish and \r\nTwofish algorithms can be found on the internet.  Consult with the author\r\nof these algorithms for information on terms or restrictions on use.\r\n\r\nCentral Directory Encryption provides greater protection against \r\ninformation leakage by encrypting the Central Directory structure and \r\nby masking key values that are replicated in the unencrypted Local \r\nHeader.   ZIP compatible programs that cannot interpret an encrypted \r\nCentral Directory structure cannot rely on the data in the corresponding \r\nLocal Header for decompression information.  \r\n\r\nExtra Field records that may contain information about a file that should \r\nnot be exposed should not be stored in the Local Header and should only \r\nbe written to the Central Directory where they can be encrypted.  This \r\ndesign currently does not support streaming.  Information in the End of \r\nCentral Directory record, the Zip64 End of Central Directory Locator, \r\nand the Zip64 End of Central Directory records are not encrypted.  Access \r\nto view data on files within a ZIP file with an encrypted Central Directory\r\nrequires the appropriate password or private key for decryption prior to \r\nviewing any files, or any information about the files, in the archive.  \r\n\r\nOlder ZIP compatible programs not familiar with the Central Directory \r\nEncryption feature will no longer be able to recognize the Central \r\nDirectory and may assume the ZIP file is corrupt.  Programs that \r\nattempt streaming access using Local Headers will see invalid \r\ninformation for each file.  Central Directory Encryption need not be \r\nused for every ZIP file.  Its use is recommended for greater security.  \r\nZIP files not using Central Directory Encryption should operate as \r\nin the past. \r\n\r\nThis strong encryption feature specification is intended to provide for \r\nscalable, cross-platform encryption needs ranging from simple password\r\nencryption to authenticated public/private key encryption.  \r\n\r\nEncryption provides data confidentiality and privacy.  It is \r\nrecommended that you combine X.509 digital signing with encryption \r\nto add authentication and non-repudiation.\r\n\r\n\r\nSingle Password Symmetric Encryption Method:\r\n-------------------------------------------\r\n\r\nThe Single Password Symmetric Encryption Method using strong \r\nencryption algorithms operates similarly to the traditional \r\nPKWARE encryption defined in this format.  Additional data \r\nstructures are added to support the processing needs of the \r\nstrong algorithms.\r\n\r\nThe Strong Encryption data structures are:\r\n\r\n1. General Purpose Bits - Bits 0 and 6 of the General Purpose bit \r\nflag in both local and central header records.  Both bits set \r\nindicates strong encryption.  Bit 13, when set indicates the Central\r\nDirectory is encrypted and that selected fields in the Local Header\r\nare masked to hide their actual value.\r\n\r\n\r\n2. Extra Field 0x0017 in central header only.\r\n\r\n     Fields to consider in this record are:\r\n\r\n     Format - the data format identifier for this record.  The only\r\n     value allowed at this time is the integer value 2.\r\n\r\n     AlgId - integer identifier of the encryption algorithm from the\r\n     following range\r\n\r\n         0x6601 - DES\r\n         0x6602 - RC2 (version needed to extract < 5.2)\r\n         0x6603 - 3DES 168\r\n         0x6609 - 3DES 112\r\n         0x660E - AES 128 \r\n         0x660F - AES 192 \r\n         0x6610 - AES 256 \r\n         0x6702 - RC2 (version needed to extract >= 5.2)\r\n         0x6720 - Blowfish\r\n         0x6721 - Twofish\r\n         0x6801 - RC4\r\n         0xFFFF - Unknown algorithm\r\n\r\n     Bitlen - Explicit bit length of key\r\n\r\n         32 - 448 bits\r\n   \r\n     Flags - Processing flags needed for decryption\r\n\r\n         0x0001 - Password is required to decrypt\r\n         0x0002 - Certificates only\r\n         0x0003 - Password or certificate required to decrypt\r\n\r\n         Values > 0x0003 reserved for certificate processing\r\n\r\n\r\n3. Decryption header record preceding compressed file data.\r\n\r\n         -Decryption Header:\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          IVSize    2 bytes  Size of initialization vector (IV)\r\n          IVData    IVSize   Initialization vector for this file\r\n          Size      4 bytes  Size of remaining decryption header data\r\n          Format    2 bytes  Format definition for this record\r\n          AlgID     2 bytes  Encryption algorithm identifier\r\n          Bitlen    2 bytes  Bit length of encryption key\r\n          Flags     2 bytes  Processing flags\r\n          ErdSize   2 bytes  Size of Encrypted Random Data\r\n          ErdData   ErdSize  Encrypted Random Data\r\n          Reserved1 4 bytes  Reserved certificate processing data\r\n          Reserved2 (var)    Reserved for certificate processing data\r\n          VSize     2 bytes  Size of password validation data\r\n          VData     VSize-4  Password validation data\r\n          VCRC32    4 bytes  Standard ZIP CRC32 of password validation data\r\n\r\n     IVData - The size of the IV should match the algorithm block size.\r\n              The IVData can be completely random data.  If the size of\r\n              the randomly generated data does not match the block size\r\n              it should be complemented with zero's or truncated as\r\n              necessary.  If IVSize is 0,then IV = CRC32 + Uncompressed\r\n              File Size (as a 64 bit little-endian, unsigned integer value).\r\n\r\n     Format - the data format identifier for this record.  The only\r\n     value allowed at this time is the integer value 3.\r\n\r\n     AlgId - integer identifier of the encryption algorithm from the\r\n     following range\r\n\r\n         0x6601 - DES\r\n         0x6602 - RC2 (version needed to extract < 5.2)\r\n         0x6603 - 3DES 168\r\n         0x6609 - 3DES 112\r\n         0x660E - AES 128 \r\n         0x660F - AES 192 \r\n         0x6610 - AES 256 \r\n         0x6702 - RC2 (version needed to extract >= 5.2)\r\n         0x6720 - Blowfish\r\n         0x6721 - Twofish\r\n         0x6801 - RC4\r\n         0xFFFF - Unknown algorithm\r\n\r\n     Bitlen - Explicit bit length of key\r\n\r\n         32 - 448 bits\r\n   \r\n     Flags - Processing flags needed for decryption\r\n\r\n         0x0001 - Password is required to decrypt\r\n         0x0002 - Certificates only\r\n         0x0003 - Password or certificate required to decrypt\r\n\r\n         Values > 0x0003 reserved for certificate processing\r\n\r\n     ErdData - Encrypted random data is used to store random data that\r\n               is used to generate a file session key for encrypting \r\n               each file.  SHA1 is used to calculate hash data used to \r\n               derive keys.  File session keys are derived from a master \r\n               session key generated from the user-supplied password.\r\n               If the Flags field in the decryption header contains \r\n               the value 0x4000, then the ErdData field must be \r\n               decrypted using 3DES. If the value 0x4000 is not set,\r\n               then the ErdData field must be decrypted using AlgId.\r\n\r\n\r\n     Reserved1 - Reserved for certificate processing, if value is\r\n               zero, then Reserved2 data is absent.  See the explanation\r\n               under the Certificate Processing Method for details on\r\n               this data structure.\r\n\r\n     Reserved2 - If present, the size of the Reserved2 data structure \r\n               is located by skipping the first 4 bytes of this field \r\n               and using the next 2 bytes as the remaining size.  See\r\n               the explanation under the Certificate Processing Method\r\n               for details on this data structure.\r\n\r\n     VSize - This size value will always include the 4 bytes of the\r\n             VCRC32 data and will be greater than 4 bytes.\r\n\r\n     VData - Random data for password validation.  This data is VSize\r\n             in length and VSize must be a multiple of the encryption\r\n             block size.  VCRC32 is a checksum value of VData.  \r\n             VData and VCRC32 are stored encrypted and start the\r\n             stream of encrypted data for a file.\r\n\r\n\r\n4. Useful Tips\r\n\r\nStrong Encryption is always applied to a file after compression. The\r\nblock oriented algorithms all operate in Cypher Block Chaining (CBC) \r\nmode.  The block size used for AES encryption is 16.  All other block\r\nalgorithms use a block size of 8.  Two ID's are defined for RC2 to \r\naccount for a discrepancy found in the implementation of the RC2\r\nalgorithm in the cryptographic library on Windows XP SP1 and all \r\nearlier versions of Windows.  It is recommended that zero length files\r\nnot be encrypted, however programs should be prepared to extract them\r\nif they are found within a ZIP file.\r\n\r\nA pseudo-code representation of the encryption process is as follows:\r\n\r\nPassword = GetUserPassword()\r\nMasterSessionKey = DeriveKey(SHA1(Password)) \r\nRD = CryptographicStrengthRandomData() \r\nFor Each File\r\n   IV = CryptographicStrengthRandomData() \r\n   VData = CryptographicStrengthRandomData()\r\n   VCRC32 = CRC32(VData)\r\n   FileSessionKey = DeriveKey(SHA1(IV + RD) \r\n   ErdData = Encrypt(RD,MasterSessionKey,IV) \r\n   Encrypt(VData + VCRC32 + FileData, FileSessionKey,IV)\r\nDone\r\n\r\nThe function names and parameter requirements will depend on\r\nthe choice of the cryptographic toolkit selected.  Almost any\r\ntoolkit supporting the reference implementations for each\r\nalgorithm can be used.  The RSA BSAFE(r), OpenSSL, and Microsoft\r\nCryptoAPI libraries are all known to work well.  \r\n\r\n\r\nSingle Password - Central Directory Encryption:\r\n-----------------------------------------------\r\n\r\nCentral Directory Encryption is achieved within the .ZIP format by \r\nencrypting the Central Directory structure.  This encapsulates the metadata \r\nmost often used for processing .ZIP files.  Additional metadata is stored for \r\nredundancy in the Local Header for each file.  The process of concealing \r\nmetadata by encrypting the Central Directory does not protect the data within \r\nthe Local Header.  To avoid information leakage from the exposed metadata \r\nin the Local Header, the fields containing information about a file are masked.  \r\n\r\nLocal Header:\r\n\r\nMasking replaces the true content of the fields for a file in the Local \r\nHeader with false information.  When masked, the Local Header is not \r\nsuitable for streaming access and the options for data recovery of damaged\r\narchives is reduced.  Extra Data fields that may contain confidential\r\ndata should not be stored within the Local Header.  The value set into\r\nthe Version needed to extract field should be the correct value needed to\r\nextract the file without regard to Central Directory Encryption. The fields \r\nwithin the Local Header targeted for masking when the Central Directory is \r\nencrypted are:\r\n\r\n        Field Name                     Mask Value\r\n        ------------------             ---------------------------\r\n        compression method              0\r\n        last mod file time              0\r\n        last mod file date              0\r\n        crc-32                          0\r\n        compressed size                 0\r\n        uncompressed size               0\r\n        file name (variable size)       Base 16 value from the\r\n                                        range 1 - 0xFFFFFFFFFFFFFFFF\r\n                                        represented as a string whose\r\n                                        size will be set into the\r\n                                        file name length field\r\n\r\nThe Base 16 value assigned as a masked file name is simply a sequentially\r\nincremented value for each file starting with 1 for the first file.  \r\nModifications to a ZIP file may cause different values to be stored for \r\neach file.  For compatibility, the file name field in the Local Header \r\nshould never be left blank.  As of Version 6.2 of this specification, \r\nthe Compression Method and Compressed Size fields are not yet masked.\r\nFields having a value of 0xFFFF or 0xFFFFFFFF for the ZIP64 format\r\nshould not be masked.  \r\n\r\nEncrypting the Central Directory:\r\n\r\nEncryption of the Central Directory does not include encryption of the \r\nCentral Directory Signature data, the Zip64 End of Central Directory\r\nrecord, the Zip64 End of Central Directory Locator, or the End\r\nof Central Directory record.  The ZIP file comment data is never\r\nencrypted.\r\n\r\nBefore encrypting the Central Directory, it may optionally be compressed.\r\nCompression is not required, but for storage efficiency it is assumed\r\nthis structure will be compressed before encrypting.  Similarly, this \r\nspecification supports compressing the Central Directory without\r\nrequiring that it also be encrypted.  Early implementations of this\r\nfeature will assume the encryption method applied to files matches the \r\nencryption applied to the Central Directory.\r\n\r\nEncryption of the Central Directory is done in a manner similar to\r\nthat of file encryption.  The encrypted data is preceded by a \r\ndecryption header.  The decryption header is known as the Archive\r\nDecryption Header.  The fields of this record are identical to\r\nthe decryption header preceding each encrypted file.  The location\r\nof the Archive Decryption Header is determined by the value in the\r\nStart of the Central Directory field in the Zip64 End of Central\r\nDirectory record.  When the Central Directory is encrypted, the\r\nZip64 End of Central Directory record will always be present.\r\n\r\nThe layout of the Zip64 End of Central Directory record for all\r\nversions starting with 6.2 of this specification will follow the\r\nVersion 2 format.  The Version 2 format is as follows:\r\n\r\nThe leading fixed size fields within the Version 1 format for this\r\nrecord remain unchanged.  The record signature for both Version 1 \r\nand Version 2 will be 0x06064b50.  Immediately following the last\r\nbyte of the field known as the Offset of Start of Central \r\nDirectory With Respect to the Starting Disk Number will begin the \r\nnew fields defining Version 2 of this record.  \r\n\r\nNew fields for Version 2:\r\n\r\nNote: all fields stored in Intel low-byte/high-byte order.\r\n\r\n          Value                 Size       Description\r\n          -----                 ----       -----------\r\n          Compression Method    2 bytes    Method used to compress the\r\n                                           Central Directory\r\n          Compressed Size       8 bytes    Size of the compressed data\r\n          Original   Size       8 bytes    Original uncompressed size\r\n          AlgId                 2 bytes    Encryption algorithm ID\r\n          BitLen                2 bytes    Encryption key length\r\n          Flags                 2 bytes    Encryption flags\r\n          HashID                2 bytes    Hash algorithm identifier\r\n          Hash Length           2 bytes    Length of hash data\r\n          Hash Data             (variable) Hash data\r\n\r\nThe Compression Method accepts the same range of values as the \r\ncorresponding field in the Central Header.\r\n\r\nThe Compressed Size and Original Size values will not include the\r\ndata of the Central Directory Signature which is compressed or\r\nencrypted.\r\n\r\nThe AlgId, BitLen, and Flags fields accept the same range of values\r\nthe corresponding fields within the 0x0017 record. \r\n\r\nHash ID identifies the algorithm used to hash the Central Directory \r\ndata.  This data does not have to be hashed, in which case the\r\nvalues for both the HashID and Hash Length will be 0.  Possible \r\nvalues for HashID are:\r\n\r\n      Value         Algorithm\r\n     ------         ---------\r\n     0x0000          none\r\n     0x0001          CRC32\r\n     0x8003          MD5\r\n     0x8004          SHA1\r\n     0x8007          RIPEMD160\r\n     0x800C          SHA256\r\n     0x800D          SHA384\r\n     0x800E          SHA512\r\n\r\nWhen the Central Directory data is signed, the same hash algorithm\r\nused to hash the Central Directory for signing should be used.\r\nThis is recommended for processing efficiency, however, it is \r\npermissible for any of the above algorithms to be used independent \r\nof the signing process.\r\n\r\nThe Hash Data will contain the hash data for the Central Directory.\r\nThe length of this data will vary depending on the algorithm used.\r\n\r\nThe Version Needed to Extract should be set to 62.\r\n\r\nThe value for the Total Number of Entries on the Current Disk will\r\nbe 0.  These records will no longer support random access when\r\nencrypting the Central Directory.\r\n\r\nWhen the Central Directory is compressed and/or encrypted, the\r\nEnd of Central Directory record will store the value 0xFFFFFFFF\r\nas the value for the Total Number of Entries in the Central\r\nDirectory.  The value stored in the Total Number of Entries in\r\nthe Central Directory on this Disk field will be 0.  The actual\r\nvalues will be stored in the equivalent fields of the Zip64\r\nEnd of Central Directory record.\r\n\r\nDecrypting and decompressing the Central Directory is accomplished\r\nin the same manner as decrypting and decompressing a file.\r\n\r\nCertificate Processing Method:\r\n-----------------------------\r\n\r\nThe Certificate Processing Method of for ZIP file encryption \r\ndefines the following additional data fields:\r\n\r\n1. Certificate Flag Values\r\n\r\nAdditional processing flags that can be present in the Flags field of both \r\nthe 0x0017 field of the central directory Extra Field and the Decryption \r\nheader record preceding compressed file data are:\r\n\r\n         0x0007 - reserved for future use\r\n         0x000F - reserved for future use\r\n         0x0100 - Indicates non-OAEP key wrapping was used.  If this\r\n                  this field is set, the version needed to extract must\r\n                  be at least 61.  This means OAEP key wrapping is not\r\n                  used when generating a Master Session Key using\r\n                  ErdData.\r\n         0x4000 - ErdData must be decrypted using 3DES-168, otherwise use the\r\n                  same algorithm used for encrypting the file contents.\r\n         0x8000 - reserved for future use\r\n\r\n\r\n2. CertData - Extra Field 0x0017 record certificate data structure\r\n\r\nThe data structure used to store certificate data within the section\r\nof the Extra Field defined by the CertData field of the 0x0017\r\nrecord are as shown:\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          RCount    4 bytes  Number of recipients.  \r\n          HashAlg   2 bytes  Hash algorithm identifier\r\n          HSize     2 bytes  Hash size\r\n          SRList    (var)    Simple list of recipients hashed public keys\r\n\r\n          \r\n     RCount    This defines the number intended recipients whose \r\n               public keys were used for encryption.  This identifies\r\n               the number of elements in the SRList.\r\n\r\n     HashAlg   This defines the hash algorithm used to calculate\r\n               the public key hash of each public key used\r\n               for encryption. This field currently supports\r\n               only the following value for SHA-1\r\n\r\n               0x8004 - SHA1\r\n\r\n     HSize     This defines the size of a hashed public key.\r\n\r\n     SRList    This is a variable length list of the hashed \r\n               public keys for each intended recipient.  Each \r\n               element in this list is HSize.  The total size of \r\n               SRList is determined using RCount * HSize.\r\n\r\n\r\n3. Reserved1 - Certificate Decryption Header Reserved1 Data:\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          RCount    4 bytes  Number of recipients.  \r\n          \r\n     RCount    This defines the number intended recipients whose \r\n               public keys were used for encryption.  This defines\r\n               the number of elements in the REList field defined below.\r\n\r\n\r\n4. Reserved2 - Certificate Decryption Header Reserved2 Data Structures:\r\n\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          HashAlg   2 bytes  Hash algorithm identifier\r\n          HSize     2 bytes  Hash size\r\n          REList    (var)    List of recipient data elements\r\n\r\n\r\n     HashAlg   This defines the hash algorithm used to calculate\r\n               the public key hash of each public key used\r\n               for encryption. This field currently supports\r\n               only the following value for SHA-1\r\n\r\n               0x8004 - SHA1\r\n\r\n     HSize     This defines the size of a hashed public key\r\n               defined in REHData.\r\n\r\n     REList    This is a variable length of list of recipient data.  \r\n               Each element in this list consists of a Recipient\r\n               Element data structure as follows:\r\n\r\n\r\n    Recipient Element (REList) Data Structure:\r\n\r\n          Value     Size     Description\r\n          -----     ----     -----------\r\n          RESize    2 bytes  Size of REHData + REKData\r\n          REHData   HSize    Hash of recipients public key\r\n          REKData   (var)    Simple key blob\r\n\r\n\r\n     RESize    This defines the size of an individual REList \r\n               element.  This value is the combined size of the\r\n               REHData field + REKData field.  REHData is defined by\r\n               HSize.  REKData is variable and can be calculated\r\n               for each REList element using RESize and HSize.\r\n\r\n     REHData   Hashed public key for this recipient.\r\n\r\n     REKData   Simple Key Blob.  The format of this data structure\r\n               is identical to that defined in the Microsoft\r\n               CryptoAPI and generated using the CryptExportKey()\r\n               function.  The version of the Simple Key Blob\r\n               supported at this time is 0x02 as defined by\r\n               Microsoft.\r\n\r\nCertificate Processing - Central Directory Encryption:\r\n------------------------------------------------------\r\n\r\nCentral Directory Encryption using Digital Certificates will \r\noperate in a manner similar to that of Single Password Central\r\nDirectory Encryption.  This record will only be present when there \r\nis data to place into it.  Currently, data is placed into this\r\nrecord when digital certificates are used for either encrypting \r\nor signing the files within a ZIP file.  When only password \r\nencryption is used with no certificate encryption or digital \r\nsigning, this record is not currently needed. When present, this \r\nrecord will appear before the start of the actual Central Directory \r\ndata structure and will be located immediately after the Archive \r\nDecryption Header if the Central Directory is encrypted.\r\n\r\nThe Archive Extra Data record will be used to store the following\r\ninformation.  Additional data may be added in future versions.\r\n\r\nExtra Data Fields:\r\n\r\n0x0014 - PKCS#7 Store for X.509 Certificates\r\n0x0016 - X.509 Certificate ID and Signature for central directory\r\n0x0019 - PKCS#7 Encryption Recipient Certificate List\r\n\r\nThe 0x0014 and 0x0016 Extra Data records that otherwise would be \r\nlocated in the first record of the Central Directory for digital \r\ncertificate processing. When encrypting or compressing the Central \r\nDirectory, the 0x0014 and 0x0016 records must be located in the \r\nArchive Extra Data record and they should not remain in the first \r\nCentral Directory record.  The Archive Extra Data record will also \r\nbe used to store the 0x0019 data. \r\n\r\nWhen present, the size of the Archive Extra Data record will be\r\nincluded in the size of the Central Directory.  The data of the\r\nArchive Extra Data record will also be compressed and encrypted\r\nalong with the Central Directory data structure.\r\n\r\nCertificate Processing Differences:\r\n\r\nThe Certificate Processing Method of encryption differs from the\r\nSingle Password Symmetric Encryption Method as follows.  Instead\r\nof using a user-defined password to generate a master session key,\r\ncryptographically random data is used.  The key material is then\r\nwrapped using standard key-wrapping techniques.  This key material\r\nis wrapped using the public key of each recipient that will need\r\nto decrypt the file using their corresponding private key.\r\n\r\nThis specification currently assumes digital certificates will follow\r\nthe X.509 V3 format for 1024 bit and higher RSA format digital\r\ncertificates.  Implementation of this Certificate Processing Method\r\nrequires supporting logic for key access and management.  This logic\r\nis outside the scope of this specification.\r\n\r\nOAEP Processing with Certificate-based Encryption:\r\n\r\nOAEP stands for Optimal Asymmetric Encryption Padding.  It is a\r\nstrengthening technique used for small encoded items such as decryption\r\nkeys.  This is commonly applied in cryptographic key-wrapping techniques\r\nand is supported by PKCS #1.  Versions 5.0 and 6.0 of this specification \r\nwere designed to support OAEP key-wrapping for certificate-based \r\ndecryption keys for additional security.  \r\n\r\nSupport for private keys stored on Smartcards or Tokens introduced\r\na conflict with this OAEP logic.  Most card and token products do \r\nnot support the additional strengthening applied to OAEP key-wrapped \r\ndata.  In order to resolve this conflict, versions 6.1 and above of this \r\nspecification will no longer support OAEP when encrypting using \r\ndigital certificates. \r\n\r\nVersions of PKZIP available during initial development of the \r\ncertificate processing method set a value of 61 into the \r\nversion needed to extract field for a file.  This indicates that \r\nnon-OAEP key wrapping is used.  This affects certificate encryption \r\nonly, and password encryption functions should not be affected by \r\nthis value.  This means values of 61 may be found on files encrypted\r\nwith certificates only, or on files encrypted with both password\r\nencryption and certificate encryption.  Files encrypted with both\r\nmethods can safely be decrypted using the password methods documented.\r\n\r\nIX. Change Process\r\n------------------\r\n\r\nIn order for the .ZIP file format to remain a viable definition, this\r\nspecification should be considered as open for periodic review and\r\nrevision.  Although this format was originally designed with a \r\ncertain level of extensibility, not all changes in technology\r\n(present or future) were or will be necessarily considered in its\r\ndesign.  If your application requires new definitions to the\r\nextensible sections in this format, or if you would like to \r\nsubmit new data structures, please forward your request to\r\nzipformat@pkware.com.  All submissions will be reviewed by the\r\nZIP File Specification Committee for possible inclusion into\r\nfuture versions of this specification.  Periodic revisions\r\nto this specification will be published to ensure interoperability. \r\nWe encourage comments and feedback that may help improve clarity \r\nor content.\r\n\r\nX. Incorporating PKWARE Proprietary Technology into Your Product\r\n----------------------------------------------------------------\r\n\r\nPKWARE is committed to the interoperability and advancement of the\r\n.ZIP format.  PKWARE offers a free license for certain technological\r\naspects described above under certain restrictions and conditions.\r\nHowever, the use or implementation in a product of certain technological\r\naspects set forth in the current APPNOTE, including those with regard to\r\nstrong encryption, patching, or extended tape operations requires a \r\nlicense from PKWARE.  Please contact PKWARE with regard to acquiring\r\na license.\r\n\r\nXI. Acknowledgements\r\n---------------------\r\n\r\nIn addition to the above mentioned contributors to PKZIP and PKUNZIP,\r\nI would like to extend special thanks to Robert Mahoney for suggesting\r\nthe extension .ZIP for this software.\r\n\r\nXII. References\r\n---------------\r\n\r\n    Fiala, Edward R., and Greene, Daniel H., \"Data compression with\r\n       finite windows\",  Communications of the ACM, Volume 32, Number 4,\r\n       April 1989, pages 490-505.\r\n\r\n    Held, Gilbert, \"Data Compression, Techniques and Applications,\r\n       Hardware and Software Considerations\", John Wiley & Sons, 1987.\r\n\r\n    Huffman, D.A., \"A method for the construction of minimum-redundancy\r\n       codes\", Proceedings of the IRE, Volume 40, Number 9, September 1952,\r\n       pages 1098-1101.\r\n\r\n    Nelson, Mark, \"LZW Data Compression\", Dr. Dobbs Journal, Volume 14,\r\n       Number 10, October 1989, pages 29-37.\r\n\r\n    Nelson, Mark, \"The Data Compression Book\",  M&T Books, 1991.\r\n\r\n    Storer, James A., \"Data Compression, Methods and Theory\",\r\n       Computer Science Press, 1988\r\n\r\n    Welch, Terry, \"A Technique for High-Performance Data Compression\",\r\n       IEEE Computer, Volume 17, Number 6, June 1984, pages 8-19.\r\n\r\n    Ziv, J. and Lempel, A., \"A universal algorithm for sequential data\r\n       compression\", Communications of the ACM, Volume 30, Number 6,\r\n       June 1987, pages 520-540.\r\n\r\n    Ziv, J. and Lempel, A., \"Compression of individual sequences via\r\n       variable-rate coding\", IEEE Transactions on Information Theory,\r\n       Volume 24, Number 5, September 1978, pages 530-536.\r\n\r\n\r\nAPPENDIX A - AS/400 Extra Field (0x0065) Attribute Definitions\r\n--------------------------------------------------------------\r\n\r\nField Definition Structure:\r\n\r\n   a. field length including length             2 bytes\r\n   b. field code                                2 bytes\r\n   c. data                                      x bytes\r\n\r\nField Code  Description\r\n   4001     Source type i.e. CLP etc\r\n   4002     The text description of the library \r\n   4003     The text description of the file\r\n   4004     The text description of the member\r\n   4005     x'F0' or 0 is PF-DTA,  x'F1' or 1 is PF_SRC\r\n   4007     Database Type Code                  1 byte\r\n   4008     Database file and fields definition\r\n   4009     GZIP file type                      2 bytes\r\n   400B     IFS code page                       2 bytes\r\n   400C     IFS Creation Time                   4 bytes\r\n   400D     IFS Access Time                     4 bytes\r\n   400E     IFS Modification time               4 bytes\r\n   005C     Length of the records in the file   2 bytes\r\n   0068     GZIP two words                      8 bytes\r\n\r\nAPPENDIX B - z/OS Extra Field (0x0065) Attribute Definitions\r\n------------------------------------------------------------\r\n\r\nField Definition Structure:\r\n\r\n   a. field length including length             2 bytes\r\n   b. field code                                2 bytes\r\n   c. data                                      x bytes\r\n\r\nField Code  Description\r\n   0001     File Type                           2 bytes \r\n   0002     NonVSAM Record Format               1 byte\r\n   0003     Reserved\t\t\r\n   0004     NonVSAM Block Size                  2 bytes Big Endian\r\n   0005     Primary Space Allocation            3 bytes Big Endian\r\n   0006     Secondary Space Allocation          3 bytes Big Endian\r\n   0007     Space Allocation Type1 byte flag\t\t\r\n   0008     Modification Date                   Retired with PKZIP 5.0 +\r\n   0009     Expiration Date                     Retired with PKZIP 5.0 +\r\n   000A     PDS Directory Block Allocation      3 bytes Big Endian binary value\r\n   000B     NonVSAM Volume List                 variable\t\t\r\n   000C     UNIT Reference                      Retired with PKZIP 5.0 +\r\n   000D     DF/SMS Management Class             8 bytes EBCDIC Text Value\r\n   000E     DF/SMS Storage Class                8 bytes EBCDIC Text Value\r\n   000F     DF/SMS Data Class                   8 bytes EBCDIC Text Value\r\n   0010     PDS/PDSE Member Info.               30 bytes\t\r\n   0011     VSAM sub-filetype                   2 bytes\t\t\r\n   0012     VSAM LRECL                          13 bytes EBCDIC \"(num_avg num_max)\"\r\n   0013     VSAM Cluster Name                   Retired with PKZIP 5.0 +\r\n   0014     VSAM KSDS Key Information           13 bytes EBCDIC \"(num_length num_position)\"\r\n   0015     VSAM Average LRECL                  5 bytes EBCDIC num_value padded with blanks\r\n   0016     VSAM Maximum LRECL                  5 bytes EBCDIC num_value padded with blanks\r\n   0017     VSAM KSDS Key Length                5 bytes EBCDIC num_value padded with blanks\r\n   0018     VSAM KSDS Key Position              5 bytes EBCDIC num_value padded with blanks\r\n   0019     VSAM Data Name                      1-44 bytes EBCDIC text string\r\n   001A     VSAM KSDS Index Name                1-44 bytes EBCDIC text string\r\n   001B     VSAM Catalog Name                   1-44 bytes EBCDIC text string\r\n   001C     VSAM Data Space Type                9 bytes EBCDIC text string\r\n   001D     VSAM Data Space Primary             9 bytes EBCDIC num_value left-justified\r\n   001E     VSAM Data Space Secondary           9 bytes EBCDIC num_value left-justified\r\n   001F     VSAM Data Volume List               variable EBCDIC text list of 6-character Volume IDs\r\n   0020     VSAM Data Buffer Space              8 bytes EBCDIC num_value left-justified\r\n   0021     VSAM Data CISIZE                    5 bytes EBCDIC num_value left-justified\r\n   0022     VSAM Erase Flag                     1 byte flag\t\t\r\n   0023     VSAM Free CI %                      3 bytes EBCDIC num_value left-justified\r\n   0024     VSAM Free CA %                      3 bytes EBCDIC num_value left-justified\r\n   0025     VSAM Index Volume List              variable EBCDIC text list of 6-character Volume IDs\r\n   0026     VSAM Ordered Flag                   1 byte flag\t\t\r\n   0027     VSAM REUSE Flag                     1 byte flag\t\t\r\n   0028     VSAM SPANNED Flag                   1 byte flag\t\t\r\n   0029     VSAM Recovery Flag                  1 byte flag\t\t\r\n   002A     VSAM  WRITECHK  Flag                1 byte flag\t\t\r\n   002B     VSAM Cluster/Data SHROPTS           3 bytes EBCDIC \"n,y\"\t\r\n   002C     VSAM Index SHROPTS                  3 bytes EBCDIC \"n,y\"\t\r\n   002D     VSAM Index Space Type               9 bytes EBCDIC text string\r\n   002E     VSAM Index Space Primary            9 bytes EBCDIC num_value left-justified\r\n   002F     VSAM Index Space Secondary          9 bytes EBCDIC num_value left-justified\r\n   0030     VSAM Index CISIZE                   5 bytes EBCDIC num_value left-justified\r\n   0031     VSAM Index IMBED                    1 byte flag\t\t\r\n   0032     VSAM Index Ordered Flag             1 byte flag\t\t\r\n   0033     VSAM REPLICATE Flag                 1 byte flag\t\t\r\n   0034     VSAM Index REUSE Flag               1 byte flag\t\t\r\n   0035     VSAM Index WRITECHK Flag            1 byte flag Retired with PKZIP 5.0 +\r\n   0036     VSAM Owner                          8 bytes EBCDIC text string\r\n   0037     VSAM Index Owner                    8 bytes EBCDIC text string\r\n   0038     Reserved\r\n   0039     Reserved\r\n   003A     Reserved\r\n   003B     Reserved\r\n   003C     Reserved\r\n   003D     Reserved\r\n   003E     Reserved\r\n   003F     Reserved\r\n   0040     Reserved\r\n   0041     Reserved\r\n   0042     Reserved\r\n   0043     Reserved\r\n   0044     Reserved\r\n   0045     Reserved\r\n   0046     Reserved\r\n   0047     Reserved\r\n   0048     Reserved\r\n   0049     Reserved\r\n   004A     Reserved\r\n   004B     Reserved\r\n   004C     Reserved\r\n   004D     Reserved\r\n   004E     Reserved\r\n   004F     Reserved\r\n   0050     Reserved\r\n   0051     Reserved\r\n   0052     Reserved\r\n   0053     Reserved\r\n   0054     Reserved\r\n   0055     Reserved\r\n   0056     Reserved\r\n   0057     Reserved\r\n   0058     PDS/PDSE Member TTR Info.           6 bytes  Big Endian\r\n   0059     PDS 1st LMOD Text TTR               3 bytes  Big Endian\r\n   005A     PDS LMOD EP Rec #                   4 bytes  Big Endian\r\n   005B     Reserved\r\n   005C     Max Length of records               2 bytes  Big Endian\r\n   005D     PDSE Flag                           1 byte flag\r\n   005E     Reserved\r\n   005F     Reserved\r\n   0060     Reserved\r\n   0061     Reserved\r\n   0062     Reserved\r\n   0063     Reserved\r\n   0064     Reserved\r\n   0065     Last Date Referenced                4 bytes  Packed Hex \"yyyymmdd\"\r\n   0066     Date Created                        4 bytes  Packed Hex \"yyyymmdd\"\r\n   0068     GZIP two words                      8 bytes\r\n   0071     Extended NOTE Location              12 bytes Big Endian\r\n   0072     Archive device UNIT                 6 bytes  EBCDIC\r\n   0073     Archive 1st Volume                  6 bytes  EBCDIC\r\n   0074     Archive 1st VOL File Seq#           2 bytes  Binary\r\n\r\nAPPENDIX C - Zip64 Extensible Data Sector Mappings (EFS)\r\n--------------------------------------------------------\r\n\r\n          -Z390   Extra Field:\r\n\r\n          The following is the general layout of the attributes for the \r\n          ZIP 64 \"extra\" block for extended tape operations. Portions of \r\n          this extended tape processing technology is covered under a \r\n          pending patent application. The use or implementation in a \r\n          product of certain technological aspects set forth in the \r\n          current APPNOTE, including those with regard to strong encryption,\r\n          patching or extended tape operations, requires a license from\r\n          PKWARE.  Please contact PKWARE with regard to acquiring a license. \r\n \r\n\r\n          Note: some fields stored in Big Endian format.  All text is \r\n\t  in EBCDIC format unless otherwise specified.\r\n\r\n          Value       Size          Description\r\n          -----       ----          -----------\r\n  (Z390)  0x0065      2 bytes       Tag for this \"extra\" block type\r\n          Size        4 bytes       Size for the following data block\r\n          Tag         4 bytes       EBCDIC \"Z390\"\r\n          Length71    2 bytes       Big Endian\r\n          Subcode71   2 bytes       Enote type code\r\n          FMEPos      1 byte\r\n          Length72    2 bytes       Big Endian\r\n          Subcode72   2 bytes       Unit type code\r\n          Unit        1 byte        Unit\r\n          Length73    2 bytes       Big Endian\r\n          Subcode73   2 bytes       Volume1 type code\r\n          FirstVol    1 byte        Volume\r\n          Length74    2 bytes       Big Endian\r\n          Subcode74   2 bytes       FirstVol file sequence\r\n          FileSeq     2 bytes       Sequence \r\n\r\nAPPENDIX D - Language Encoding (EFS)\r\n------------------------------------\r\n\r\nThe ZIP format has historically supported only the original IBM PC character \r\nencoding set, commonly referred to as IBM Code Page 437.  This limits storing \r\nfile name characters to only those within the original MS-DOS range of values \r\nand does not properly support file names in other character encodings, or \r\nlanguages. To address this limitation, this specification will support the \r\nfollowing change. \r\n\r\nIf general purpose bit 11 is unset, the file name and comment should conform \r\nto the original ZIP character encoding.  If general purpose bit 11 is set, the \r\nfilename and comment must support The Unicode Standard, Version 4.1.0 or \r\ngreater using the character encoding form defined by the UTF-8 storage \r\nspecification.  The Unicode Standard is published by the The Unicode\r\nConsortium (www.unicode.org).  UTF-8 encoded data stored within ZIP files \r\nis expected to not include a byte order mark (BOM). \r\n\r\nApplications may choose to supplement this file name storage through the use \r\nof the 0x0008 Extra Field.  Storage for this optional field is currently \r\nundefined, however it will be used to allow storing extended information \r\non source or target encoding that may further assist applications with file \r\nname, or file content encoding tasks.  Please contact PKWARE with any\r\nrequirements on how this field should be used.\r\n\r\nThe 0x0008 Extra Field storage may be used with either setting for general \r\npurpose bit 11.  Examples of the intended usage for this field is to store \r\nwhether \"modified-UTF-8\" (JAVA) is used, or UTF-8-MAC.  Similarly, other \r\ncommonly used character encoding (code page) designations can be indicated \r\nthrough this field.  Formalized values for use of the 0x0008 record remain \r\nundefined at this time.  The definition for the layout of the 0x0008 field\r\nwill be published when available.  Use of the 0x0008 Extra Field provides\r\nfor storing data within a ZIP file in an encoding other than IBM Code\r\nPage 437 or UTF-8.\r\n\r\nGeneral purpose bit 11 will not imply any encoding of file content or\r\npassword.  Values defining character encoding for file content or \r\npassword must be stored within the 0x0008 Extended Language Encoding \r\nExtra Field.\r\n\r\nEd Gordon of the Info-ZIP group has defined a pair of \"extra field\" records \r\nthat can be used to store UTF-8 file name and file comment fields.  These\r\nrecords can be used for cases when the general purpose bit 11 method\r\nfor storing UTF-8 data in the standard file name and comment fields is\r\nnot desirable.  A common case for this alternate method is if backward\r\ncompatibility with older programs is required.\r\n\r\nDefinitions for the record structure of these fields are included above \r\nin the section on 3rd party mappings for \"extra field\" records.  These\r\nrecords are identified by Header ID's 0x6375 (Info-ZIP Unicode Comment \r\nExtra Field) and 0x7075 (Info-ZIP Unicode Path Extra Field).\r\n\r\nThe choice of which storage method to use when writing a ZIP file is left\r\nto the implementation.  Developers should expect that a ZIP file may \r\ncontain either method and should provide support for reading data in \r\neither format. Use of general purpose bit 11 reduces storage requirements \r\nfor file name data by not requiring additional \"extra field\" data for\r\neach file, but can result in older ZIP programs not being able to extract \r\nfiles.  Use of the 0x6375 and 0x7075 records will result in a ZIP file \r\nthat should always be readable by older ZIP programs, but requires more \r\nstorage per file to write file name and/or file comment fields.\r\n\r\n \r\n\r\n\r\n"
  },
  {
    "path": "docs/ZIP spec.txt",
    "content": "Here are the notes I made while working through the ZIP file specification.\n\nFor each file:\n\n        local file header signature     4 bytes  (0x04034b50)\n        version needed to extract       2 bytes\n        general purpose bit flag        2 bytes\n        compression method              2 bytes\n        last mod file time              2 bytes\n        last mod file date              2 bytes\n        crc-32                          4 bytes\n        compressed size                 4 bytes\n        uncompressed size               4 bytes\n        file name length                2 bytes\n        extra field length              2 bytes\n\n|sig |v |g |c |t |d |crc |csz |usz |n |x |\n PK.. ## 00 00 ?? ?? xxxx ???? ???? ?? 00\n<file name><file data>\n\nCentral directory:\n\n        central file header signature   4 bytes  (0x02014b50)\n        version made by                 2 bytes\n        version needed to extract       2 bytes  *\n        general purpose bit flag        2 bytes  *\n        compression method              2 bytes  *\n        last mod file time              2 bytes  *\n        last mod file date              2 bytes  *\n        crc-32                          4 bytes  *\n        compressed size                 4 bytes  *\n        uncompressed size               4 bytes  *\n        file name length                2 bytes  *\n        extra field length              2 bytes  *\n        file comment length             2 bytes\n        disk number start               2 bytes\n        internal file attributes        2 bytes\n        external file attributes        4 bytes\n        relative offset of local header 4 bytes\n\n        file name (variable size)\n        extra field (variable size)\n        file comment (variable size)\n\n|sig |vm|vx|g |c |d |t |crc |csz |usz |n |x |cm|dn|ia|xa  |roff|\n PK.. ## ## 00 00 ?? ?? xxxx ???? ???? ?? 00 00 00 00 xxxx ????\n\nEnd of central directory:\n\n        end of central dir signature    4 bytes  (0x06054b50)\n        number of this disk             2 bytes\n        number of the disk with the\n        start of the central directory  2 bytes\n        total number of entries in the\n        central directory on this disk  2 bytes\n        total number of entries in\n        the central directory           2 bytes\n        size of the central directory   4 bytes\n        offset of start of central\n        directory with respect to\n        the starting disk number        4 bytes\n        .ZIP file comment length        2 bytes\n        .ZIP file comment       (variable size)\n\n|sig |n1|n2|e |ne|size|off |cm|\n PK.. 00 00 ?? ?? ???? ???? 00\n"
  },
  {
    "path": "docs/references.txt",
    "content": "Zip format\n----------\nhttp://www.pkware.com/support/zip-application-note\nhttp://www.xxcopy.com/xxcopy06.htm\n\nData URL\n--------\nhttps://developer.mozilla.org/en/The_data_URL_scheme\nhttp://msdn.microsoft.com/en-us/library/cc848897(VS.85).aspx\nhttp://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/\n\nhttp://www.motobit.com/util/base64-decoder-encoder.asp\n\nSaving files\n------------\nhttp://msdn.microsoft.com/en-us/library/ms536676(VS.85).aspx\nhttp://msdn.microsoft.com/en-us/library/ms536419(VS.85).aspx\nhttp://msdn.microsoft.com/en-us/library/ms537418(VS.85).aspx\n"
  },
  {
    "path": "documentation/.eslintrc.js",
    "content": "\"use strict\";\n\nmodule.exports = {\n    globals: {\n        $: false,\n        jQuery: false,\n        JSZip: false,\n        JSZipUtils: false,\n        // From FileSaver.js\n        saveAs: false,\n    },\n};\n"
  },
  {
    "path": "documentation/_layouts/default.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <meta name=\"description\" content=\"Create .zip files using JavaScript. Provides a simple API to place any content generated by JavaScript into a .zip file for your users.\" />\n    <title>{{page.title}}</title>\n\n    <!--\n    Any version of jQuery will do (it's just to write some examples), this one\n    happens to be available in our tests.\n    -->\n    <script type=\"text/javascript\" src=\"{{site.baseurl}}/test/jquery-1.8.3.min.js\"></script>\n\n    <!-- Latest compiled and minified CSS -->\n    <link rel=\"stylesheet\" href=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css\">\n\n    <!-- Optional theme -->\n    <link rel=\"stylesheet\" href=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css\">\n\n    <!-- Latest compiled and minified JavaScript -->\n    <script src=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js\"></script>\n\n    <link rel=\"stylesheet\" href=\"{{site.baseurl}}/documentation/css/pygments.css\">\n    <link rel=\"stylesheet\" href=\"{{site.baseurl}}/documentation/css/main.css\">\n\n    <script type=\"text/javascript\" src=\"{{site.baseurl}}/dist/jszip.js\"></script>\n\n    <script type=\"text/javascript\" src=\"//stuk.github.io/jszip-utils/dist/jszip-utils.js\"></script>\n    <!--\n    Mandatory in IE 6, 7, 8 and 9.\n    -->\n    <!--[if IE]>\n    <script type=\"text/javascript\" src=\"//stuk.github.io/jszip-utils/dist/jszip-utils-ie.js\"></script>\n    <![endif]-->\n\n\n    <script type=\"text/javascript\" src=\"{{site.baseurl}}/vendor/FileSaver.js\"></script>\n  </head>\n  <body>\n    <div class=\"container\">\n      <div class=\"navbar navbar-default\" role=\"navigation\">\n        <div class=\"container-fluid\">\n          <div class=\"navbar-header\">\n            <a class=\"navbar-brand\" href=\"{{site.baseurl}}/\"><strong>JS</strong>Zip</a>\n          </div>\n          <ul class=\"nav navbar-nav\">\n            <li {% if page.section == \"api\" %}class=\"active\"{% endif %}>\n              <a href=\"{{site.baseurl}}/documentation/api_jszip.html\">API</a>\n            </li>\n            <li {% if page.section == \"example\" %}class=\"active\"{% endif %}>\n              <a href=\"{{site.baseurl}}/documentation/examples.html\">How to / examples</a>\n            </li>\n            <li {% if page.section == \"limitations\" %}class=\"active\"{% endif %}>\n              <a href=\"{{site.baseurl}}/documentation/limitations.html\">Performances / limitations</a>\n            </li>\n          </ul>\n          <ul class=\"nav navbar-nav navbar-right\">\n            <li>\n              <a href=\"https://github.com/Stuk/jszip\">JSZip on Github</a>\n            </li>\n          </ul>\n        </div>\n      </div>\n      {% if page.section and page.fullpage != true %}\n      <div class=\"row\">\n        <nav class=\"col-md-3\">\n        {% case page.section %}\n        {% when \"main\" %}\n        <h4>JSZip users:</h4>\n        <ul class=\"nav\">\n              <li><a href=\"{{site.baseurl}}/\">Installation</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/faq.html\">FAQ</a></li>\n              <li><a href=\"{{site.baseurl}}/CHANGES.html\">Changelog</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/upgrade_guide.html\">Upgrade guide</a></li>\n              <li><a href=\"https://github.com/Stuk/jszip/issues\">Bug tracker</a></li>\n              <li><a href=\"{{site.baseurl}}/sponsors\">Sponsorship</a></li>\n            </ul>\n        <h4>JSZip developers:</h4>\n        <ul class=\"nav\">\n              <li><a href=\"{{site.baseurl}}/documentation/contributing.html\">How to contribute</a></li>\n              <li><a href=\"https://github.com/Stuk/jszip/graphs/contributors\">Contributors</a></li>\n        </ul>\n        {% when \"api\" %}\n        <ul class=\"nav\">\n          <li><a href=\"{{site.baseurl}}/documentation/api_jszip.html\">JSZip</a>\n            <ul>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/constructor.html\">new JSZip() or JSZip()</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/file_name.html\">JSZip#file(name)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/file_regex.html\">JSZip#file(regex)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/file_data.html\">JSZip#file(name, data [,options])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/folder_name.html\">JSZip#folder(name)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/folder_regex.html\">JSZip#folder(regex)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/for_each.html\">JSZip#forEach(callback)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/filter.html\">JSZip#filter(predicate)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/remove.html\">JSZip#remove(name)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/generate_async.html\">JSZip#generateAsync(options[, onUpdate])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/generate_node_stream.html\">JSZip#generateNodeStream(options[, onUpdate])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/generate_internal_stream.html\">JSZip#generateInternalStream(options)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/load_async.html\">JSZip#loadAsync(data [, options])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/load_async_object.html\">JSZip.loadAsync(data [, options])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/support.html\">JSZip.support</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/external.html\">JSZip.external</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_jszip/version.html\">JSZip.version</a></li>\n            </ul>\n          </li>\n          <li><a href=\"{{site.baseurl}}/documentation/api_zipobject.html\">ZipObject</a></li>\n            <ul>\n              <li><a href=\"{{site.baseurl}}/documentation/api_zipobject/async.html\">ZipObject#async(type[, onUpdate])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_zipobject/node_stream.html\">ZipObject#nodeStream(type[, onUpdate])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_zipobject/internal_stream.html\">ZipObject#internalStream(type)</a></li>\n            </ul>\n          <li><a href=\"{{site.baseurl}}/documentation/api_streamhelper.html\">StreamHelper</a>\n            <ul>\n              <li><a href=\"{{site.baseurl}}/documentation/api_streamhelper/on.html\">StreamHelper#on(event, callback)</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_streamhelper/accumulate.html\">StreamHelper#accumulate( [updateCallback])</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_streamhelper/resume.html\">StreamHelper#resume()</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/api_streamhelper/pause.html\">StreamHelper#pause()</a></li>\n            </ul>\n          </li>\n        </ul>\n        {% when \"example\" %}\n        <h4>How to ...</h4>\n        <ul class=\"nav\">\n              <li><a href=\"{{site.baseurl}}/documentation/examples.html\">Use JSZip</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/howto/read_zip.html\">Read a file</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/howto/write_zip.html\">Write a file</a></li>\n        </ul>\n        <h4>Examples</h4>\n        <ul class=\"nav\">\n              <li><a href=\"{{site.baseurl}}/documentation/examples/read-local-file-api.html\">Read local file</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/examples/get-binary-files-ajax.html\">Read remote file</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/examples/download-zip-file.html\">Give the user its zip file</a></li>\n              <li><a href=\"{{site.baseurl}}/documentation/examples/downloader.html\">Mini app: downloader</a></li>\n        </ul>\n        {% endcase %}\n        <!-- <ul class=\"nav\"> -->\n          <!-- <li><a href=\"{{site.baseurl}}/documentation/faq.html\">FAQ</a></li> -->\n        <!-- </ul> -->\n          <!-- <li><a href=\"{{site.baseurl}}/\">installation</a></li> -->\n          </nav>\n        {% endif %}\n        <div class=\"{% if page.section and page.fullpage != true%}col-md-9{% else %}col-md-12{% endif %}\">\n          <h1>{{page.title}}</h1>\n          <!-- ===================== -->\n          <!-- === C O N T E N T === -->\n          <!-- ===================== -->\n\n          {{content}}\n\n          <!-- ===================== -->\n          <!-- == / C O N T E N T == -->\n          <!-- ===================== -->\n        </div>\n      </div>\n    </div>\n    <script>\n      // FIXME find how to do that cleanly\n      (function(){\n        var tables = document.getElementsByTagName(\"table\");\n        for(var i = 0; i < tables.length; i++) {\n          tables[i].className += \" table table-condensed table-striped table-bordered \";\n        }\n      })();\n    </script>\n    <script>\n      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n      ga('create', 'UA-52085706-1', 'stuk.github.io');\n      ga('send', 'pageview');\n\n    </script>\n  </body>\n</html>\n"
  },
  {
    "path": "documentation/api_jszip/constructor.md",
    "content": "---\ntitle: \"new JSZip() or JSZip()\"\nlayout: default\nsection: api\n---\n\nCreate a new JSZip instance.\n\n__Returns__ : A new JSZip.\n\n__Since__: v1.0.0\n\n## Example\n\n```js\nvar zip = new JSZip();\n// same as\nvar zip = JSZip();\n```\n"
  },
  {
    "path": "documentation/api_jszip/external.md",
    "content": "---\ntitle: \"JSZip.external\"\nlayout: default\nsection: api\n---\n\nJSZip uses objects that may not exist on every platform, in which case it uses\na shim.\nAccessing or replacing these objects can sometimes be useful. JSZip.external\ncontains the following properties :\n\n* `Promise` : the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) implementation used.\n\nThe global object is preferred when available.\n\n__Example__\n\n```js\n// use bluebird instead\nJSZip.external.Promise = Bluebird;\n\n// use the native Promise object:\nJSZip.external.Promise = Promise;\n```\n\n"
  },
  {
    "path": "documentation/api_jszip/file_data.md",
    "content": "---\ntitle: \"file(name, data [,options])\"\nlayout: default\nsection: api\n---\n\nAdd (or update) a file to the zip file.\nIf something goes wrong (the data is not in a supported format for example),\nan exception will be propagated when accessing the data.\n\n__Returns__ : The current JSZip object, for chaining.\n\n__Since__: v1.0.0\n\n## Arguments\n\nname                | type    | description\n--------------------|---------|------------\nname                | string  | the name of the file. You can specify folders in the name : the folder separator is a forward slash (\"/\").\ndata                | String/ArrayBuffer/Uint8Array/Buffer/Blob/Promise/Nodejs stream | the content of the file.\noptions             | object  | the options.\n\nContent of `options` :\n\nname        | type    | default | description\n------------|---------|---------|------------\nbase64      | boolean | `false` | set to `true` if the data is base64 encoded. For example image data from a `<canvas>` element. Plain text and HTML do not need this option. [More](#base64-option).\nbinary      | boolean | `false` | set to `true` if the data should be treated as raw content, `false` if this is a text. If base64 is used, this defaults to `true`, if the data is not a string, this will be set to `true`. [More](#binary-option).\ndate        | date    | the current date | the last modification date. [More](#date-option).\ncompression | string  | null    | If set, specifies compression method to use for this specific file. If not, the default file compression will be used, see [generateAsync(options)]({{site.baseurl}}/documentation/api_jszip/generate_async.html). [More](#compression-and-compressionoptions-options).\ncompressionOptions | object | `null` | the options to use when compressing the file, see [generateAsync(options)]({{site.baseurl}}/documentation/api_jszip/generate_async.html). [More](#compression-and-compressionoptions-options).\ncomment     | string  | null    | The comment for this file. [More](#comment-option).\noptimizedBinaryString | boolean | `false` | Set to true if (and only if) the input is a \"binary string\" and has already been prepared with a 0xFF mask.\ncreateFolders | boolean | `true` | Set to true if folders in the file path should be automatically created, otherwise there will only be virtual folders that represent the path to the file. [More](#createfolders-option).\nunixPermissions | 16 bits number | null    | The UNIX permissions of the file, if any. [More](#unixpermissions-and-dospermissions-options).\ndosPermissions  | 6 bits number  | null    | The DOS permissions of the file, if any. [More](#unixpermissions-and-dospermissions-options).\ndir             | boolean        | false   | Set to true if this is a directory and content should be ignored. [More](#dir-option).\n\n### data input\n\nYou shouldn't update the data given to this method: it is kept as it so any\nupdate will impact the stored data.\n\n#### About Promise <small>since v3.0.0</small>\n\nYou can use a Promise of content directly to simplify async content handling.\nLet's use HTTP calls as examples:\n\n```js\n/** with promises **/\n\n// instead of\n$.get(\"url/to.file.txt\") // jQuery v3 returns promises\n.then(function (content) {\n    zip.file(\"file.txt\", content);\n})\n\n// you can do\nvar promise = $.get(\"url/to.file.txt\");\nzip.file(\"file.txt\", promise);\n```\n\n```js\n/** with callbacks **/\n\n// instead of\nrequest('url/to.file.txt', function (error, response, body) {\n    zip.file(\"file.txt\", body);\n});\n\n// you can do\nvar promise = new Promise(function (resolve, reject) {\n    request('url/to.file.txt', function (error, response, body) {\n        if (error) {\n            reject(error);\n        } else {\n          resolve(body);\n        }\n    });\n});\nzip.file(\"file.txt\", promise);\n```\n\n#### About Blob <small>since v3.0.0</small>\n\nYou can use directly [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)\nas input, no need to use a `FileReader`.\n[File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects are Blobs\nso you can use them directly:\n\n```js\n// in a change callback of a <input type=\"file\">\nvar files = evt.target.files;\nfor (var i = 0; i < files.length; i++) {\n    var f = files[i];\n    zip.file(f.name, f);\n}\n```\n\n#### About nodejs stream <small>since v3.0.0</small>\n\nA stream can't be restarted: if it is used once, it can't be used again (\nby [generateAsync()]({{site.baseurl}}/documentation/api_jszip/generate_async.html)\nor by [ZipObject methods]({{site.baseurl}}/documentation/api_zipobject.html)).\nIn that case, the promise/stream (depending on the method called) will get\nan error.\n\n\n### `base64` option\n\n```js\nvar zip = new JSZip();\nzip.file(\"hello.txt\", \"aGVsbG8gd29ybGQK\", {base64: true});\n```\n\n### `binary` option\n\n```js\nvar zip = new JSZip();\n\n// here, we have a correct (unicode) string\nzip.file(\"hello.txt\", \"unicode ♥\", {binary: false});\n\n// here, we have a binary string: it can contain binary content, one byte\n// per character.\nzip.file(\"hello.txt\", \"unicode \\xE2\\x99\\xA5\", {binary: true});\n```\n\nIf you use a library that returns a binary string for example, you should use\nthis option. Otherwise, you will get a corrupted result: JSZip will try to\nencode this string with UTF-8 when the content doesn't need to.\n\n### `date` option\n\n```js\nzip.file(\"Xmas.txt\", \"Ho ho ho !\", {\n    date: new Date(\"December 25, 2007 00:00:01\")\n});\n```\n\n### `compression` and `compressionOptions` options\n\nSee also the same options on [`JSZip#generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html#compression-and-compressionoptions-options).\n\nThese options will be used when generating a zip file. They let you override\nentry per entry the compression / compression options to use.\n\n```js\nzip.file(\"a.png\", contentOfA, {\n    compression: \"STORE\" // force a compression for this file\n});\nzip.file(\"b.txt\", contentOfA, {\n    compression: \"DEFLATE\",\n    compressionOptions: {\n        level: 9 // force a compression and a compression level for this file\n    }\n});\n\n// don't force anything, use the generateAsync options\nzip.file(\"c.txt\", contentOfB);\n\n// here:\n// - a.png will not be compressed (STORE)\n// - b.txt will be compressed at maximum level\n// - c.txt will be compressed with the default compression level\nzip.generateAsync({\n    type: \"blob\",\n    compression: \"DEFLATE\"\n});\n```\n\n### `comment` option\n\n```js\nzip.file(\"a.txt\", \"content\", {\n    comment: \"comment of a.txt\"\n});\n```\n\n### `createFolders` option\n\n```js\nzip.file(\"a/b/c/d.txt\", \"content\", {\n    createFolders: true // default value\n});\nconsole.log(zip.files);\n// will display:\n// - a/\n// - a/b/\n// - a/b/c/\n// - a/b/c/d.txt\n\n\nzip.file(\"a/b/c/d.txt\", \"content\", {\n    createFolders: false\n});\nconsole.log(zip.files);\n// will display:\n// - a/b/c/d.txt\n```\n\n### `unixPermissions` and `dosPermissions` options\n\nEach permission will be used for matching [platform option of generateAsync()]({{site.baseurl}}/documentation/api_jszip/generate_async.html):\non `DOS`, use `dosPermissions`, on `UNIX`, use `unixPermissions`.\n\nOn nodejs you can use the `mode` attribute of\n[nodejs' fs.Stats](http://nodejs.org/api/fs.html#fs_class_fs_stats).\n\nWhen not set, a default value will be generated:\n\n- `0100664` or `040775` for `UNIX`\n- standard file or standard directory for `DOS`\n\nThe field `unixPermissions` also accepts a **string** representing the\noctal value: \"644\", \"755\", etc.\n\n```js\nzip.file(\"script.sh\", \"#!/bin/bash\", {\n    unixPermissions: \"755\"\n});\n```\n\n\n### `dir` option\n\nIf `dir` is true or if a permission says it's a folder, this entry be flagged\nas a folder and the content will be ignored.\n\nSee also [folder(name)]({{site.baseurl}}/documentation/api_jszip/folder_name.html).\n\n```js\nzip.file(\"folder/\", null, {\n    dir: true\n});\n```\n\n## Other examples\n\n```js\nzip.file(\"Hello.txt\", \"Hello World\\n\");\n\n// base64\nzip.file(\"smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true});\n// from an ajax call with xhr.responseType = 'arraybuffer'\nzip.file(\"smile.gif\", arraybufferFromXhr);\n// or on nodejs\nzip.file(\"smile.gif\", fs.readFileSync(\"smile.gif\"));\n\nzip.file(\"Xmas.txt\", \"Ho ho ho !\", {date : new Date(\"December 25, 2007 00:00:01\")});\nzip.file(\"folder/file.txt\", \"file in folder\");\n\nzip.file(\"animals.txt\", \"dog,platypus\\n\").file(\"people.txt\", \"james,sebastian\\n\");\n\n// result:\n// - Hello.txt\n// - smile.gif\n// - Xmas.txt\n// - animals.txt\n// - people.txt\n// - folder/\n// - folder/file.txt\n```\n"
  },
  {
    "path": "documentation/api_jszip/file_name.md",
    "content": "---\ntitle: \"file(name)\"\nlayout: default\nsection: api\n---\n\nGet a file with the specified name. You can specify folders\nin the name : the folder separator is a forward slash (\"/\").\n\n__Returns__ : An instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html) representing\nthe file if any, `null` otherwise.\n\n__Since__: v1.0.0\n\n## Arguments\n\nname | type   | description\n-----|--------|-------------\nname | string | the name of the file.\n\n__Throws__ : Nothing.\n\n<!-- __Complexity__ : This is a simple lookup in **O(1)**. -->\n\n## Example\n\n```js\nvar zip = new JSZip();\nzip.file(\"file.txt\", \"content\");\n\nzip.file(\"file.txt\").name // \"file.txt\"\nzip.file(\"file.txt\").async(\"string\") // a promise of \"content\"\nzip.file(\"file.txt\").dir // false\n\n// utf8 example\nvar zip = new JSZip();\nzip.file(\"amount.txt\", \"€15\");\nzip.file(\"amount.txt\").async(\"string\") // a promise of \"€15\"\nzip.file(\"amount.txt\").async(\"arraybuffer\") // a promise of an ArrayBuffer containing €15 encoded as utf8\nzip.file(\"amount.txt\").async(\"uint8array\") // a promise of an Uint8Array containing €15 encoded as utf8\n\n// with folders\nzip.folder(\"sub\").file(\"file.txt\", \"content\");\nzip.file(\"sub/file.txt\"); // the file\n// or\nzip.folder(\"sub\").file(\"file.txt\") // the file\n```\n\n\n"
  },
  {
    "path": "documentation/api_jszip/file_regex.md",
    "content": "---\ntitle: \"file(regex)\"\nlayout: default\nsection: api\n---\n\nSearch a file in the current folder and subfolders with a\n[regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).\nThe regex is tested against the relative filename.\n\n__Returns__ : An array of matching files (an empty array if none matched). Each\nmatching file is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).\n\n__Since__: v1.0.0\n\n## Arguments\n\nname  | type   | description\n------|--------|------------\nregex | RegExp | the regex to use.\n\n## Example\n\n```js\nvar zip = new JSZip();\nzip.file(\"file1.txt\", \"content\");\nzip.file(\"file2.txt\", \"content\");\n\nzip.file(/file/); // array of size 2\n\n// example with a relative path :\nvar folder = zip.folder(\"sub\");\nfolder\n  .file(\"file3.txt\", \"content\")  // relative path from folder : file3.txt\n  .file(\"file4.txt\", \"content\"); // relative path from folder : file4.txt\n\nfolder.file(/file/);  // array of size 2\nfolder.file(/^file/); // array of size 2, the relative paths start with file\n\n// arrays contain objects in the form:\n// {name: \"file2.txt\", dir: false, async : function () {...}, ...}\n```\n\n\n"
  },
  {
    "path": "documentation/api_jszip/filter.md",
    "content": "---\ntitle: \"filter(predicate)\"\nlayout: default\nsection: api\n---\n\nFilter nested files/folders with the specified function.\n\n__Returns__ : An array of matching ZipObject.\n\n__Since__: v1.0.0\n\n## Arguments\n\nname      | type     | description\n----------|----------|------------\npredicate | function | the predicate to use.\n\nThe predicate has the following signature : `function (relativePath, file) {...}` :\n\nname         | type      | description\n-------------|-----------|------------\nrelativePath | string    | the filename and its path, relative to the current folder.\nfile         | ZipObject | the file being tested. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).\n\nThe predicate must return true if the file should be included, false otherwise.\n\n\n## Examples\n\n```js\nvar zip = new JSZip().folder(\"dir\");\nzip.file(\"readme.txt\", \"content\");\nzip.filter(function (relativePath, file){\n  // relativePath == \"readme.txt\"\n  // file = {name:\"dir/readme.txt\",options:{...},async:function}\n  return true/false;\n});\n```\n\n\n"
  },
  {
    "path": "documentation/api_jszip/folder_name.md",
    "content": "---\ntitle: \"folder(name)\"\nlayout: default\nsection: api\n---\n\nCreate a directory if it doesn't exist, return a new JSZip\nobject with the new folder as root.\n\nSee also [the `dir` option of file()]({{site.baseurl}}/documentation/api_jszip/file_data.html).\n\n__Returns__ : A new JSZip (for chaining), with the new folder as root.\n\n__Since__: v1.0.0\n\n## Arguments\n\nname | type   | description\n-----|--------|------------\nname | string | the name of the directory.\n\n## Examples\n\n```js\nzip.folder(\"images\");\nzip.folder(\"css\").file(\"style.css\", \"body {background: #FF0000}\");\n// or specify an absolute path (using forward slashes)\nzip.file(\"css/font.css\", \"body {font-family: sans-serif}\")\n\n// result : images/, css/, css/style.css, css/font.css\n```\n\n"
  },
  {
    "path": "documentation/api_jszip/folder_regex.md",
    "content": "---\ntitle: \"folder(regex)\"\nlayout: default\nsection: api\n---\n\nSearch a subdirectory in the current directory with a\n[regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).\nThe regex is tested against the relative path.\n\n__Returns__ : An array of matching folders (an empty array if none matched).\nEach matching folder is an instance of [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).\n\n__Since__: v1.0.0\n\n## Arguments\n\nname  | type   | description\n------|--------|------------\nregex | RegExp | the regex to use.\n\n## Examples\n\n```js\nvar zip = new JSZip();\nzip.folder(\"home/Pierre/videos\");\nzip.folder(\"home/Pierre/photos\");\nzip.folder(\"home/Jean/videos\");\nzip.folder(\"home/Jean/photos\");\n\nzip.folder(/videos/); // array of size 2\n\nzip.folder(\"home/Jean\").folder(/^vid/); // array of 1\n```\n\n"
  },
  {
    "path": "documentation/api_jszip/for_each.md",
    "content": "---\ntitle: \"forEach(callback)\"\nlayout: default\nsection: api\n---\n\nCall a callback function for each entry at this folder level.\n\n__Returns__ : Nothing.\n\n__Since__: v3.0.0\n\n## Arguments\n\nname      | type     | description\n----------|----------|------------\ncallback  | function | the callback to use.\n\nThe callback has the following signature : `function (relativePath, file) {...}` :\n\nname         | type      | description\n-------------|-----------|------------\nrelativePath | string    | the filename and its path, relative to the current folder.\nfile         | ZipObject | the current file. See [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html).\n\n\n## Examples\n\n```js\nvar zip = new JSZip();\nzip.file(\"package.json\", \"...\");\nzip.file(\"lib/index.js\", \"...\");\nzip.file(\"test/index.html\", \"...\");\nzip.file(\"test/asserts/file.js\", \"...\");\nzip.file(\"test/asserts/generate.js\", \"...\");\n\nzip.folder(\"test\").forEach(function (relativePath, file){\n    console.log(\"iterating over\", relativePath);\n});\n\n// will display:\n// iterating over index.html\n// iterating over asserts/\n// iterating over asserts/file.js\n// iterating over asserts/generate.js\n```\n"
  },
  {
    "path": "documentation/api_jszip/generate_async.md",
    "content": "---\ntitle: \"generateAsync(options[, onUpdate])\"\nlayout: default\nsection: api\n---\n\nGenerates the complete zip file at the current folder level.\n\n__Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\nof the generated zip file.\n\nAn error will be propagated if the asked `type` is not available in the\nbrowser, see [JSZip.support]({{site.baseurl}}/documentation/api_jszip/support.html).\n\n__Since__: v3.0.0\n\n## Arguments\n\nname                | type     | default  | description\n--------------------|----------|----------|------------\noptions             | object   |          | the options to generate the zip file :\noptions.type        | string   |          | The type of zip to return, see below for the other types. **Required**. [More](#type-option).\noptions.compression | string   | `STORE` (no compression) | the default file compression method to use. [More](#compression-and-compressionoptions-options).\noptions.compressionOptions | object | `null` | the options to use when compressing the file. [More](#compression-and-compressionoptions-options).\noptions.comment     | string   |          | The comment to use for the zip file. [More](#comment-option).\noptions.mimeType    | string   | `application/zip` | mime-type for the generated file. [More](#mimetype-option).\noptions.platform    | string   | `DOS`    | The platform to use when generating the zip file. [More](#platform-option).\noptions.encodeFileName | function | encode with UTF-8 | the function to encode the file name / comment. [More](#encodefilename-option).\noptions.streamFiles | boolean  | false    | Stream the files and create file descriptors, see below. [More](#streamfiles-option).\nonUpdate            | function |          | The optional function called on each internal update with the metadata. [More](#onupdate-callback).\n\n### `type` option\n\nPossible values for `type` :\n\n* `base64`: the result will be a string, the binary in a base64 form.\n* `binarystring` (or `string`, deprecated): the result will be a string in \"binary\" form, using 1 byte per char (2 bytes).\n* `array`: the result will be an Array of bytes (numbers between 0 and 255) containing the zip.\n* `uint8array`: the result will be a Uint8Array containing the zip. This requires a compatible browser.\n* `arraybuffer`: the result will be a ArrayBuffer containing the zip. This requires a compatible browser.\n* `blob`: the result will be a Blob containing the zip. This requires a compatible browser.\n* `nodebuffer`: the result will be a nodejs Buffer containing the zip. This requires nodejs.\n\nNote : when using type = \"uint8array\", \"arraybuffer\" or \"blob\", be sure to\ncheck if the browser supports it (you can use [`JSZip.support`]({{site.baseurl}}/documentation/api_jszip/support.html)).\n\n```js\nzip.generateAsync({type: \"uint8array\"}).then(function (u8) {\n    // ...\n});\n```\n\n### `compression` and `compressionOptions` options\n\nAvailable `compression` methods are `STORE` (no compression) and `DEFLATE`.\n\nThe `compressionOptions` parameter depends on the compression type. With\n`STORE` (no compression), this parameter is ignored. With `DEFLATE`, you can\ngive the compression level with `compressionOptions : {level:6}` (or any level\nbetween 1 (best speed) and 9 (best compression)).\n\nNote : if the entry is *already* compressed (coming from a compressed zip file),\ncalling `generateAsync()` with a different compression level won't update the entry.\nThe reason is simple : JSZip doesn't know how compressed the content was and\nhow to match the compression level with the implementation we use.\n\n```js\nzip.generateAsync({\n    type: \"blob\",\n    compression: \"DEFLATE\",\n    compressionOptions: {\n        level: 9\n    }\n});\n```\n\n### `comment` option\n\nThe zip format has no flag or field to give the encoding of this field and\nJSZip will use UTF-8. With non ASCII characters you might get encoding issues\nif the file archiver doesn't use UTF-8 (or the given encoding) to decode the\ncomment.\n\n```js\nzip.generateAsync({\n    type: \"blob\",\n    comment: \"The comment text for this zip file\"\n})\n```\n\n### `mimeType` option\n\nThis field is used when you generate a Blob and need to change\n[the mime type](https://developer.mozilla.org/en-US/docs/Web/API/Blob/type).\nUseful when you need to generate a file with a different extension, ie: \".ods\".\n\nNote, this won't change the content of the file, only the other programs *may*\nsee it.\n\n```js\n//This example will Generate a Open Document Spreadsheet, with the correct mime type\nvar zip = new JSZip();\nzip.file(\"mimetype\", \"application/vnd.oasis.opendocument.spreadsheet\");\nvar metaInf = zip.folder(\"META-INF\");\nmetaInf.file(\"manifest.xml\", \"<...\");\n// ...\n\n//Generate the file\nzip.generateAsync({\n    type: \"blob\",\n    mimeType: \"application/ods\",\n    compression: \"DEFLATE\"\n}).then(function (odsFile) {\n    // odsFile.type == \"application/ods\"\n});\n```\n\n### `platform` option\n\nPossible values for `platform` : `DOS` and `UNIX`. It also accepts nodejs\n`process.platform` values.\nWhen using `DOS`, the attribute `dosPermissions` of each file is used.\nWhen using `UNIX`, the attribute `unixPermissions` of each file is used.\n\nIf you set the platform value on nodejs, be sure to use `process.platform`.\n`fs.stats` returns a non executable mode for folders on windows, if you\nforce the platform to `UNIX` the generated zip file will have a strange\nbehavior on UNIX platforms.\n\n```js\n// on nodejs\nzip.file(pathname, content, {\n    date: stat.mtime,\n    unixPermissions: stat.mode\n});\n\n// ...\n\nzip.generateAsync({\n    type: 'nodebuffer',\n    platform: process.platform\n});\n```\n\n### `encodeFileName` option\n\nBy default, JSZip uses UTF-8 to encode the file names / comments. You can use\nthis method to force an other encoding. Note: the encoding used is not stored\nin a zip file, not using UTF-8 may lead to encoding issues.\nThe function takes a string and returns a bytes array (Uint8Array or Array).\n\nSee also [`decodeFileName` on `JSZip#loadAsync()`]({{site.baseurl}}/documentation/api_jszip/load_async.html#decodefilename-option).\n\n```js\n// using iconv-lite for example\nvar iconv = require('iconv-lite');\n\nzip.generateAsync({\n    type: 'uint8array',\n    encodeFileName: function (string) {\n        return iconv.encode(string, 'your-encoding');\n    }\n});\n```\n\n\n### `streamFiles` option\n\nIn a zip file, the size and the crc32 of the content are placed before the\nactual content: to write it we must process the whole file. When this option\nis `false` (the default) the processed file is held in memory. It takes more\nmemory but generates a zip file which should be read by every program.\nWhen this options is `true`, we stream the file and use data descriptors at the\nend of the entry. This option uses less memory but some program might not\nsupport data descriptors (and won't accept the generated zip file).\n\n```js\nzip.generateAsync({\n    type: 'uint8array',\n    streamFiles: true\n});\n```\n\n### `onUpdate` callback\n\nIf specified, this function will be called each time a chunk is pushed to the\noutput stream (or internally accumulated).\n\nThe function takes a `metadata` object which contains information about the\nongoing process.\n\n__Metadata__ : the metadata are:\n\nname        | type   | description\n------------|--------|------------\npercent     | number | the percent of completion (a double between 0 and 100)\ncurrentFile | string | the name of the current file being processed, if any.\n\n```js\nzip.generateAsync({type:\"blob\"}, function updateCallback(metadata) {\n    console.log(\"progression: \" + metadata.percent.toFixed(2) + \" %\");\n    if(metadata.currentFile) {\n        console.log(\"current file = \" + metadata.currentFile);\n    }\n})\n```\n\n## Other examples\n\n```js\nzip.generateAsync({type:\"blob\"})\n.then(function (content) {\n    // see FileSaver.js\n    saveAs(content, \"hello.zip\");\n});\n```\n\n```js\nzip.generateAsync({type:\"base64\"})\n.then(function (content) {\n    location.href=\"data:application/zip;base64,\"+content;\n});\n```\n\n```js\nzip.folder(\"folder_1\").folder(\"folder_2\").file(\"hello.txt\", \"hello\");\n// zip now contains:\n// folder_1/\n// folder_1/folder_2/\n// folder_1/folder_2/hello.txt\n\nzip.folder(\"folder_1\").generateAsync({type:\"nodebuffer\"})\n.then(function (content) {\n    // relative to folder_1/, this file only contains:\n    // folder_2/\n    // folder_2/hello.txt\n    require(\"fs\").writeFile(\"hello.zip\", content, function(err){/*...*/});\n});\n```\n"
  },
  {
    "path": "documentation/api_jszip/generate_internal_stream.md",
    "content": "---\ntitle: \"generateInternalStream(options)\"\nlayout: default\nsection: api\n---\n\nGenerates the complete zip file with the internal stream implementation.\n\n__Returns__ : a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html).\n\n__Since__: v3.0.0\n\n## Arguments\n\nname                | type     | default | description\n--------------------|----------|---------|------------\noptions             | object   |         | the options to generate the zip file, see [the options of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html)\n\n__Metadata__ : see [the metadata of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html#onupdate-callback).\n\n## Examples\n\n```js\nzip\n.generateInternalStream({type:\"uint8array\"})\n.accumulate()\n.then(function (data) {\n    // data contains here the complete zip file as a uint8array (the type asked in generateInternalStream)\n});\n```\n"
  },
  {
    "path": "documentation/api_jszip/generate_node_stream.md",
    "content": "---\ntitle: \"generateNodeStream(options[, onUpdate])\"\nlayout: default\nsection: api\n---\n\nGenerates the complete zip file as a nodejs stream.\n\n__Returns__ : a [nodejs Streams3](https://github.com/nodejs/readable-stream).\n\n__Since__: v3.0.0\n\n## Arguments\n\nname                | type     | default | description\n--------------------|----------|---------|------------\noptions             | object   |         | the options to generate the zip file, see [the options of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html)\nonUpdate            | function |         | The optional function called on each internal update with the metadata.\n\nThe `type` parameter has here the default value of `nodebuffer`.\nOnly `nodebuffer` is currently supported.\n\n__Metadata__ : see [the metadata of `generateAsync()`]({{site.baseurl}}/documentation/api_jszip/generate_async.html#onupdate-callback).\n\n## Examples\n\n```js\nzip\n.generateNodeStream({streamFiles:true})\n.pipe(fs.createWriteStream('out.zip'))\n.on('finish', function () {\n    // JSZip generates a readable stream with a \"end\" event,\n    // but is piped here in a writable stream which emits a \"finish\" event.\n    console.log(\"out.zip written.\");\n});\n```\n"
  },
  {
    "path": "documentation/api_jszip/load_async.md",
    "content": "---\ntitle: \"loadAsync(data [, options])\"\nlayout: default\nsection: api\n---\n\nRead an existing zip and merge the data in the current JSZip\nobject at the current folder level. This technique has some limitations, see\n[here]({{site.baseurl}}/documentation/limitations.html).\nIf the JSZip object already contains entries, new entries will be merged. If\ntwo have the same name, the loaded one will replace the other.\n\nSince v3.8.0 this method will santize relative path components (i.e. `..`) in loaded filenames to avoid [\"zip slip\" attacks](https://snyk.io/research/zip-slip-vulnerability). For example: `../../../example.txt` → `example.txt`, `src/images/../example.txt` → `src/example.txt`. The original filename is available on each zip entry as `unsafeOriginalName`.\n\n__Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with the updated zip object.\nThe promise can fail if the loaded data is not valid zip data or if it\nuses unsupported features (multi volume, password protected, etc).\n\n__Since__: v3.0.0\n\n## Arguments\n\nname               | type   | description\n-------------------|--------|------------\ndata               | String/Array of bytes/ArrayBuffer/Uint8Array/Buffer/Blob/Promise | the zip file\noptions            | object | the options to load the zip file\n\nContent of `options` :\n\nname                          | type    | default | description\n------------------------------|---------|---------|------------\noptions.base64                | boolean | false   | set to `true` if the data is base64 encoded, `false` for binary. [More](#base64-option).\noptions.checkCRC32            | boolean | false   | set to `true` if the read data should be checked against its CRC32. [More](#checkcrc32-option).\noptions.optimizedBinaryString | boolean | false   | set to `true` if (and only if) the input is a string and has already been prepared with a 0xFF mask.\noptions.createFolders         | boolean | false   | set to `true` to create folders in the file path automatically. Leaving it false will result in only virtual folders (i.e. folders that merely represent part of the file path) being created. [More](#createfolders-option).\noptions.decodeFileName        | function | decode from UTF-8 | the function to decode the file name / comment. [More](#decodefilename-option).\n\nYou shouldn't update the data given to this method : it is kept as it so any\nupdate will impact the stored data.\n\nZip features supported by this method :\n\n* Compression (<code>DEFLATE</code> supported)\n* zip with data descriptor\n* ZIP64\n* UTF8 in file name, UTF8 in file content\n\nZip features not (yet) supported :\n\n* password protected zip\n* multi-volume zip\n\n### `base64` option\n\n```js\nvar zip = new JSZip();\nzip.loadAsync(\"UEsDBAoDAAAAAJxs8T...AAAAAA==\", {base64: true});\n```\n\n### `checkCRC32` option\n\nThe `checkCRC32` option will load every files, compute the CRC32 value and\ncompare it against the saved value.\nWith larger zip files, this option can have a significant performance cost.\n\n```js\n// here, \"bin\" is a corrupted zip file\n\nzip.loadAsync(bin)\n.then(function (zip) {\n    // will be called, even if content is corrupted\n}, function (e) {\n    // won't be called\n});\n\nzip.loadAsync(bin, {\n    checkCRC32: true\n})\n.then(function (zip) {\n    // won't be called\n}, function (e) {\n    // Error: Corrupted zip : CRC32 mismatch\n});\n```\n\n### `createFolders` option\n\n```js\n// here, \"bin\" is zip file containing:\n// folder1/folder2/folder3/file1.txt\n\nzip.loadAsync(bin)\n.then(function (zip) {\n    console.log(zip.files);\n    // folder1/folder2/folder3/file1.txt\n});\n\n// with createFolders: true, all folders will be created\nzip.loadAsync(bin, {createFolders: true})\n.then(function (zip) {\n    console.log(zip.files);\n    // folder1/\n    // folder1/folder2/\n    // folder1/folder2/folder3/\n    // folder1/folder2/folder3/file1.txt\n});\n```\n\n### `decodeFileName` option\n\nA zip file has a flag to say if the filename and comment are encoded with UTF-8.\nIf it's not set, JSZip has **no way** to know the encoding used. It usually\nis the default encoding of the operating system. Some extra fields can give\nthe unicode version of the filename/comment too (in that case, we use it).\n\nIf we can't find an UTF-8 encoded filename/comment, we use the `decodeFileName`\nfunction (which is by default an UTF-8 decode).\n\nThe function takes the bytes array (Uint8Array or Array) and returns the\ndecoded string.\n\n```js\n// here, \"bin\" is a russian zip file, using the cp866 encoding for file names\n// by default, using UTF-8 leads to wrong file names:\nzip.loadAsync(bin)\n.then(function (zip) {\n    console.log(zip.files);\n    // '����� �����/': ...\n    // '����� �����/����� ⥪�⮢�� ���㬥��.txt': ...\n});\n\n// using the correct encoding solve the issue:\nvar iconv = require('iconv-lite');\nzip.loadAsync(bin, {\n  decodeFileName: function (bytes) {\n    return iconv.decode(bytes, 'cp866');\n  }\n})\n.then(function (zip) {\n    console.log(zip.files);\n    // 'Новая папка/': ...\n    // 'Новая папка/Новый текстовый документ.txt': ...\n});\n```\n\n## Other examples\n\n```js\nvar zip = new JSZip();\nzip.loadAsync(zipDataFromXHR);\n```\n\n```js\nrequire(\"fs\").readFile(\"hello.zip\", function (err, data) {\n  if (err) throw err;\n  var zip = new JSZip();\n  zip.loadAsync(data);\n}\n```\n\nUsing sub folders :\n\n```js\n// here, \"bin\" is zip file containing:\n// file1.txt\n// folder1/file2.txt\n\nvar zip = new JSZip();\nzip.folder(\"subfolder\").loadAsync(bin)\n.then(function (zip) {\n    // \"zip\" is still in the \"subfolder\" folder\n    console.log(zip.files);\n    // subfolder/file1.txt\n    // subfolder/folder1/file2.txt\n});\n```\n\nUsing `loadAsync` multiple times:\n\n```js\n// here, \"bin1\" is zip file containing:\n// file1.txt\n// file2.txt\n// and \"bin2\" is zip file containing:\n// file2.txt\n// file3.txt\n\nvar zip = new JSZip();\nzip.loadAsync(bin1)\n.then(function (zip) {\n    return zip.loadAsync(bin2);\n}).then(function (zip) {\n    console.log(zip.files);\n    // file1.txt, from bin1\n    // file2.txt, from bin2\n    // file3.txt, from bin2\n});\n```\n\nReading a zip file with relative filenames:\n\n```js\n// here, \"unsafe.zip\" is zip file containing:\n// src/images/../file.txt\n// ../../example.txt\n\nrequire(\"fs\").readFile(\"unsafe.zip\", function (err, data) {\n    if (err) throw err;\n    var zip = new JSZip();\n    zip.loadAsync(data)\n    .then(function (zip) {\n        console.log(zip.files);\n        // src/file.txt\n        // example.txt\n        console.log(zip.files[\"example.txt\"].unsafeOriginalName);\n        // \"../../example.txt\"\n    });\n}\n```\n"
  },
  {
    "path": "documentation/api_jszip/load_async_object.md",
    "content": "---\ntitle: \"JSZip.loadAsync(data [, options])\"\nlayout: default\nsection: api\n---\n\nThis is a shortcut for\n\n```js\nvar zip = new JSZip();\nzip.loadAsync(data, options);\n```\n\nPlease see the documentation of [loadAsync]({{site.baseurl}}/documentation/api_jszip/load_async.html).\n\n\n__Examples__\n\n```js\ndataAsPromise\n.then(JSZip.loadAsync)\n.then(function(zip) {...})\n```\n\nsame as:\n\n```js\nJSZip.loadAsync(dataAsPromise)\n.then(function(zip) {...})\n```\n"
  },
  {
    "path": "documentation/api_jszip/remove.md",
    "content": "---\ntitle: \"remove(name)\"\nlayout: default\nsection: api\n---\n\nDelete a file or folder (recursively).\n\n__Returns__ : The current JSZip object.\n\n__Since__: v1.0.0\n\n## Arguments\n\nname | type   | description\n-----|--------|------------\nname | string | the name of the file/folder to delete.\n\n## Examples\n\n```js\nvar zip = new JSZip();\nzip.file(\"Hello.txt\", \"Hello World\\n\");\nzip.file(\"temp.txt\", \"nothing\").remove(\"temp.txt\");\n// result : Hello.txt\n\nzip.folder(\"css\").file(\"style.css\", \"body {background: #FF0000}\");\nzip.remove(\"css\");\n//result : empty zip\n```\n\n\n"
  },
  {
    "path": "documentation/api_jszip/support.md",
    "content": "---\ntitle: \"JSZip.support\"\nlayout: default\nsection: api\n---\n\nIf the browser supports them, JSZip can take advantage of some \"new\" features :\nArrayBuffer, Blob, Uint8Array. To know if JSZip can use them, you can check the\nJSZip.support object. It contains the following boolean properties :\n\n* `arraybuffer` : true if JSZip can read and generate ArrayBuffer, false otherwise.\n* `uint8array` : true if JSZip can read and generate Uint8Array, false otherwise.\n* `blob` : true if JSZip can generate Blob, false otherwise.\n* `nodebuffer` : true if JSZip can read and generate nodejs Buffer, false otherwise.\n* `nodestream` : true if JSZip can read and generate nodejs stream, false otherwise.\n\n\n"
  },
  {
    "path": "documentation/api_jszip/version.md",
    "content": "---\ntitle: \"JSZip.version\"\nlayout: default\nsection: api\n---\n\nThe version of JSZip as a string.\n\n__Since__: v3.1.0\n\n## Example\n\n```js\nJSZip.version == \"3.1.0\";\n```\n"
  },
  {
    "path": "documentation/api_jszip.md",
    "content": "---\ntitle: \"JSZip API\"\nlayout: default\nsection: api\n---\n\nAn instance of JSZip represents a set of files. You can add them, remove them,\nmodify them. You can also import an existing zip file or generate one.\n\n### Attributes\n\nattribute name       | type        | description\n---------------------|-------------|-------------\n`files`              | object      | the [ZipObject]({{site.baseurl}}/documentation/api_zipobject.html)s inside the zip with the name as key. See [file(name)]({{site.baseurl}}/documentation/api_jszip/file_name.html).\n`comment`            | string      | the comment of the zip file.\n"
  },
  {
    "path": "documentation/api_streamhelper/accumulate.md",
    "content": "---\ntitle: \"accumulate([updateCallback])\"\nlayout: default\nsection: api\n---\n\nRead the whole stream and call a callback with the complete content.\n\n__Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\nof the full content.\n\n__Since__: v3.0.0\n\n## Arguments\n\nname            | type     | description\n----------------|----------|------------\nupdateCallback  | function | the function called every time the stream updates. This function is optional.\n\n\nThe update callback function takes 1 parameter: the metadata (see the [`on` method]({{site.baseurl}}/documentation/api_streamhelper/on.html)).\n\n## Example\n\n```js\nzip\n.generateInternalStream({type:\"uint8array\"})\n.accumulate(function updateCallback(metadata) {\n    // metadata contains for example currentFile and percent, see the generateInternalStream doc.\n}).then(function (data) {\n    // data contains here the complete zip file as a uint8array (the type asked in generateInternalStream)\n});\n```\n"
  },
  {
    "path": "documentation/api_streamhelper/on.md",
    "content": "---\ntitle: \"on(event, callback)\"\nlayout: default\nsection: api\n---\n\nRegister a listener on an event.\n\n__Returns__ : The current StreamHelper object, for chaining.\n\n__Throws__ : An exception if the event is unknown.\n\n## Arguments\n\nname      | type     | description\n----------|----------|------------\nevent     | string   | the name of the event. Only 3 events are supported : `data`, `end` and `error`.\ncallback  | function | the function called when the event occurs. See below for the arguments.\n\nThe callbacks are executed in with the current `StreamHelper` as `this`.\n\n### `data` callback\n\nIt takes 2 parameters:\n\n- the current chunk of data (in a format specified by the method which\n  generated this StreamHelper)\n- the metadata (see each method to know what's inside)\n\n### `end` callback\n\nIt does not take any parameter.\n\n### `error` callback\n\nIt takes an `Error` as parameter.\n\n## Example\n\n```js\nzip\n.generateInternalStream({type:\"uint8array\"})\n.on('data', function (data, metadata) {\n    // data is a Uint8Array because that's the type asked in generateInternalStream\n    // metadata contains for example currentFile and percent, see the generateInternalStream doc.\n})\n.on('error', function (e) {\n    // e is the error\n})\n.on('end', function () {\n    // no parameter\n})\n.resume();\n```\n"
  },
  {
    "path": "documentation/api_streamhelper/pause.md",
    "content": "---\ntitle: \"pause()\"\nlayout: default\nsection: api\n---\n\nPause the stream if the stream is running. Once paused, the\nstream stops sending `data` events.\n\n__Returns__ : The current StreamHelper object, for chaining.\n\n## Example\n\n```js\nzip\n.generateInternalStream({type:\"uint8array\"})\n.on('data', function(chunk) {\n\n    // if we push the chunk to an other service which is overloaded, we can\n    // pause the stream as backpressure.\n    this.pause();\n\n}).resume(); // start the stream the first time\n```\n\n"
  },
  {
    "path": "documentation/api_streamhelper/resume.md",
    "content": "---\ntitle: \"resume()\"\nlayout: default\nsection: api\n---\n\nResume the stream if the stream is paused. Once resumed, the stream starts\nsending `data` events again.\n\n__Returns__ : The current StreamHelper object, for chaining.\n\n__Since__: v3.0.0\n\n## Example\n\n```js\nzip\n.generateInternalStream({type:\"uint8array\"})\n.on('data', function() {...})\n.resume();\n```\n"
  },
  {
    "path": "documentation/api_streamhelper.md",
    "content": "---\ntitle: \"StreamHelper API\"\nlayout: default\nsection: api\n---\n\nA `StreamHelper` can be viewed as a pausable stream with some helper methods.\nIt is not a full featured stream like in nodejs (and can't directly used as one)\nbut the exposed methods should be enough to write the glue code with other async\nlibraries : `on('data', function)`, `on('end', function)` and `on('error', function)`.\n\nIt starts paused, be sure to `resume()` it when ready.\n\nIf you are looking for an asynchronous helper without writing glue code, take a\nlook at `accumulate(function)`.\n"
  },
  {
    "path": "documentation/api_zipobject/async.md",
    "content": "---\ntitle: \"async(type[, onUpdate])\"\nlayout: default\nsection: api\n---\n\nReturn a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) of the content in the asked type.\n\n__Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) of the content.\n\n__Since__: v3.0.0\n\n## Arguments\n\nname     | type     | description\n---------|----------|------------\ntype     | String   | the type of the result. [More](#type-option).\nonUpdate | Function | an optional function called on each internal update with the metadata. [More](#onupdate-callback).\n\n### `type` option\n\nPossible values for `type` :\n\n* `base64` : the result will be a string, the binary in a base64 form.\n* `text` (or `string`): the result will be an unicode string.\n* `binarystring`: the result will be a string in \"binary\" form, using 1 byte per char (2 bytes).\n* `array`: the result will be an Array of bytes (numbers between 0 and 255).\n* `uint8array` : the result will be a Uint8Array. This requires a compatible browser.\n* `arraybuffer` : the result will be a ArrayBuffer. This requires a compatible browser.\n* `blob` : the result will be a Blob. This requires a compatible browser.\n* `nodebuffer` : the result will be a nodejs Buffer. This requires nodejs.\n\nNote : when using type = \"uint8array\", \"arraybuffer\" or \"blob\", be sure to\ncheck if the browser supports it (you can use [`JSZip.support`]({{site.baseurl}}/documentation/api_jszip/support.html)).\n\n```js\nzip.file(\"image.png\").async(\"uint8array\").then(function (u8) {\n    // ...\n});\n```\n\n### `onUpdate` callback\n\nIf specified, this function will be called each time a chunk is pushed to the\noutput stream (or internally accumulated).\n\nThe function takes a `metadata` object which contains information about the\nongoing process.\n\n__Metadata__ : the metadata are :\n\nname        | type   | description\n------------|--------|------------\npercent     | number | the percent of completion (a double between 0 and 100)\n\n```js\nzip.file(\"image.png\").async(\"uint8array\", function updateCallback(metadata) {\n    console.log(\"progression: \" + metadata.percent.toFixed(2) + \" %\");\n}).then(function (u8) {\n    // ...\n})\n```\n\n\n## Other examples\n\n```js\nzip\n.file(\"my_text.txt\")\n.async(\"string\")\n.then(function success(content) {\n    // use the content\n}, function error(e) {\n    // handle the error\n});\n```\n"
  },
  {
    "path": "documentation/api_zipobject/internal_stream.md",
    "content": "---\ntitle: \"internalStream(type)\"\nlayout: default\nsection: api\n---\n\nReturn a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html)\nof the content in the asked type.\n\n__Returns__ : a [StreamHelper]({{site.baseurl}}/documentation/api_streamhelper.html)\nof the content in the asked type.\n\n## Arguments\n\nname     | type     | description\n---------|----------|------------\ntype     | String   | the type of the result: `string`, `binarystring`, `uint8array`, `arraybuffer`, `nodebuffer`.\n\n\n## Example\n\n```js\nzip\n.file(\"my_text.txt\")\n.internalStream(\"string\")\n.on(\"data\", function (data) {...})\n.on(\"error\", function (e) {...})\n.on(\"end\", function () {...});\n```\n\n"
  },
  {
    "path": "documentation/api_zipobject/node_stream.md",
    "content": "---\ntitle: \"nodeStream(type[, onUpdate])\"\nlayout: default\nsection: api\n---\n\nReturn a [nodejs Streams3](https://github.com/nodejs/readable-stream)\nof the content in the asked type.\n\n__Returns__ : a [nodejs Streams3](https://github.com/nodejs/readable-stream).\n\n## Arguments\n\nname     | type     | default      | description\n---------|----------|--------------|------------\ntype     | String   | `nodebuffer` | only `nodebuffer` is currently supported.\nonUpdate | Function |              | an optional function called on each internal update with the metadata.\n\n__Metadata__ : see [the metadata of `async()`]({{site.baseurl}}/documentation/api_zipobject/async.html#onupdate-callback).\n\n## Example\n\n```js\nzip\n.file(\"my_text.txt\")\n.nodeStream()\n.pipe(fs.createWriteStream('/tmp/my_text.txt'))\n.on('finish', function () {\n    // JSZip generates a readable stream with a \"end\" event,\n    // but is piped here in a writable stream which emits a \"finish\" event.\n    console.log(\"text file written.\");\n});\n```\n"
  },
  {
    "path": "documentation/api_zipobject.md",
    "content": "---\ntitle: \"ZipObject API\"\nlayout: default\nsection: api\n---\n\nThis represents an entry in the zip file. If the entry comes from an existing\narchive previously [loaded]({{site.baseurl}}/documentation/api_jszip/load_async.html), the content\nwill be automatically decompressed/converted first.\n\n### Attributes\n\nattribute name              | type        | description\n----------------------------|-------------|-------------\n`name`                      | string      | the absolute path of the file\n`dir`                       | boolean     | true if this is a directory\n`date`                      | date        | the last modification date\n`comment`                   | string      | the comment for this file\n`unixPermissions`           | 16 bits number | The UNIX permissions of the file, if any.\n`dosPermissions`            | 6 bits number  | The DOS permissions of the file, if any.\n`options`                   | object      | the options of the file. The available options are :\n`options.compression`       | compression | see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)\n`options.compressionOptions`| object      | see [file(name, data [,options])]({{site.baseurl}}/documentation/api_jszip/file_data.html)\n\nExample:\n\n```js\n{ name: 'docs/',\n  dir: true,\n  date: 2016-12-25T08:09:27.153Z,\n  comment: null,\n  unixPermissions: 16877,\n  dosPermissions: null,\n  options: {\n    compression: 'STORE',\n    compressionOptions: null\n  }\n}\n```\n\n```js\n{ name: 'docs/list.txt',\n  dir: false,\n  date: 2016-12-25T08:09:27.152Z,\n  comment: null,\n  unixPermissions: 33206,\n  dosPermissions: null,\n  options: {\n    compression: 'DEFLATE',\n    compressionOptions: null\n  }\n}\n```\n"
  },
  {
    "path": "documentation/contributing.md",
    "content": "---\ntitle: Contributing\nlayout: default\nsection: main\n---\n\n\n### Download the sources\n\nYou should create a [Github](https://github.com/) account and\n[fork the repository](https://help.github.com/articles/fork-a-repo) (you will\nneed one to create the pull request).\n\nIf you just want the get the source code, you can use git and do\n`git clone https://github.com/Stuk/jszip.git` to get the sources. You can also\ndownload the latest sources [here](https://github.com/Stuk/jszip/archive/main.zip).\n\n### Building the project\n\n#### Code\n\nThe dependencies are handled by npm, the first step is to run\n`npm install` to get the dependencies.\nJSZip uses Grunt to handle the build, [see here to install its CLI](http://gruntjs.com/getting-started).\n\nHere are the interesting build commands :\n\n* `grunt` will generate the final js file in dist/ and the minified version.\n* `npm run test-node` will run the tests in nodejs.\n* `npm run test-browser` will the tests in some browsers using SauceLabs, see\n  below.\n* `npm run test` will run the tests in nodejs and in the browser.\n* `npm run lint` will use eslint the check the source code.\n\n#### Documentation\n\nThe documentation uses jekyll on gh-pages. To render the documentation, you\nneed to [install jekyll](http://jekyllrb.com/docs/installation/) and then run\n`jekyll serve --baseurl ''`.\n\n### Testing the project\n\nTo test JSZip in nodejs, use `npm run test-node`.\n\nTo test JSZip in a browser, you can open the file `test/index.html` in the\nbrowser you want to test. Don't forget to update the dist/ files with `grunt`.\n\nYou can also test JSZip in a lot of browsers at once with\n[SauceLabs](https://saucelabs.com/). You will need a SauceLabs account and two\nvariables into your environment. On linux, just use\n\n```bash\nexport SAUCE_USERNAME=your-saucelabs-username\nexport SAUCE_ACCESS_KEY=your-saucelabs-access-key\n```\n\nbefore running the `npm run test-browser` command.\n\n### Merging the changes\n\nIf you have tested bug fixes or new features, you can open a\n[pull request](https://help.github.com/articles/using-pull-requests) on Github.\n\n## Releasing a new version\n\n1. In `package.json` temporarily remove `browser[\"./lib/index\"]`.\n2. Run `npm test`\n    * Locally open http://localhost:8080/test/\n    * Or use the SauceLabs configuration above\n3. Update `JSZip.version` in `index.js`, `index.html` and in `package.json`\n4. Run `grunt` to generate the new dist files\n    * undo the package.json change, it was just needed to replace the `__VERSION__` in the header\n5. Undo step 1.\n6. Change version back in `package.json` (it will get update by the npm command below)\n7. Update CHANGES.md\n8. Commit the appropriate changes\n9. Run `npm version ...` where `...` is `major`, `minor`, or `patch`\n10. Run npm publish\n"
  },
  {
    "path": "documentation/css/main.css",
    "content": "ul.nav ul {\n  list-style:none;\n  margin: 0;\n  padding: 0 0 0 25px;\n}\n\n#downloader_application form {\n  margin-bottom: 10px;\n}\n\n#downloader_application ul {\n  list-style-type: none;\n}\n\n.browser_support th {\n  border-bottom-width: 3px !important;\n}\n\n.support_ie {border-bottom-color: #0275BA !important;}\n.support_ff {border-bottom-color: #DF7215 !important;}\n.support_sf {border-bottom-color: #43B3E9 !important;}\n.support_cr {border-bottom-color: #39B642 !important;}\n.support_op {border-bottom-color: #C42122 !important;}\n.support_nd {border-bottom-color: #8CC84B !important;}\n\n.show-example {\n    padding: 10px;\n    border: 1px solid #ccc;\n    border-radius: 4px;\n    margin: 0 0 10px;\n}\n\n.tab-pane > figure.highlight > pre, .tab-pane > .show-example {\n    border-radius: 0 0 4px 4px;\n    border-top: 0px;\n}\n"
  },
  {
    "path": "documentation/css/pygments.css",
    "content": "/* Generated with :\n * pygmentize -S default -f html > pygments.css\n */\n.hll { background-color: #ffffcc }\n.c { color: #408080; font-style: italic } /* Comment */\n.err { border: 1px solid #FF0000 } /* Error */\n.k { color: #008000; font-weight: bold } /* Keyword */\n.o { color: #666666 } /* Operator */\n.cm { color: #408080; font-style: italic } /* Comment.Multiline */\n.cp { color: #BC7A00 } /* Comment.Preproc */\n.c1 { color: #408080; font-style: italic } /* Comment.Single */\n.cs { color: #408080; font-style: italic } /* Comment.Special */\n.gd { color: #A00000 } /* Generic.Deleted */\n.ge { font-style: italic } /* Generic.Emph */\n.gr { color: #FF0000 } /* Generic.Error */\n.gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.gi { color: #00A000 } /* Generic.Inserted */\n.go { color: #888888 } /* Generic.Output */\n.gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.gs { font-weight: bold } /* Generic.Strong */\n.gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.gt { color: #0044DD } /* Generic.Traceback */\n.kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.kp { color: #008000 } /* Keyword.Pseudo */\n.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.kt { color: #B00040 } /* Keyword.Type */\n.m { color: #666666 } /* Literal.Number */\n.s { color: #BA2121 } /* Literal.String */\n.na { color: #7D9029 } /* Name.Attribute */\n.nb { color: #008000 } /* Name.Builtin */\n.nc { color: #0000FF; font-weight: bold } /* Name.Class */\n.no { color: #880000 } /* Name.Constant */\n.nd { color: #AA22FF } /* Name.Decorator */\n.ni { color: #999999; font-weight: bold } /* Name.Entity */\n.ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n.nf { color: #0000FF } /* Name.Function */\n.nl { color: #A0A000 } /* Name.Label */\n.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n.nt { color: #008000; font-weight: bold } /* Name.Tag */\n.nv { color: #19177C } /* Name.Variable */\n.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n.w { color: #bbbbbb } /* Text.Whitespace */\n.mf { color: #666666 } /* Literal.Number.Float */\n.mh { color: #666666 } /* Literal.Number.Hex */\n.mi { color: #666666 } /* Literal.Number.Integer */\n.mo { color: #666666 } /* Literal.Number.Oct */\n.sb { color: #BA2121 } /* Literal.String.Backtick */\n.sc { color: #BA2121 } /* Literal.String.Char */\n.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.s2 { color: #BA2121 } /* Literal.String.Double */\n.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n.sh { color: #BA2121 } /* Literal.String.Heredoc */\n.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n.sx { color: #008000 } /* Literal.String.Other */\n.sr { color: #BB6688 } /* Literal.String.Regex */\n.s1 { color: #BA2121 } /* Literal.String.Single */\n.ss { color: #19177C } /* Literal.String.Symbol */\n.bp { color: #008000 } /* Name.Builtin.Pseudo */\n.vc { color: #19177C } /* Name.Variable.Class */\n.vg { color: #19177C } /* Name.Variable.Global */\n.vi { color: #19177C } /* Name.Variable.Instance */\n.il { color: #666666 } /* Literal.Number.Integer.Long */\n"
  },
  {
    "path": "documentation/examples/download-zip-file.html",
    "content": "---\ntitle: \"Download the generated zip file\"\nlayout: default\nsection: example\n---\n\n<h2>The FileSaver API</h2>\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#file-saver-result\" aria-controls=\"file-saver-result\" role=\"tab\" data-toggle=\"tab\">\n            result\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#file-saver-js\" aria-controls=\"file-saver-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#file-saver-html\" aria-controls=\"file-saver-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"file-saver-result\">\n        <div class=\"show-example\">\n            {% include_relative download-zip-file.inc/blob.html %}\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"file-saver-js\">\n{% highlight js %}\n{% include_relative download-zip-file.inc/blob.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"file-saver-html\">\n{% highlight html %}\n{% include_relative download-zip-file.inc/blob.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<h2>The data URL</h2>\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#data-uri-result\" aria-controls=\"data-uri-result\" role=\"tab\" data-toggle=\"tab\">\n            result\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#data-uri-js\" aria-controls=\"data-uri-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#data-uri-html\" aria-controls=\"data-uri-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"data-uri-result\">\n        <div class=\"show-example\">\n            {% include_relative download-zip-file.inc/data_uri.html %}\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"data-uri-js\">\n{% highlight js %}\n{% include_relative download-zip-file.inc/data_uri.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"data-uri-html\">\n{% highlight html %}\n{% include_relative download-zip-file.inc/data_uri.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<script type=\"text/javascript\">\n(function () {\n    // Blob\n    if (JSZip.support.blob) {\n        {% include_relative download-zip-file.inc/blob.js %}\n    } else {\n        blobLink.innerHTML += \" (not supported on this browser)\";\n    }\n})();\n\n(function () {\n    // data URI\n    {% include_relative download-zip-file.inc/data_uri.js %}\n})();\n</script>\n"
  },
  {
    "path": "documentation/examples/download-zip-file.inc/blob.html",
    "content": "<p>Works on firefox, chrome , opera &gt;= 15 and IE &gt;= 10 (but NOT in compatibility view).</p>\n<button id=\"blob\" class=\"btn btn-primary\">click to download</button>\n"
  },
  {
    "path": "documentation/examples/download-zip-file.inc/blob.js",
    "content": "\"use strict\";\n\nvar zip = new JSZip();\nzip.file(\"Hello.txt\", \"Hello world\\n\");\n\njQuery(\"#blob\").on(\"click\", function () {\n    zip.generateAsync({type:\"blob\"}).then(function (blob) { // 1) generate the zip file\n        saveAs(blob, \"hello.zip\");                          // 2) trigger the download\n    }, function (err) {\n        jQuery(\"#blob\").text(err);\n    });\n});\n"
  },
  {
    "path": "documentation/examples/download-zip-file.inc/data_uri.html",
    "content": "<p>Does not work in IE, has restrictions on the length.</p>\n<button id=\"data_uri\" class=\"btn btn-primary\">click to download</button>\n\n"
  },
  {
    "path": "documentation/examples/download-zip-file.inc/data_uri.js",
    "content": "\"use strict\";\n\nvar zip = new JSZip();\nzip.file(\"Hello.txt\", \"Hello world\\n\");\n\njQuery(\"#data_uri\").on(\"click\", function () {\n    zip.generateAsync({type:\"base64\"}).then(function (base64) {\n        window.location = \"data:application/zip;base64,\" + base64;\n    }, function (err) {\n        jQuery(\"#data_uri\").text(err);\n    });\n});\n"
  },
  {
    "path": "documentation/examples/downloader.html",
    "content": "---\ntitle: \"Mini app : Downloader\"\nlayout: default\nsection: example\n---\n\n<p>\n  This mini application let you choose the files you want in a list, download\n  them, zip them and give the result to the user.\n</p>\n<p>\n  This demo requires a recent browser, see <a href=\"{{site.baseurl}}/documentation/howto/write_zip.html\">\n  the howto</a>.\n</p>\n<p>\n  This demo depends on the following libraries:\n  <ul>\n      <li><a href=\"https://jquery.com/\">jQuery</a> (to manipulate the DOM)</li>\n      <li><a href=\"https://github.com/stuk/jszip-utils\">JSZipUtils</a> (to download files)</li>\n      <li><a href=\"https://getbootstrap.com/\">bootstrap</a> (for the progress bar)</li>\n  </ul>\n</p>\n\n\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#downloader-result\" aria-controls=\"downloader-result\" role=\"tab\" data-toggle=\"tab\">\n            result\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#downloader-js\" aria-controls=\"downloader-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#downloader-helpers-js\" aria-controls=\"downloader-helpers-js\" role=\"tab\" data-toggle=\"tab\">\n            js helpers\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#downloader-html\" aria-controls=\"downloader-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"downloader-result\">\n        <div class=\"show-example\">\n            <div id=\"downloader_application\">\n                {% include_relative downloader.inc/downloader.html %}\n            </div>\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"downloader-js\">\n{% highlight js %}\n{% include_relative downloader.inc/downloader.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"downloader-helpers-js\">\n{% highlight js %}\n{% include_relative downloader.inc/helpers.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"downloader-html\">\n{% highlight html %}\n{% include_relative downloader.inc/downloader.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<script type=\"text/javascript\">\njQuery(function ($) {\n    {% include_relative downloader.inc/downloader.js %}\n    {% include_relative downloader.inc/helpers.js %}\n});\n</script>\n"
  },
  {
    "path": "documentation/examples/downloader.inc/downloader.html",
    "content": "<h3>Please select your files</h3>\n<form action=\"#\" id=\"download_form\">\n    <ul>\n        <li>\n            <label>\n                <input type=\"checkbox\" data-url=\"{{site.baseurl}}/test/ref/complex_files/Franz Kafka - The Metamorphosis.epub\" checked />\n                Franz Kafka - The Metamorphosis.epub\n            </label>\n        </li>\n        <li>\n            <label>\n                <input type=\"checkbox\" data-url=\"{{site.baseurl}}/documentation/css/pygments.css\" checked />\n                pygments.css\n            </label>\n        </li>\n        <li>\n            <label>\n                <input type=\"checkbox\" data-url=\"{{site.baseurl}}/dist/jszip.js\" />\n                jszip.js\n            </label>\n        </li>\n        <li>\n            <label>\n                <input type=\"checkbox\" data-url=\"{{site.baseurl}}/test/ref/all.zip\" />\n                all.zip\n            </label>\n        </li>\n    </ul>\n\n    <button type=\"submit\" class=\"btn btn-primary\">pack them !</button>\n</form>\n\n<div class=\"progress hide\" id=\"progress_bar\">\n    <div class=\"progress-bar\" role=\"progressbar\" aria-valuenow=\"0\" aria-valuemin=\"0\" aria-valuemax=\"100\" style=\"width: 0%;\">\n    </div>\n</div>\n\n<p class=\"hide\" id=\"result\"></p>\n\n\n"
  },
  {
    "path": "documentation/examples/downloader.inc/downloader.js",
    "content": "\"use strict\";\n// From helpers.js:\n/* global resetMessage, showMessage, showError, updatePercent */\n\n/**\n * Fetch the content and return the associated promise.\n * @param {String} url the url of the content to fetch.\n * @return {Promise} the promise containing the data.\n */\nfunction urlToPromise(url) {\n    return new Promise(function(resolve, reject) {\n        JSZipUtils.getBinaryContent(url, function (err, data) {\n            if(err) {\n                reject(err);\n            } else {\n                resolve(data);\n            }\n        });\n    });\n}\n\n$(\"#download_form\").on(\"submit\", function () {\n    resetMessage();\n\n    var zip = new JSZip();\n\n    // find every checked item\n    $(this).find(\":checked\").each(function () {\n        var $this = $(this);\n        var url = $this.data(\"url\");\n        var filename = url.replace(/.*\\//g, \"\");\n        zip.file(filename, urlToPromise(url), {binary:true});\n    });\n\n    // when everything has been downloaded, we can trigger the dl\n    zip.generateAsync({type:\"blob\"}, function updateCallback(metadata) {\n        var msg = \"progression : \" + metadata.percent.toFixed(2) + \" %\";\n        if(metadata.currentFile) {\n            msg += \", current file = \" + metadata.currentFile;\n        }\n        showMessage(msg);\n        updatePercent(metadata.percent|0);\n    })\n        .then(function callback(blob) {\n\n            // see FileSaver.js\n            saveAs(blob, \"example.zip\");\n\n            showMessage(\"done !\");\n        }, function (e) {\n            showError(e);\n        });\n\n    return false;\n});\n"
  },
  {
    "path": "documentation/examples/downloader.inc/helpers.js",
    "content": "\"use strict\";\n\n/**\n * Reset the message.\n */\nfunction resetMessage () {\n    $(\"#result\")\n        .removeClass()\n        .text(\"\");\n}\n/**\n * show a successful message.\n * @param {String} text the text to show.\n */\n// eslint-disable-next-line no-unused-vars\nfunction showMessage(text) {\n    resetMessage();\n    $(\"#result\")\n        .addClass(\"alert alert-success\")\n        .text(text);\n}\n/**\n * show an error message.\n * @param {String} text the text to show.\n */\nfunction showError(text) {\n    resetMessage();\n    $(\"#result\")\n        .addClass(\"alert alert-danger\")\n        .text(text);\n}\n/**\n * Update the progress bar.\n * @param {Integer} percent the current percent\n */\n// eslint-disable-next-line no-unused-vars\nfunction updatePercent(percent) {\n    $(\"#progress_bar\").removeClass(\"hide\")\n        .find(\".progress-bar\")\n        .attr(\"aria-valuenow\", percent)\n        .css({\n            width : percent + \"%\"\n        });\n}\n\nif(!JSZip.support.blob) {\n    showError(\"This demo works only with a recent browser !\");\n}\n"
  },
  {
    "path": "documentation/examples/get-binary-files-ajax.html",
    "content": "---\ntitle: \"Get a file with an ajax call\"\nlayout: default\nsection: example\n---\n\n<h3>With JSZipUtils</h3>\n\nNote: JSZipUtils is a library available <a href=\"https://github.com/stuk/jszip-utils\">here</a>.\n\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#jszip-utils-result\" aria-controls=\"jszip-utils-result\" role=\"tab\" data-toggle=\"tab\">\n            result\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#jszip-utils-js\" aria-controls=\"jszip-utils-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#jszip-utils-html\" aria-controls=\"jszip-utils-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"jszip-utils-result\">\n        <div class=\"show-example\">\n            {% include_relative get-binary-files-ajax.inc/jszip_utils.html %}\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"jszip-utils-js\">\n{% highlight js %}\n{% include_relative get-binary-files-ajax.inc/jszip_utils.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"jszip-utils-html\">\n{% highlight html %}\n{% include_relative get-binary-files-ajax.inc/jszip_utils.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<h3>With the Fetch API</h3>\n\nNote: the <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API\">\nFetch API</a> is a new javascript API which may not be available everywhere.\n\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#fetch-api-result\" aria-controls=\"fetch-api-result\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#fetch-api-js\" aria-controls=\"fetch-api-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#fetch-api-html\" aria-controls=\"fetch-api-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"fetch-api-result\">\n        <div class=\"show-example\">\n            {% include_relative get-binary-files-ajax.inc/fetch_api.html %}\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"fetch-api-js\">\n{% highlight js %}\n{% include_relative get-binary-files-ajax.inc/fetch_api.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"fetch-api-html\">\n{% highlight html %}\n{% include_relative get-binary-files-ajax.inc/fetch_api.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<script type=\"text/javascript\">\n(function () {\n\n  //=========================\n  // JSZipUtils\n  //=========================\n  (function () {\n      {% include_relative get-binary-files-ajax.inc/jszip_utils.js %}\n  })();\n\n  //=========================\n  // Fetch API\n  //=========================\n  (function () {\n    var elt = document.getElementById('fetch');\n    if(typeof window.fetch === \"function\") {\n      {% include_relative get-binary-files-ajax.inc/fetch_api.js %}\n    } else {\n        $(\"#fetch\").append($(\"<p>\", {\n            \"class\": \"alert alert-danger\",\n            text: \"This browser doesn't support the Fetch API.\"\n        }));\n    }\n  })();\n\n})();\n</script>\n"
  },
  {
    "path": "documentation/examples/get-binary-files-ajax.inc/fetch_api.html",
    "content": "<div id=\"fetch\"></div>\n"
  },
  {
    "path": "documentation/examples/get-binary-files-ajax.inc/fetch_api.js",
    "content": "\"use strict\";\n\nfetch(\"{{site.baseurl}}/test/ref/text.zip\")       // 1) fetch the url\n    .then(function (response) {                       // 2) filter on 200 OK\n        if (response.status === 200 || response.status === 0) {\n            return Promise.resolve(response.blob());\n        } else {\n            return Promise.reject(new Error(response.statusText));\n        }\n    })\n    .then(JSZip.loadAsync)                            // 3) chain with the zip promise\n    .then(function (zip) {\n        return zip.file(\"Hello.txt\").async(\"string\"); // 4) chain with the text content promise\n    })\n    .then(function success(text) {                    // 5) display the result\n        $(\"#fetch\").append($(\"<p>\", {\n            \"class\": \"alert alert-success\",\n            text: \"loaded, content = \" + text\n        }));\n    }, function error(e) {\n        $(\"#fetch\").append($(\"<p>\", {\n            \"class\": \"alert alert-danger\",\n            text: e\n        }));\n    });\n"
  },
  {
    "path": "documentation/examples/get-binary-files-ajax.inc/jszip_utils.html",
    "content": "<div id=\"jszip_utils\"></div>\n"
  },
  {
    "path": "documentation/examples/get-binary-files-ajax.inc/jszip_utils.js",
    "content": "\"use strict\";\n\n// 1) get a promise of the content\nvar promise = new JSZip.external.Promise(function (resolve, reject) {\n    JSZipUtils.getBinaryContent(\"{{site.baseurl}}/test/ref/text.zip\", function(err, data) {\n        if (err) {\n            reject(err);\n        } else {\n            resolve(data);\n        }\n    });\n});\n\npromise.then(JSZip.loadAsync)                     // 2) chain with the zip promise\n    .then(function(zip) {\n        return zip.file(\"Hello.txt\").async(\"string\"); // 3) chain with the text content promise\n    })\n    .then(function success(text) {                    // 4) display the result\n        $(\"#jszip_utils\").append($(\"<p>\", {\n            \"class\": \"alert alert-success\",\n            text: \"loaded, content = \" + text\n        }));\n    }, function error(e) {\n        $(\"#jszip_utils\").append($(\"<p>\", {\n            \"class\": \"alert alert-danger\",\n            text: e\n        }));\n    });\n"
  },
  {
    "path": "documentation/examples/read-local-file-api.html",
    "content": "---\ntitle: \"Reading a local file with the File API\"\nlayout: default\nsection: example\n---\n\n<ul class=\"nav nav-tabs\" role=\"tablist\">\n    <li role=\"presentation\" class=\"active\">\n        <a href=\"#load-result\" aria-controls=\"load-result\" role=\"tab\" data-toggle=\"tab\">\n            result\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#load-js\" aria-controls=\"load-js\" role=\"tab\" data-toggle=\"tab\">\n            js code\n        </a>\n    </li>\n    <li role=\"presentation\">\n        <a href=\"#load-html\" aria-controls=\"load-html\" role=\"tab\" data-toggle=\"tab\">\n            html code\n        </a>\n    </li>\n</ul>\n<div class=\"tab-content\">\n    <div role=\"tabpanel\" class=\"tab-pane active\" id=\"load-result\">\n        <div class=\"show-example\">\n            {% include_relative read-local-file-api.inc/read.html %}\n        </div>\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"load-js\">\n{% highlight js %}\n{% include_relative read-local-file-api.inc/read.js %}\n{% endhighlight %}\n    </div>\n    <div role=\"tabpanel\" class=\"tab-pane\" id=\"load-html\">\n{% highlight html %}\n{% include_relative read-local-file-api.inc/read.html %}\n{% endhighlight %}\n    </div>\n</div>\n\n<div id=\"error_block\" class=\"alert alert-danger hidden\">\n  You will need a recent browser to use this demo :(\n</div>\n<script type=\"text/javascript\">\n(function () {\n  if (!window.FileReader || !window.ArrayBuffer) {\n    $(\"#error_block\").removeClass(\"hidden\").addClass(\"show\");\n    return;\n  }\n\n{% include_relative read-local-file-api.inc/read.js %}\n\n})();\n</script>\n"
  },
  {
    "path": "documentation/examples/read-local-file-api.inc/read.html",
    "content": "<h3>Choose the local(s) zip file(s)</h3>\n<p class=\"note\">Note : your browser will process the zip file, don't choose a file too big !</p>\n<input type=\"file\" id=\"file\" name=\"file\" multiple /><br />\n\n<div id=\"result_block\" class=\"hidden\">\n  <h3>Content :</h3>\n  <div id=\"result\"></div>\n</div>\n\n"
  },
  {
    "path": "documentation/examples/read-local-file-api.inc/read.js",
    "content": "\"use strict\";\n\nvar $result = $(\"#result\");\n$(\"#file\").on(\"change\", function(evt) {\n    // remove content\n    $result.html(\"\");\n    // be sure to show the results\n    $(\"#result_block\").removeClass(\"hidden\").addClass(\"show\");\n\n    // Closure to capture the file information.\n    function handleFile(f) {\n        var $title = $(\"<h4>\", {\n            text : f.name\n        });\n        var $fileContent = $(\"<ul>\");\n        $result.append($title);\n        $result.append($fileContent);\n\n        var dateBefore = new Date();\n        JSZip.loadAsync(f)                                   // 1) read the Blob\n            .then(function(zip) {\n                var dateAfter = new Date();\n                $title.append($(\"<span>\", {\n                    \"class\": \"small\",\n                    text:\" (loaded in \" + (dateAfter - dateBefore) + \"ms)\"\n                }));\n\n                zip.forEach(function (relativePath, zipEntry) {  // 2) print entries\n                    $fileContent.append($(\"<li>\", {\n                        text : zipEntry.name\n                    }));\n                });\n            }, function (e) {\n                $result.append($(\"<div>\", {\n                    \"class\" : \"alert alert-danger\",\n                    text : \"Error reading \" + f.name + \": \" + e.message\n                }));\n            });\n    }\n\n    var files = evt.target.files;\n    for (var i = 0; i < files.length; i++) {\n        handleFile(files[i]);\n    }\n});\n"
  },
  {
    "path": "documentation/examples.md",
    "content": "---\ntitle: \"How to use JSZip\"\nlayout: default\nsection: example\n---\n\nAn instance of JSZip represents a set of files. You can add them, remove them,\nmodify them. You can also import an existing zip file or generate one.\n\n### Getting the object\n\n#### In a browser\n\nFor a browser, there are two interesting files : `dist/jszip.js` and\n`dist/jszip.min.js` (include just one).\n\nIf you use an AMD loader (RequireJS for example) JSZip will register itself :\nyou just have to put the js file at the right place, or configure the loader\n(see [here for RequireJS](http://requirejs.org/docs/api.html#config-paths)).\n\nWithout any loader, JSZip will declare in the global scope a variable named `JSZip`.\n\n#### In nodejs\n\nIn nodejs, you can `require` it :\n\n```js\nvar JSZip = require(\"jszip\");\n```\n\n### Basic manipulations\n\nThe first step is to create an instance of JSZip :\n\n```js\nvar zip = new JSZip();\n```\n\nOn this instance, we can add (and update) files and folders with\n`.file(name, content)` and `.folder(name)`.\nThey return the current JSZip instance so you can chain the calls.\n\n```js\n// create a file\nzip.file(\"hello.txt\", \"Hello[p my)6cxsw2q\");\n// oops, cat on keyboard. Fixing !\nzip.file(\"hello.txt\", \"Hello World\\n\");\n\n// create a file and a folder\nzip.file(\"nested/hello.txt\", \"Hello World\\n\");\n// same as\nzip.folder(\"nested\").file(\"hello.txt\", \"Hello World\\n\");\n```\n\nWith `.folder(name)`, the returned object has a different root : if you add files\non this object, you will put them in the created subfolder. This is just a\nview, the added files will also be in the \"root\" object.\n\n```js\nvar photoZip = zip.folder(\"photos\");\n// this call will create photos/README\nphotoZip.file(\"README\", \"a folder with photos\");\n```\n\nYou can access the file content with `.file(name)` and\n[its getters]({{site.baseurl}}/documentation/api_zipobject.html) :\n\n```js\nzip.file(\"hello.txt\").async(\"string\").then(function (data) {\n  // data is \"Hello World\\n\"\n});\n\nif (JSZip.support.uint8array) {\n  zip.file(\"hello.txt\").async(\"uint8array\").then(function (data) {\n    // data is Uint8Array { 0=72, 1=101, 2=108, more...}\n  });\n}\n```\n\nYou can also remove files or folders with `.remove(name)` :\n\n```js\nzip.remove(\"photos/README\");\nzip.remove(\"photos\");\n// same as\nzip.remove(\"photos\"); // by removing the folder, you also remove its content.\n```\n\n### Generate a zip file\n\nWith `.generateAsync(options)` or `.generateNodeStream(options)` you can generate\na zip file (not a real file but its representation in memory). Check\n[this page]({{site.baseurl}}/documentation/howto/write_zip.html) for more\ninformation on how to write / give the file to the user.\n\n```js\nvar promise = null;\nif (JSZip.support.uint8array) {\n  promise = zip.generateAsync({type : \"uint8array\"});\n} else {\n  promise = zip.generateAsync({type : \"string\"});\n}\n```\n\n### Read a zip file\n\nWith `.loadAsync(data)` you can load a zip file. Check\n[this page]({{site.baseurl}}/documentation/howto/read_zip.html) to see how to\ndo properly (it's more tricky that it seems).\n\n```js\nvar new_zip = new JSZip();\n// more files !\nnew_zip.loadAsync(content)\n.then(function(zip) {\n    // you now have every files contained in the loaded zip\n    zip.file(\"hello.txt\").async(\"string\"); // a promise of \"Hello World\\n\"\n});\n```\n\n"
  },
  {
    "path": "documentation/faq.md",
    "content": "---\ntitle: \"Frequently Asked Questions\"\nlayout: default\nsection: main\n---\n\n### \"Corrupted zip or bug: unexpected signature\"\n\nIf you are sure that the zip file is correct, that error often comes from a\ncorrupted content. An ajax request, if not prepared correctly, will try to\ndecode the binary content as a text and corrupt it. See\n[this page]({{site.baseurl}}/documentation/howto/read_zip.html).\n\n### My browser crashes / becomes unresponsive / never finish the execution\n\nThat happens if you try to handle to much data with the synchronous API. If\npossible, try the asynchronous API, see\n[this page]({{site.baseurl}}/documentation/limitations.html) for more information.\n\n### Can't read the data of [...]. Is it in a supported JavaScript type ?\n\nOr the old message:\n\n> The data of [...] is in an unsupported format\n\nThe method [`file(name, data [,options])`]({{site.baseurl}}/documentation/api_jszip/file_data.html)\naccepts string and binary inputs for `data`.\n\nIf you use an unsupported type, an object for example, you will get this error:\n\n```js\n// WRONG\nvar data = {\n    content: new ArrayBuffer(...)\n};\nzip.file(\"my.data\", data); // won't work, data is an object\n\n// CORRECT\nvar data = new ArrayBuffer(...);\nzip.file(\"my.data\", data); // will work, JSZip accepts ArrayBuffer\n```\n\n### My mac generates a `.cpgz` file when I try to extract the zip file\n\nMacOS Finder has a lot of bug related to zip files (the `unzip` command line\ntool is fine). When something goes wrong, Finder will generate this cpgz file\ninstead of showing an error.\n\nTo get a correct result, try to enable compression in `generateAsync`:\n\n```js\nzip.generateAsync({\n    type:\"...\",\n    compression: \"DEFLATE\" // <-- here\n});\n```\n\nUsing `platform: \"UNIX\"` may help too.\n"
  },
  {
    "path": "documentation/howto/read_zip.md",
    "content": "---\ntitle: \"How to read a file\"\nlayout: default\nsection: example\n---\n\nThis page explains how to read an existing zip file or add a existing file into\nthe zip file.\n\n\n### In the browser\n\n#### AJAX request\n\nGetting binary data with an ajax request is hard (mainly because of IE <= 9).\nThe easy way is to use [JSZipUtils.getBinaryContent](https://github.com/stuk/jszip-utils).\nWith JSZipUtils.getBinaryContent, you can do the following (see the\ndocumentation for more examples) :\n\n```js\nJSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {\n    if(err) {\n        throw err; // or handle err\n    }\n\n    JSZip.loadAsync(data).then(function () {\n        // ...\n    });\n});\n\n// or, with promises:\n\nnew JSZip.external.Promise(function (resolve, reject) {\n    JSZipUtils.getBinaryContent('path/to/content.zip', function(err, data) {\n        if (err) {\n            reject(err);\n        } else {\n            resolve(data);\n        }\n    });\n}).then(function (data) {\n    return JSZip.loadAsync(data);\n})\n.then(...)\n```\n\n<br>\n\nIf you need to adapt an existing solution to what getBinaryContent does, here\nare the details. When doing a XHR request (level 1, without setting the\n`responseType`) the browser will try to interpret the response as a string and\ndecode it from its charset. To avoid this on Firefox/Chrome/Opera, you need to\nset mime type : `xhr.overrideMimeType(\"text/plain; charset=x-user-defined\");`.\nOn IE <= 9, this is harder. The overrideMimeType trick doesn't work so we need\nto use [vbscript](http://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest)\nand non standard attributes.\nOn IE > 9, overrideMimeType doesn't work but xhr2 does.\n\nWith [xhr 2](http://caniuse.com/xhr2), you can just set the responseType\nattribute : `xhr.responseType = \"arraybuffer\";`. With this, the browser will\nreturn an ArrayBuffer.\n\n#### Local files\n\nIf the browser supports the [FileReader API](http://caniuse.com/filereader),\nyou can use it to read a zip file. JSZip can read ArrayBuffer, so you can use\n`FileReader.readAsArrayBuffer(Blob)`, see this [example]({{site.baseurl}}/documentation/examples/read-local-file-api.html).\n\n### In nodejs\n\nJSZip can read Buffers so you can do the following :\n\n#### Local file\n\n```js\n\"use strict\";\n\nvar fs = require(\"fs\");\nvar JSZip = require(\"jszip\");\n\n// read a zip file\nfs.readFile(\"test.zip\", function(err, data) {\n    if (err) throw err;\n    JSZip.loadAsync(data).then(function (zip) {\n        // ...\n    });\n});\n// or\nnew JSZip.external.Promise(function (resolve, reject) {\n    fs.readFile(\"test.zip\", function(err, data) {\n        if (err) {\n            reject(e);\n        } else {\n            resolve(data);\n        }\n    });\n}).then(function (data) {\n    return JSZip.loadAsync(data);\n})\n.then(...)\n\n\n// read a file and add it to a zip\nfs.readFile(\"picture.png\", function(err, data) {\n    if (err) throw err;\n    var zip = new JSZip();\n    zip.file(\"picture.png\", data);\n});\n// or\nvar contentPromise = new JSZip.external.Promise(function (resolve, reject) {\n    fs.readFile(\"picture.png\", function(err, data) {\n        if (err) {\n            reject(e);\n        } else {\n            resolve(data);\n        }\n    });\n});\nzip.file(\"picture.png\", contentPromise);\n\n\n// read a file as a stream and add it to a zip\nvar stream = fs.createReadStream(\"picture.png\");\nzip.file(\"picture.png\", stream);\n```\n\n#### Remote file\n\nThere are a lot of nodejs libraries doing http requests, from the built-in\n[http](http://nodejs.org/docs/latest/api/http.html) to the\n[npm packages](https://www.npmjs.org/browse/keyword/http). Here are two\nexamples, one with the default http API, the other with\n[request](https://github.com/mikeal/request) (but you're free to use your\nfavorite library !). If possible, download the file as a Buffer (you will get\nbetter performances). If it's not possible, you can fallback to a binary string\n(the option is likely to be `encoding : \"binary\"`).\n\n##### With http :\n\n```js\n\"use strict\";\n\nvar http = require(\"http\");\nvar url = require(\"url\");\nvar JSZip = require(\"jszip\");\n\nvar req = http.get(url.parse(\"http://localhost/.../file.zip\"), function (res) {\n  if (res.statusCode !== 200) {\n    console.log(res.statusCode);\n    // handle error\n    return;\n  }\n  var data = [], dataLen = 0;\n\n  // don't set the encoding, it will break everything !\n  // or, if you must, set it to null. In that case the chunk will be a string.\n\n  res.on(\"data\", function (chunk) {\n    data.push(chunk);\n    dataLen += chunk.length;\n  });\n\n  res.on(\"end\", function () {\n    var buf = Buffer.concat(data);\n\n    // here we go !\n    JSZip.loadAsync(buf).then(function (zip) {\n      return zip.file(\"content.txt\").async(\"string\");\n    }).then(function (text) {\n      console.log(text);\n    });\n  });\n});\n\nreq.on(\"error\", function(err){\n  // handle error\n});\n```\n\n##### With request :\n\n```js\n\"use strict\";\n\nvar request = require('request');\nvar JSZip = require(\"jszip\");\n\nrequest({\n  method : \"GET\",\n  url : \"http://localhost/.../file.zip\",\n  encoding: null // <- this one is important !\n}, function (error, response, body) {\n  if(error ||  response.statusCode !== 200) {\n    // handle error\n    return;\n  }\n  JSZip.loadAsync(body).then(function (zip) {\n    return zip.file(\"content.txt\").async(\"string\");\n  }).then(function (text) {\n    console.log(text);\n  });\n});\n```\n"
  },
  {
    "path": "documentation/howto/write_zip.md",
    "content": "---\ntitle: \"How to write a file / give it to the user\"\nlayout: default\nsection: example\n---\n\n### In the browser\n\nWith only javascript, this part won't work in old browsers, including IE < 10.\nFor those browsers, you can use a flash polyfill, see below.\n\nYou can also see this\n[example]({{site.baseurl}}/documentation/examples/download-zip-file.html).\n\n#### Blob URL / FileSaver\n\nWith recent browsers, the easiest way is to use `saveAs` or a polyfill, see\n[FileSaver.js](https://github.com/eligrey/FileSaver.js) :\n\n```js\nzip.generateAsync({type:\"blob\"})\n.then(function (blob) {\n    saveAs(blob, \"hello.zip\");\n});\n```\n\nUnder the hood, the polyfill uses the native `saveAs` from the\n[FileSaver](http://www.w3.org/TR/file-writer-api/#the-filesaver-interface) API\n(on Chrome and IE10+) or use a [Blob URL](http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download)\n(on Firefox).\n\n\n#### Data URI\n\nFor older browsers that support [data URI](http://caniuse.com/datauri), you can also\ndo the following :\n\n```js\nzip.generateAsync({type:\"base64\"}).then(function (base64) {\n    location.href=\"data:application/zip;base64,\" + base64;\n});\n```\n\nThe biggest issue here is that the filenames are very awkward, Firefox\ngenerates filenames such as `a5sZQRsx.zip.part` (see bugs\n[367231](https://bugzilla.mozilla.org/show_bug.cgi?id=367231) and\n[532230](https://bugzilla.mozilla.org/show_bug.cgi?id=532230), and Safari\nisn't much better with just `Unknown`.\n\nBrowser support and resulting filename :\n\nOpera  | Firefox | Safari | Chrome | Internet Explorer\n-------|---------|--------|--------|------------------\n\"default.zip\" | random alphanumeric with \".part\" extension | \"Unknown\" (no extension) | \"download.zip\" on OSX and Linux, just \"download\" on Windows | No\n\n#### Downloadify\n\n[Downloadify](https://github.com/dcneiner/downloadify) uses a small Flash SWF\nto download files to a user's computer with a filename that you can choose.\nDoug Neiner has added the `dataType` option to allow you to pass a zip for\ndownloading. Follow the [Downloadify demo](http://pixelgraphics.us/downloadify/test.html)\nwith the following changes:\n\n```js\nzip = new JSZip();\nzip.file(\"Hello.\", \"hello.txt\");\n\nzip.generateAsync({type:\"base64\"}).then(function (base64) {\n    Downloadify.create('downloadify',{\n    ...\n    data: function(){\n        return base64;\n    },\n    ...\n    dataType: 'base64'\n    });\n});\n```\n\n<!--\nTODO : send data as GET / POST ?\n-->\n\n#### Deprecated google gears\n\n[Franz Buchinger](http://www.picurl.org/blog/author/franz/) has written a\nbrilliant tutorial on [using JSZip with Google Gears](http://www.picurl.org/blog/2009/11/22/creating-zip-archives-with-gears)\n([part 2](http://www.picurl.org/blog/2009/11/29/gearszipper-part2-adding-support-for-real-files-and-canvas-elements/)).\nIf you want to let your Gears users download several files at once I really\nrecommend having a look at some of his [examples](http://picurl.org/gears/zipper/).\n\n\n\n### In nodejs\n\nJSZip can generate Buffers so you can do the following :\n\n```js\nvar fs = require(\"fs\");\nvar JSZip = require(\"jszip\");\n\nvar zip = new JSZip();\n// zip.file(\"file\", content);\n// ... and other manipulations\n\nzip\n.generateNodeStream({type:'nodebuffer',streamFiles:true})\n.pipe(fs.createWriteStream('out.zip'))\n.on('finish', function () {\n    // JSZip generates a readable stream with a \"end\" event,\n    // but is piped here in a writable stream which emits a \"finish\" event.\n    console.log(\"out.zip written.\");\n});\n```\n\n\n"
  },
  {
    "path": "documentation/limitations.md",
    "content": "---\ntitle: \"Limitations of JSZip\"\nlayout: default\nsection: limitations\nfullpage: true\n---\n\n### Not supported features\n\nNot all features of zip files are supported. Classic zip files will work\nbut encrypted zip, multi-volume, etc are not supported and the loadAsync()\nmethod will return a failed promise.\n\n\n### ZIP64 and 32bit integers\n\nZIP64 files can be loaded, but only if the zip file is not \"too big\". ZIP64 uses 64bits integers\nbut JavaScript represents all numbers as\n[64-bit double precision IEEE 754 floating point numbers](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)\n(see section 8.5). So, we have 53bits for integers and\n[bitwise operations treat everything as 32bits](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators).\nSo if all the 64bits integers can fit into 32 bits integers, everything will be\nfine. If it's not the case, you will have other problems anyway (see next\nlimitation).\n\n### Performance issues\n\nAn other limitation comes from the browser (and the machine running the\nbrowser). A compressed zip file of 10MB is easily opened by firefox / chrome\n/ opera / IE10+ but will crash older IE. Also keep in mind that strings in\njavascript are encoded in UTF-16 : a 10MB ascii text file will take 20MB of\nmemory.\n\nThe\n[`async` method]({{site.baseurl}}/documentation/api_zipobject/async.html) and the\n[`generateAsync` method]({{site.baseurl}}/documentation/api_jszip/generate_async.html)\nhold the full result in memory but doesn't freeze the browser. If the result\nis too big, and if you can't use the\n[`nodeStream` method]({{site.baseurl}}/documentation/api_zipobject/node_stream.html) or the\n[`generateNodeStream` method]({{site.baseurl}}/documentation/api_jszip/generate_node_stream.html)\nyou need to use the underlying\n[`StreamHelper`]({{site.baseurl}}/documentation/api_streamhelper.html) to\nhandle the result chunk by chunk and `pause()`/`resume()` to handle the\nbackpressure.\n\nIf you're having performance issues, please consider the following :\n\n* Don't use IE &lt;= 9. Everything is better with typed arrays.\n* Use typed arrays (Uint8Array, ArrayBuffer, etc) if possible :\n  * If you generate a zip file, you should use `type:\"uint8array\"`\n    (or blob, arraybuffer, nodebuffer).\n  * If you load the file from an ajax call, ask your XHR an ArrayBuffer.\n    Loading a string is asking for troubles.\n\nNote about compression :\nWhen reading a file, JSZip will store the content without decompressing it.\nWhen generating a compressed file, JSZip will reuse if possible the compressed\ncontent :\n\n* If you read a zip file compressed with DEFLATE and call `generate` with the\n  DEFLATE compression, JSZip won't call the compression algorithms (same with\n  STORE everywhere.)\n* If you read a zip file compressed with DEFLATE and call `generate` with the\n  STORE compression, JSZip will have to decompress everything.\n\nOn IE &lt;=9, typed arrays are not supported and the compression algorithm\nwill fallback on arrays. In that case, JSZip needs to convert the binary string\ninto an array, DEFLATE it and convert the result into a binary string.\nYou don't want that to happen.\n\n### The output zip will differ from the input zip\n\nReading and generating a zip file won't give you back the same file.\nSome data are discarded (file metadata) and other are added (subfolders).\n\n### Encodings support\n\nJSZip only supports UTF-8 natively. A zip file doesn't contain the name of the\nencoding used, you need to know it before doing anything.\n\n#### File name\n\nIf the name of a file inside the zip is encoded with UTF-8 then JSZip can\ndetect it (Language encoding flag, Unicode Path Extra Field). If not, JSZip\ncan't detect the encoding used and will generate [Mojibake](https://en.wikipedia.org/wiki/Mojibake).\nYou can use the [encodeFileName]({{site.baseurl}}/documentation/api_jszip/generate.html)\noption and the [decodeFileName]({{site.baseurl}}/documentation/api_jszip/load.html)\noption to encode/decode using a custom encoding.\n\n#### File content\n\nThe `async(\"string\")` method uses UTF-8 to decode the content. If you have a text in\na different encoding, you can get the bytes array with `async(\"uint8array\")` and\ndecode it with a lib (iconv, iconv-lite, etc) on your side.\nTo save a text using a non-UTF-8 encoding, do the same : encode it into a\nUint8Array before adding it to JSZip.\n"
  },
  {
    "path": "documentation/upgrade_guide.md",
    "content": "---\ntitle: Upgrade Guide\nlayout: default\nsection: main\n---\n\n### From 2.x to 3.0.0\n\n* Deprecated objects/methods has been removed:\n  * `options.base64` in `generate()` (the base64 type is still valid)\n  * `options.base64`, `options.binary`, `options.dir`, `options.date`\n    on `ZipObject` (see the [2.3 upgrade section](#from-222-to-230))\n  * `JSZip.utils`\n  * `JSZip.prototype.crc32`, `JSZip.prototype.utf8encode`, `JSZip.prototype.utf8decode`\n  * `JSZip.base64` (you can get the content of a file directly as a base64 string)\n* `JSZip.compressions` has been removed.\n* On `ZipObject`, the synchronous getters has been replaced by `async()` and\n  `nodeStream()`.\n* The `generate()` method has been replaced by `generateAsync()` and \n  `generateNodeStream()`.\n* The `type` option in `generate()` is now mandatory.\n* The \"text\" type has been replaced by the \"string\" type, a binary string is\n  named \"binarystring\".\n* The `load()` method and the constructor with data (`new JSZip(data)`) have\n  been replaced by `loadAsync()`.\n* When adding a file, the option `createFolders` now defaults to `true`. If\n  you don't want to create sub folders, set it to false.\n* `zip.generateAsync()` and `zip.generateNodeStream()` now depend on the\n  current folder level.\n\n```js\n// 2.x\nzip.file(\"test.txt\").asText();\n// 3.x\nzip.file(\"test.txt\").async(\"string\")\n.then(function (content) {\n    // use content\n});\n\n\n// 2.x\nzip.generate();\n// 3.x\nzip.generateAsync({type:\"uint8array\"})\n.then(function (content) {\n    // use content\n});\n\n// 2.x\nnew JSZip(data);\nzip.load(data);\n// zip.file(...)\n// 3.x\nJSZip.loadAsync(data).then(zip) {...};\nzip.loadAsync(data).then(zip) {...};\n// here, zip won't have (yet) the updated content\n\n// 2.x\nvar data = zip.file(\"img.jpg\").asBinary();\nvar dataURI = \"data:image/jpeg;base64,\" + JSZip.base64.encode(data);\n// 3.x\nzip.file(\"img.jpg\").async(\"base64\")\n.then(function (data64) {\n    var dataURI = \"data:image/jpeg;base64,\" + data64;\n});\n```\n\n`async` and `loadAsync` use (a polyfill of) promises, you can find\nthe documentation [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\nand a tutorial [here](http://www.html5rocks.com/en/tutorials/es6/promises/).\n\nIt is worth noting that:\n\n```js\n/*\n * JSZip accepts these promise as input\n */\n\n// replace a content with JSZip v2\nvar content = zip.file(\"my_file\").asText();\ncontent = content.replace(/apples/, 'oranges');\nzip.file(\"my_file\", content);\n\n// replace a content with JSZip v3\nvar contentPromise = zip.file(\"my_file\").async(\"text\").then(function (content) {\n    return content.replace(/apples/, 'oranges');\n});\nzip.file(\"my_file\", contentPromise);\n\n\n/*\n * Promises are chainable\n */\n\n// read, update, generate a zip file with JSZip v2\nvar zip = new JSZip(content);\nzip.file(\"new_file\", \"new_content\");\nvar blob = zip.generate({type: \"blob\"});\nsaveAs(blob, \"result.zip\");\n\n// read, update, generate a zip file with JSZip v3\nJSZip.loadAsync(content)\n.then(function (zip) {\n    zip.file(\"new_file\", \"new_content\");\n    // if you return the zip object, it will be available in the next \"then\"\n    return zip;\n.then(function (zip) {\n    // if you return a promise of a blob, promises will \"merge\": the current\n    // promise will wait for the other and the next \"then\" will get the\n    // blob\n    return zip.generateAsync({type: \"blob\"});\n.then(function (blob) {\n    saveAs(blob, \"result.zip\");\n});\n```\n\n### From 2.2.2 to 2.3.0\n\n* On `ZipObject#options`, the attributes `date` and `dir` have been\n  deprecated and are now on `ZipObject`.\n* On `ZipObject#options`, the attributes `base64` and `binary` have been\n  deprecated.\n* `JSZip.base64`, `JSZip.prototype.crc32`, `JSZip.prototype.utf8decode`,\n  `JSZip.prototype.utf8encode` and `JSZip.utils` have been deprecated.\n\n```js\n// deprecated\nzip.file(\"test.txt\").options.date\nzip.file(\"test.txt\").options.dir\n// new API\nzip.file(\"test.txt\").date\nzip.file(\"test.txt\").dir\n```\n\n\n### From 2.0.0 to 2.1.0\n\n* The packaging changed : instead of loading jszip.js, jszip-load.js,\n  jszip-inflate.js, jszip-deflate.js, just include dist/jszip.js or\n  dist/jszip.min.js.\n  For AMD loader users : JSZip now registers itself. You just have to put the\n  file at the right place or configure your loader.\n\n\n### From 1.x to 2.x\n\n* `JSZipBase64` has been renamed to `JSZip.base64`.\n* The `data` attribute doesn't exist anymore :\n  use the getters `asText()`, `asBinary()`, etc\n* The compression/decompression methods now give their input type with the\n  `compressInputType` and `uncompressInputType` attributes.\n\nExample for the data attribute :\n\n```js\n// before\nzip.file(\"test.txt\").data;\nzip.files[\"test.txt\"].data;\nzip.file(\"image.png\").data;\nzip.files[\"image.png\"].data;\n\n// after\nzip.file(\"test.txt\").asText();\nzip.files[\"test.txt\"].asText();\nzip.file(\"image.png\").asBinary();\nzip.files[\"image.png\"].asBinary();\n```\n"
  },
  {
    "path": "index.d.ts",
    "content": "// Type definitions for JSZip 3.1\n// Project: http://stuk.github.com/jszip/, https://github.com/stuk/jszip\n// Definitions by: mzeiher <https://github.com/mzeiher>, forabi <https://github.com/forabi>\n// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped\n// TypeScript Version: 2.3\n\n/// <reference types=\"node\" />\n\ninterface JSZipSupport {\n    arraybuffer: boolean;\n    uint8array: boolean;\n    blob: boolean;\n    nodebuffer: boolean;\n}\n\ntype Compression = 'STORE' | 'DEFLATE';\n\n/**\n * Depends on the compression type. With `STORE` (no compression), these options are ignored. With\n * `DEFLATE`, you can give the compression level between 1 (best speed) and 9 (best compression).\n */\ninterface CompressionOptions {\n    level: number;\n}\n\ninterface InputByType {\n    base64: string;\n    string: string;\n    text: string;\n    binarystring: string;\n    array: number[];\n    uint8array: Uint8Array;\n    arraybuffer: ArrayBuffer;\n    blob: Blob;\n    stream: NodeJS.ReadableStream;\n}\n\ninterface OutputByType {\n    base64: string;\n    string: string;\n    text: string;\n    binarystring: string;\n    array: number[];\n    uint8array: Uint8Array;\n    arraybuffer: ArrayBuffer;\n    blob: Blob;\n    nodebuffer: Buffer;\n}\n\n// This private `_data` property on a JSZipObject uses this interface.\n// If/when it is made public this should be uncommented.\n// interface CompressedObject {\n//     compressedSize: number;\n//     uncompressedSize: number;\n//     crc32: number;\n//     compression: object;\n//     compressedContent: string|ArrayBuffer|Uint8Array|Buffer;\n// }\n\ntype InputFileFormat = InputByType[keyof InputByType] | Promise<InputByType[keyof InputByType]>;\n\ndeclare namespace JSZip {\n    type InputType = keyof InputByType;\n\n    type OutputType = keyof OutputByType;\n\n    interface JSZipMetadata {\n        percent: number;\n        currentFile: string | null;\n    }\n\n    type OnUpdateCallback = (metadata: JSZipMetadata) => void;\n\n    interface JSZipObject {\n        name: string;\n        /**\n         * Present for files loadded with `loadAsync`. May contain \"..\" path components that could\n         * result in a zip-slip attack. See https://snyk.io/research/zip-slip-vulnerability\n         */\n        unsafeOriginalName?: string;\n        dir: boolean;\n        date: Date;\n        comment: string;\n        /** The UNIX permissions of the file, if any. */\n        unixPermissions: number | string | null;\n        /** The UNIX permissions of the file, if any. */\n        dosPermissions: number | null;\n        options: JSZipObjectOptions;\n\n        /**\n         * Prepare the content in the asked type.\n         * @param type the type of the result.\n         * @param onUpdate a function to call on each internal update.\n         * @return Promise the promise of the result.\n         */\n        async<T extends OutputType>(type: T, onUpdate?: OnUpdateCallback): Promise<OutputByType[T]>;\n        nodeStream(type?: 'nodebuffer', onUpdate?: OnUpdateCallback): NodeJS.ReadableStream;\n    }\n\n    interface JSZipFileOptions {\n        /** Set to `true` if the data is `base64` encoded. For example image data from a `<canvas>` element. Plain text and HTML do not need this option. */\n        base64?: boolean;\n        /**\n         * Set to `true` if the data should be treated as raw content, `false` if this is a text. If `base64` is used,\n         * this defaults to `true`, if the data is not a `string`, this will be set to `true`.\n         */\n        binary?: boolean;\n        /**\n         * The last modification date, defaults to the current date.\n         */\n        date?: Date;\n        /**\n         * Sets per file compression. The `compressionOptions` parameter depends on the compression type.\n         */\n        compression?: Compression;\n        /**\n         * Sets per file compression level for `DEFLATE` compression.\n         */\n        compressionOptions?: null | CompressionOptions;\n        comment?: string;\n        /** Set to `true` if (and only if) the input is a \"binary string\" and has already been prepared with a `0xFF` mask. */\n        optimizedBinaryString?: boolean;\n        /** Set to `true` if folders in the file path should be automatically created, otherwise there will only be virtual folders that represent the path to the file. */\n        createFolders?: boolean;\n        /** Set to `true` if this is a directory and content should be ignored. */\n        dir?: boolean;\n\n        /** 6 bits number. The DOS permissions of the file, if any. */\n        dosPermissions?: number | null;\n        /**\n         * 16 bits number. The UNIX permissions of the file, if any.\n         * Also accepts a `string` representing the octal value: `\"644\"`, `\"755\"`, etc.\n         */\n        unixPermissions?: number | string | null;\n    }\n\n    interface JSZipObjectOptions {\n        compression: Compression;\n    }\n\n    interface JSZipGeneratorOptions<T extends OutputType = OutputType> {\n        /**\n         * Sets compression option for all entries that have not specified their own `compression` option\n         */\n        compression?: Compression;\n        /**\n         * Sets compression level for `DEFLATE` compression.\n         */\n        compressionOptions?: null | CompressionOptions;\n        type?: T;\n        comment?: string;\n        /**\n         * mime-type for the generated file.\n         * Useful when you need to generate a file with a different extension, ie: “.ods”.\n         * @default 'application/zip'\n         */\n        mimeType?: string;\n        encodeFileName?(filename: string): string;\n        /** Stream the files and create file descriptors */\n        streamFiles?: boolean;\n        /** DOS (default) or UNIX */\n        platform?: 'DOS' | 'UNIX';\n    }\n\n    interface JSZipLoadOptions {\n        base64?: boolean;\n        checkCRC32?: boolean;\n        optimizedBinaryString?: boolean;\n        createFolders?: boolean;\n        decodeFileName?: (bytes: string[] | Uint8Array | Buffer) => string;\n    }\n\n    type DataEventCallback<T> = (dataChunk: T, metadata: JSZipMetadata) => void\n    type EndEventCallback = () => void\n    type ErrorEventCallback = (error: Error) => void\n\n    interface JSZipStreamHelper<T> {\n        /**\n         * Register a listener on an event\n         */\n        on(event: 'data', callback: DataEventCallback<T>): this;\n        on(event: 'end', callback: EndEventCallback): this;\n        on(event: 'error', callback: ErrorEventCallback): this;\n\n        /**\n         * Read the whole stream and call a callback with the complete content\n         *\n         * @param updateCallback The function called every time the stream updates\n         * @return A Promise of the full content\n         */\n        accumulate(updateCallback?: (metadata: JSZipMetadata) => void): Promise<T>;\n\n        /**\n         * Resume the stream if the stream is paused. Once resumed, the stream starts sending data events again\n         *\n         * @return The current StreamHelper object, for chaining\n         */\n        resume(): this;\n\n        /**\n         * Pause the stream if the stream is running. Once paused, the stream stops sending data events\n         *\n         * @return The current StreamHelper object, for chaining\n         */\n        pause(): this;\n    }\n}\n\ninterface JSZip {\n    files: {[key: string]: JSZip.JSZipObject};\n\n    /**\n     * Get a file from the archive\n     *\n     * @param Path relative path to file\n     * @return File matching path, null if no file found\n     */\n    file(path: string): JSZip.JSZipObject | null;\n\n    /**\n     * Get files matching a RegExp from archive\n     *\n     * @param path RegExp to match\n     * @return Return all matching files or an empty array\n     */\n    file(path: RegExp): JSZip.JSZipObject[];\n\n    /**\n     * Add a file to the archive\n     *\n     * @param path Relative path to file\n     * @param data Content of the file\n     * @param options Optional information about the file\n     * @return JSZip object\n     */\n    file<T extends JSZip.InputType>(path: string, data: InputByType[T] | Promise<InputByType[T]>, options?: JSZip.JSZipFileOptions): this;\n    file<T extends JSZip.InputType>(path: string, data: null, options?: JSZip.JSZipFileOptions & { dir: true }): this;\n\n    /**\n     * Returns an new JSZip instance with the given folder as root\n     *\n     * @param name Name of the folder\n     * @return New JSZip object with the given folder as root or null\n     */\n    folder(name: string): JSZip | null;\n\n    /**\n     * Returns new JSZip instances with the matching folders as root\n     *\n     * @param name RegExp to match\n     * @return New array of JSZipFile objects which match the RegExp\n     */\n    folder(name: RegExp): JSZip.JSZipObject[];\n\n    /**\n     * Call a callback function for each entry at this folder level.\n     *\n     * @param callback function\n     */\n    forEach(callback: (relativePath: string, file: JSZip.JSZipObject) => void): void;\n\n    /**\n     * Get all files which match the given filter function\n     *\n     * @param predicate Filter function\n     * @return Array of matched elements\n     */\n    filter(predicate: (relativePath: string, file: JSZip.JSZipObject) => boolean): JSZip.JSZipObject[];\n\n    /**\n     * Removes the file or folder from the archive\n     *\n     * @param path Relative path of file or folder\n     * @return Returns the JSZip instance\n     */\n    remove(path: string): JSZip;\n\n    /**\n     * Generates a new archive asynchronously\n     *\n     * @param options Optional options for the generator\n     * @param onUpdate The optional function called on each internal update with the metadata.\n     * @return The serialized archive\n     */\n    generateAsync<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>, onUpdate?: JSZip.OnUpdateCallback): Promise<OutputByType[T]>;\n\n    /**\n     * Generates a new archive asynchronously\n     *\n     * @param options Optional options for the generator\n     * @param onUpdate The optional function called on each internal update with the metadata.\n     * @return A Node.js `ReadableStream`\n     */\n    generateNodeStream(options?: JSZip.JSZipGeneratorOptions<'nodebuffer'>, onUpdate?: JSZip.OnUpdateCallback): NodeJS.ReadableStream;\n\n    /**\n     * Generates the complete zip file with the internal stream implementation\n     *\n     * @param options Optional options for the generator\n     * @return a StreamHelper\n     */\n    generateInternalStream<T extends JSZip.OutputType>(options?: JSZip.JSZipGeneratorOptions<T>): JSZip.JSZipStreamHelper<OutputByType[T]>;\n\n    /**\n     * Deserialize zip file asynchronously\n     *\n     * @param data Serialized zip file\n     * @param options Options for deserializing\n     * @return Returns promise\n     */\n    loadAsync(data: InputFileFormat, options?: JSZip.JSZipLoadOptions): Promise<JSZip>;\n\n    /**\n     * Create JSZip instance\n     */\n    new(): this;\n\n    (): JSZip;\n\n    prototype: JSZip;\n    support: JSZipSupport;\n    external: {\n        Promise: PromiseConstructorLike;\n    };\n    version: string;\n}\n\ndeclare var JSZip: JSZip;\n\nexport = JSZip;\n"
  },
  {
    "path": "index.html",
    "content": "---\ntitle: JSZip\nlayout: default\nsection: main\n---\n\n<div class=\"row\">\n<div class=\"col-md-5\">\n\nJSZip is a javascript library for creating, reading and editing .zip files, with a\nlovely and simple API.\n\n</div>\n<div class=\"col-md-7\">\n<p>\n  <strong>Current version</strong> : v3.10.1\n</p>\n<p>\n  <strong>License</strong> : JSZip is dual-licensed. You may use it under the\n  MIT license <em>or</em> the GPLv3 license. See\n  <a href=\"https://github.com/Stuk/jszip/blob/main/LICENSE.markdown\">LICENSE.markdown</a>.\n</p>\n</div>\n\n<div class=\"row\">\n<div class=\"col-md-5\">\n\n<h3>Example</h3>\n\n<script type=\"text/javascript\">\nimgData = \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\";\n\njQuery(function($) {\n  if(!JSZip.support.blob) {\n      $(\"#demo-not-supported\").removeClass(\"hidden\");\n      $(\"#demo\").hide();\n      return;\n  }\n  $(\"#demo\").click(function () {\n      try {\n          eval($(\"#demo-code\").val());\n          $(\"#status\")\n          .removeClass()\n          .addClass(\"text-success\")\n          .text(\"Done!\");\n      }\n      catch (e) {\n          $(\"#status\")\n          .removeClass()\n          .addClass(\"text-danger\")\n          .text(e);\n      }\n  });\n});\n\n</script>\n<textarea class=\"form-control\" id=\"demo-code\" rows=\"9\" spellcheck=\"false\">\nvar zip = new JSZip();\nzip.file(\"Hello.txt\", \"Hello World\\n\");\nvar img = zip.folder(\"images\");\nimg.file(\"smile.gif\", imgData, {base64: true});\nzip.generateAsync({type:\"blob\"})\n.then(function(content) {\n    // see FileSaver.js\n    saveAs(content, \"example.zip\");\n});</textarea>\n<button id=\"demo\" class=\"btn btn-primary\">Run!</button>\n<span id=\"status\"></span>\n<div id=\"demo-not-supported\" class=\"alert alert-danger hidden\">\n  This browser doesn't support blobs, this demo won't work :(\n  See <a href=\"{{site.baseurl}}/documentation/howto/write_zip.html\" class=\"alert-link\">here for more info</a>.\n</div>\n</div>\n<div class=\"col-md-7\">\n\n<h3>Installation</h3>\n\n<p>\n  <strong>With npm</strong> : <code>npm install jszip</code>\n</p>\n<p>\n  <strong>With bower</strong> : <code>bower install Stuk/jszip</code>\n</p>\n<p>\n  <strong>With component</strong> : <code>component install Stuk/jszip</code>\n</p>\n<p>\n  <strong>Manually</strong> : <a href=\"https://github.com/Stuk/jszip/zipball/main\">download JSZip</a>\n  and include the file <code>dist/jszip.js</code> or <code>dist/jszip.min.js</code>\n</p>\n<br>\n<p>\n  Installed ? Great ! You can now check our\n  <a href=\"{{site.baseurl}}/documentation/examples.html\">guides and examples !</a>\n</p>\n</div>\n</div>\n\n<h3>Support</h3>\n\n<table class=\"browser_support\">\n  <tr>\n    <th class=\"support_op\">Opera</th>\n    <th class=\"support_ff\">Firefox</th>\n    <th class=\"support_sf\">Safari</th>\n    <th class=\"support_cr\">Chrome</th>\n    <th class=\"support_ie\">Internet Explorer</th>\n    <th class=\"support_nd\">Node.js</th>\n  </tr>\n  <tr>\n    <td>Yes</td>\n    <td>Yes</td>\n    <td>Yes</td>\n    <td>Yes</td>\n    <td>Yes</td>\n    <td>Yes</td>\n  </tr>\n  <tr>\n    <td>Tested with the latest version</td>\n    <td>Tested with 3.0 / 3.6 / latest version</td>\n    <td>Tested with the latest version</td>\n    <td>Tested with the latest version</td>\n    <td>Tested with IE 6 / 7 / 8 / 9 / 10</td>\n    <td>Tested with node.js 0.10 / latest version</td>\n  </tr>\n</table>\n\n<h3>Getting help</h3>\n\n<p>\nHaving trouble ? We'd like to help !\n</p>\n<ul>\n  <li>\n  Try the <a href=\"{{site.baseurl}}/documentation/faq.html\">FAQ</a>, it has\n  answers to common questions.\n  </li>\n  <li>\n  If you're looking for information about a specific method, try the\n  <a href=\"{{site.baseurl}}/documentation/api_jszip.html\">documentation</a>.\n  </li>\n  <li>\n  Check the\n  <a href=\"{{site.baseurl}}/documentation/examples.html\">examples</a>.\n  </li>\n  <li>\n  Report bugs in our\n  <a href=\"https://github.com/Stuk/jszip/issues\">Bug tracker</a>.\n  </li>\n</ul>\n\n<h3>Test status</h3>\n\n<dl class=\"dl-horizontal\">\n  <dt>Live tests:</dt>\n  <dd>\n    <a href=\"{{site.baseurl}}/test/\">See for yourself !</a>\n  </dd>\n</dl>\n"
  },
  {
    "path": "lib/base64.js",
    "content": "\"use strict\";\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\n// private property\nvar _keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n\n// public method for encoding\nexports.encode = function(input) {\n    var output = [];\n    var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n    var i = 0, len = input.length, remainingBytes = len;\n\n    var isArray = utils.getTypeOf(input) !== \"string\";\n    while (i < input.length) {\n        remainingBytes = len - i;\n\n        if (!isArray) {\n            chr1 = input.charCodeAt(i++);\n            chr2 = i < len ? input.charCodeAt(i++) : 0;\n            chr3 = i < len ? input.charCodeAt(i++) : 0;\n        } else {\n            chr1 = input[i++];\n            chr2 = i < len ? input[i++] : 0;\n            chr3 = i < len ? input[i++] : 0;\n        }\n\n        enc1 = chr1 >> 2;\n        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n        enc3 = remainingBytes > 1 ? (((chr2 & 15) << 2) | (chr3 >> 6)) : 64;\n        enc4 = remainingBytes > 2 ? (chr3 & 63) : 64;\n\n        output.push(_keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4));\n\n    }\n\n    return output.join(\"\");\n};\n\n// public method for decoding\nexports.decode = function(input) {\n    var chr1, chr2, chr3;\n    var enc1, enc2, enc3, enc4;\n    var i = 0, resultIndex = 0;\n\n    var dataUrlPrefix = \"data:\";\n\n    if (input.substr(0, dataUrlPrefix.length) === dataUrlPrefix) {\n        // This is a common error: people give a data url\n        // (data:image/png;base64,iVBOR...) with a {base64: true} and\n        // wonders why things don't work.\n        // We can detect that the string input looks like a data url but we\n        // *can't* be sure it is one: removing everything up to the comma would\n        // be too dangerous.\n        throw new Error(\"Invalid base64 input, it looks like a data url.\");\n    }\n\n    input = input.replace(/[^A-Za-z0-9+/=]/g, \"\");\n\n    var totalLength = input.length * 3 / 4;\n    if(input.charAt(input.length - 1) === _keyStr.charAt(64)) {\n        totalLength--;\n    }\n    if(input.charAt(input.length - 2) === _keyStr.charAt(64)) {\n        totalLength--;\n    }\n    if (totalLength % 1 !== 0) {\n        // totalLength is not an integer, the length does not match a valid\n        // base64 content. That can happen if:\n        // - the input is not a base64 content\n        // - the input is *almost* a base64 content, with a extra chars at the\n        //   beginning or at the end\n        // - the input uses a base64 variant (base64url for example)\n        throw new Error(\"Invalid base64 input, bad content length.\");\n    }\n    var output;\n    if (support.uint8array) {\n        output = new Uint8Array(totalLength|0);\n    } else {\n        output = new Array(totalLength|0);\n    }\n\n    while (i < input.length) {\n\n        enc1 = _keyStr.indexOf(input.charAt(i++));\n        enc2 = _keyStr.indexOf(input.charAt(i++));\n        enc3 = _keyStr.indexOf(input.charAt(i++));\n        enc4 = _keyStr.indexOf(input.charAt(i++));\n\n        chr1 = (enc1 << 2) | (enc2 >> 4);\n        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n        chr3 = ((enc3 & 3) << 6) | enc4;\n\n        output[resultIndex++] = chr1;\n\n        if (enc3 !== 64) {\n            output[resultIndex++] = chr2;\n        }\n        if (enc4 !== 64) {\n            output[resultIndex++] = chr3;\n        }\n\n    }\n\n    return output;\n};\n"
  },
  {
    "path": "lib/compressedObject.js",
    "content": "\"use strict\";\n\nvar external = require(\"./external\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar DataLengthProbe = require(\"./stream/DataLengthProbe\");\n\n/**\n * Represent a compressed object, with everything needed to decompress it.\n * @constructor\n * @param {number} compressedSize the size of the data compressed.\n * @param {number} uncompressedSize the size of the data after decompression.\n * @param {number} crc32 the crc32 of the decompressed file.\n * @param {object} compression the type of compression, see lib/compressions.js.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the compressed data.\n */\nfunction CompressedObject(compressedSize, uncompressedSize, crc32, compression, data) {\n    this.compressedSize = compressedSize;\n    this.uncompressedSize = uncompressedSize;\n    this.crc32 = crc32;\n    this.compression = compression;\n    this.compressedContent = data;\n}\n\nCompressedObject.prototype = {\n    /**\n     * Create a worker to get the uncompressed content.\n     * @return {GenericWorker} the worker.\n     */\n    getContentWorker: function () {\n        var worker = new DataWorker(external.Promise.resolve(this.compressedContent))\n            .pipe(this.compression.uncompressWorker())\n            .pipe(new DataLengthProbe(\"data_length\"));\n\n        var that = this;\n        worker.on(\"end\", function () {\n            if (this.streamInfo[\"data_length\"] !== that.uncompressedSize) {\n                throw new Error(\"Bug : uncompressed data size mismatch\");\n            }\n        });\n        return worker;\n    },\n    /**\n     * Create a worker to get the compressed content.\n     * @return {GenericWorker} the worker.\n     */\n    getCompressedWorker: function () {\n        return new DataWorker(external.Promise.resolve(this.compressedContent))\n            .withStreamInfo(\"compressedSize\", this.compressedSize)\n            .withStreamInfo(\"uncompressedSize\", this.uncompressedSize)\n            .withStreamInfo(\"crc32\", this.crc32)\n            .withStreamInfo(\"compression\", this.compression)\n        ;\n    }\n};\n\n/**\n * Chain the given worker with other workers to compress the content with the\n * given compression.\n * @param {GenericWorker} uncompressedWorker the worker to pipe.\n * @param {Object} compression the compression object.\n * @param {Object} compressionOptions the options to use when compressing.\n * @return {GenericWorker} the new worker compressing the content.\n */\nCompressedObject.createWorkerFrom = function (uncompressedWorker, compression, compressionOptions) {\n    return uncompressedWorker\n        .pipe(new Crc32Probe())\n        .pipe(new DataLengthProbe(\"uncompressedSize\"))\n        .pipe(compression.compressWorker(compressionOptions))\n        .pipe(new DataLengthProbe(\"compressedSize\"))\n        .withStreamInfo(\"compression\", compression);\n};\n\nmodule.exports = CompressedObject;\n"
  },
  {
    "path": "lib/compressions.js",
    "content": "\"use strict\";\n\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nexports.STORE = {\n    magic: \"\\x00\\x00\",\n    compressWorker : function () {\n        return new GenericWorker(\"STORE compression\");\n    },\n    uncompressWorker : function () {\n        return new GenericWorker(\"STORE decompression\");\n    }\n};\nexports.DEFLATE = require(\"./flate\");\n"
  },
  {
    "path": "lib/crc32.js",
    "content": "\"use strict\";\n\nvar utils = require(\"./utils\");\n\n/**\n * The following functions come from pako, from pako/lib/zlib/crc32.js\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n    var c, table = [];\n\n    for(var n =0; n < 256; n++){\n        c = n;\n        for(var k =0; k < 8; k++){\n            c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n        }\n        table[n] = c;\n    }\n\n    return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n    var t = crcTable, end = pos + len;\n\n    crc = crc ^ (-1);\n\n    for (var i = pos; i < end; i++ ) {\n        crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n    }\n\n    return (crc ^ (-1)); // >>> 0;\n}\n\n// That's all for the pako functions.\n\n/**\n * Compute the crc32 of a string.\n * This is almost the same as the function crc32, but for strings. Using the\n * same function for the two use cases leads to horrible performances.\n * @param {Number} crc the starting value of the crc.\n * @param {String} str the string to use.\n * @param {Number} len the length of the string.\n * @param {Number} pos the starting position for the crc32 computation.\n * @return {Number} the computed crc32.\n */\nfunction crc32str(crc, str, len, pos) {\n    var t = crcTable, end = pos + len;\n\n    crc = crc ^ (-1);\n\n    for (var i = pos; i < end; i++ ) {\n        crc = (crc >>> 8) ^ t[(crc ^ str.charCodeAt(i)) & 0xFF];\n    }\n\n    return (crc ^ (-1)); // >>> 0;\n}\n\nmodule.exports = function crc32wrapper(input, crc) {\n    if (typeof input === \"undefined\" || !input.length) {\n        return 0;\n    }\n\n    var isArray = utils.getTypeOf(input) !== \"string\";\n\n    if(isArray) {\n        return crc32(crc|0, input, input.length, 0);\n    } else {\n        return crc32str(crc|0, input, input.length, 0);\n    }\n};\n"
  },
  {
    "path": "lib/defaults.js",
    "content": "\"use strict\";\nexports.base64 = false;\nexports.binary = false;\nexports.dir = false;\nexports.createFolders = true;\nexports.date = null;\nexports.compression = null;\nexports.compressionOptions = null;\nexports.comment = null;\nexports.unixPermissions = null;\nexports.dosPermissions = null;\n"
  },
  {
    "path": "lib/external.js",
    "content": "\"use strict\";\n\n// load the global object first:\n// - it should be better integrated in the system (unhandledRejection in node)\n// - the environment may have a custom Promise implementation (see zone.js)\nvar ES6Promise = null;\nif (typeof Promise !== \"undefined\") {\n    ES6Promise = Promise;\n} else {\n    ES6Promise = require(\"lie\");\n}\n\n/**\n * Let the user use/change some implementations.\n */\nmodule.exports = {\n    Promise: ES6Promise\n};\n"
  },
  {
    "path": "lib/flate.js",
    "content": "\"use strict\";\nvar USE_TYPEDARRAY = (typeof Uint8Array !== \"undefined\") && (typeof Uint16Array !== \"undefined\") && (typeof Uint32Array !== \"undefined\");\n\nvar pako = require(\"pako\");\nvar utils = require(\"./utils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\nvar ARRAY_TYPE = USE_TYPEDARRAY ? \"uint8array\" : \"array\";\n\nexports.magic = \"\\x08\\x00\";\n\n/**\n * Create a worker that uses pako to inflate/deflate.\n * @constructor\n * @param {String} action the name of the pako function to call : either \"Deflate\" or \"Inflate\".\n * @param {Object} options the options to use when (de)compressing.\n */\nfunction FlateWorker(action, options) {\n    GenericWorker.call(this, \"FlateWorker/\" + action);\n\n    this._pako = null;\n    this._pakoAction = action;\n    this._pakoOptions = options;\n    // the `meta` object from the last chunk received\n    // this allow this worker to pass around metadata\n    this.meta = {};\n}\n\nutils.inherits(FlateWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nFlateWorker.prototype.processChunk = function (chunk) {\n    this.meta = chunk.meta;\n    if (this._pako === null) {\n        this._createPako();\n    }\n    this._pako.push(utils.transformTo(ARRAY_TYPE, chunk.data), false);\n};\n\n/**\n * @see GenericWorker.flush\n */\nFlateWorker.prototype.flush = function () {\n    GenericWorker.prototype.flush.call(this);\n    if (this._pako === null) {\n        this._createPako();\n    }\n    this._pako.push([], true);\n};\n/**\n * @see GenericWorker.cleanUp\n */\nFlateWorker.prototype.cleanUp = function () {\n    GenericWorker.prototype.cleanUp.call(this);\n    this._pako = null;\n};\n\n/**\n * Create the _pako object.\n * TODO: lazy-loading this object isn't the best solution but it's the\n * quickest. The best solution is to lazy-load the worker list. See also the\n * issue #446.\n */\nFlateWorker.prototype._createPako = function () {\n    this._pako = new pako[this._pakoAction]({\n        raw: true,\n        level: this._pakoOptions.level || -1 // default compression\n    });\n    var self = this;\n    this._pako.onData = function(data) {\n        self.push({\n            data : data,\n            meta : self.meta\n        });\n    };\n};\n\nexports.compressWorker = function (compressionOptions) {\n    return new FlateWorker(\"Deflate\", compressionOptions);\n};\nexports.uncompressWorker = function () {\n    return new FlateWorker(\"Inflate\", {});\n};\n"
  },
  {
    "path": "lib/generate/ZipFileWorker.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\nvar utf8 = require(\"../utf8\");\nvar crc32 = require(\"../crc32\");\nvar signature = require(\"../signature\");\n\n/**\n * Transform an integer into a string in hexadecimal.\n * @private\n * @param {number} dec the number to convert.\n * @param {number} bytes the number of bytes to generate.\n * @returns {string} the result.\n */\nvar decToHex = function(dec, bytes) {\n    var hex = \"\", i;\n    for (i = 0; i < bytes; i++) {\n        hex += String.fromCharCode(dec & 0xff);\n        dec = dec >>> 8;\n    }\n    return hex;\n};\n\n/**\n * Generate the UNIX part of the external file attributes.\n * @param {Object} unixPermissions the unix permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :\n *\n * TTTTsstrwxrwxrwx0000000000ADVSHR\n * ^^^^____________________________ file type, see zipinfo.c (UNX_*)\n *     ^^^_________________________ setuid, setgid, sticky\n *        ^^^^^^^^^________________ permissions\n *                 ^^^^^^^^^^______ not used ?\n *                           ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only\n */\nvar generateUnixExternalFileAttr = function (unixPermissions, isDir) {\n\n    var result = unixPermissions;\n    if (!unixPermissions) {\n        // I can't use octal values in strict mode, hence the hexa.\n        //  040775 => 0x41fd\n        // 0100664 => 0x81b4\n        result = isDir ? 0x41fd : 0x81b4;\n    }\n    return (result & 0xFFFF) << 16;\n};\n\n/**\n * Generate the DOS part of the external file attributes.\n * @param {Object} dosPermissions the dos permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * Bit 0     Read-Only\n * Bit 1     Hidden\n * Bit 2     System\n * Bit 3     Volume Label\n * Bit 4     Directory\n * Bit 5     Archive\n */\nvar generateDosExternalFileAttr = function (dosPermissions) {\n    // the dir flag is already set for compatibility\n    return (dosPermissions || 0)  & 0x3F;\n};\n\n/**\n * Generate the various parts used in the construction of the final zip file.\n * @param {Object} streamInfo the hash with information about the compressed file.\n * @param {Boolean} streamedContent is the content streamed ?\n * @param {Boolean} streamingEnded is the stream finished ?\n * @param {number} offset the current offset from the start of the zip file.\n * @param {String} platform let's pretend we are this platform (change platform dependents fields)\n * @param {Function} encodeFileName the function to encode the file name / comment.\n * @return {Object} the zip parts.\n */\nvar generateZipParts = function(streamInfo, streamedContent, streamingEnded, offset, platform, encodeFileName) {\n    var file = streamInfo[\"file\"],\n        compression = streamInfo[\"compression\"],\n        useCustomEncoding = encodeFileName !== utf8.utf8encode,\n        encodedFileName = utils.transformTo(\"string\", encodeFileName(file.name)),\n        utfEncodedFileName = utils.transformTo(\"string\", utf8.utf8encode(file.name)),\n        comment = file.comment,\n        encodedComment = utils.transformTo(\"string\", encodeFileName(comment)),\n        utfEncodedComment = utils.transformTo(\"string\", utf8.utf8encode(comment)),\n        useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,\n        useUTF8ForComment = utfEncodedComment.length !== comment.length,\n        dosTime,\n        dosDate,\n        extraFields = \"\",\n        unicodePathExtraField = \"\",\n        unicodeCommentExtraField = \"\",\n        dir = file.dir,\n        date = file.date;\n\n\n    var dataInfo = {\n        crc32 : 0,\n        compressedSize : 0,\n        uncompressedSize : 0\n    };\n\n    // if the content is streamed, the sizes/crc32 are only available AFTER\n    // the end of the stream.\n    if (!streamedContent || streamingEnded) {\n        dataInfo.crc32 = streamInfo[\"crc32\"];\n        dataInfo.compressedSize = streamInfo[\"compressedSize\"];\n        dataInfo.uncompressedSize = streamInfo[\"uncompressedSize\"];\n    }\n\n    var bitflag = 0;\n    if (streamedContent) {\n        // Bit 3: the sizes/crc32 are set to zero in the local header.\n        // The correct values are put in the data descriptor immediately\n        // following the compressed data.\n        bitflag |= 0x0008;\n    }\n    if (!useCustomEncoding && (useUTF8ForFileName || useUTF8ForComment)) {\n        // Bit 11: Language encoding flag (EFS).\n        bitflag |= 0x0800;\n    }\n\n\n    var extFileAttr = 0;\n    var versionMadeBy = 0;\n    if (dir) {\n        // dos or unix, we set the dos dir flag\n        extFileAttr |= 0x00010;\n    }\n    if(platform === \"UNIX\") {\n        versionMadeBy = 0x031E; // UNIX, version 3.0\n        extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);\n    } else { // DOS or other, fallback to DOS\n        versionMadeBy = 0x0014; // DOS, version 2.0\n        extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);\n    }\n\n    // date\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html\n    // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html\n\n    dosTime = date.getUTCHours();\n    dosTime = dosTime << 6;\n    dosTime = dosTime | date.getUTCMinutes();\n    dosTime = dosTime << 5;\n    dosTime = dosTime | date.getUTCSeconds() / 2;\n\n    dosDate = date.getUTCFullYear() - 1980;\n    dosDate = dosDate << 4;\n    dosDate = dosDate | (date.getUTCMonth() + 1);\n    dosDate = dosDate << 5;\n    dosDate = dosDate | date.getUTCDate();\n\n    if (useUTF8ForFileName) {\n        // set the unicode path extra field. unzip needs at least one extra\n        // field to correctly handle unicode path, so using the path is as good\n        // as any other information. This could improve the situation with\n        // other archive managers too.\n        // This field is usually used without the utf8 flag, with a non\n        // unicode path in the header (winrar, winzip). This helps (a bit)\n        // with the messy Windows' default compressed folders feature but\n        // breaks on p7zip which doesn't seek the unicode path extra field.\n        // So for now, UTF-8 everywhere !\n        unicodePathExtraField =\n            // Version\n            decToHex(1, 1) +\n            // NameCRC32\n            decToHex(crc32(encodedFileName), 4) +\n            // UnicodeName\n            utfEncodedFileName;\n\n        extraFields +=\n            // Info-ZIP Unicode Path Extra Field\n            \"\\x75\\x70\" +\n            // size\n            decToHex(unicodePathExtraField.length, 2) +\n            // content\n            unicodePathExtraField;\n    }\n\n    if(useUTF8ForComment) {\n\n        unicodeCommentExtraField =\n            // Version\n            decToHex(1, 1) +\n            // CommentCRC32\n            decToHex(crc32(encodedComment), 4) +\n            // UnicodeName\n            utfEncodedComment;\n\n        extraFields +=\n            // Info-ZIP Unicode Path Extra Field\n            \"\\x75\\x63\" +\n            // size\n            decToHex(unicodeCommentExtraField.length, 2) +\n            // content\n            unicodeCommentExtraField;\n    }\n\n    var header = \"\";\n\n    // version needed to extract\n    header += \"\\x0A\\x00\";\n    // general purpose bit flag\n    header += decToHex(bitflag, 2);\n    // compression method\n    header += compression.magic;\n    // last mod file time\n    header += decToHex(dosTime, 2);\n    // last mod file date\n    header += decToHex(dosDate, 2);\n    // crc-32\n    header += decToHex(dataInfo.crc32, 4);\n    // compressed size\n    header += decToHex(dataInfo.compressedSize, 4);\n    // uncompressed size\n    header += decToHex(dataInfo.uncompressedSize, 4);\n    // file name length\n    header += decToHex(encodedFileName.length, 2);\n    // extra field length\n    header += decToHex(extraFields.length, 2);\n\n\n    var fileRecord = signature.LOCAL_FILE_HEADER + header + encodedFileName + extraFields;\n\n    var dirRecord = signature.CENTRAL_FILE_HEADER +\n        // version made by (00: DOS)\n        decToHex(versionMadeBy, 2) +\n        // file header (common to file and central directory)\n        header +\n        // file comment length\n        decToHex(encodedComment.length, 2) +\n        // disk number start\n        \"\\x00\\x00\" +\n        // internal file attributes TODO\n        \"\\x00\\x00\" +\n        // external file attributes\n        decToHex(extFileAttr, 4) +\n        // relative offset of local header\n        decToHex(offset, 4) +\n        // file name\n        encodedFileName +\n        // extra field\n        extraFields +\n        // file comment\n        encodedComment;\n\n    return {\n        fileRecord: fileRecord,\n        dirRecord: dirRecord\n    };\n};\n\n/**\n * Generate the EOCD record.\n * @param {Number} entriesCount the number of entries in the zip file.\n * @param {Number} centralDirLength the length (in bytes) of the central dir.\n * @param {Number} localDirLength the length (in bytes) of the local dir.\n * @param {String} comment the zip file comment as a binary string.\n * @param {Function} encodeFileName the function to encode the comment.\n * @return {String} the EOCD record.\n */\nvar generateCentralDirectoryEnd = function (entriesCount, centralDirLength, localDirLength, comment, encodeFileName) {\n    var dirEnd = \"\";\n    var encodedComment = utils.transformTo(\"string\", encodeFileName(comment));\n\n    // end of central dir signature\n    dirEnd = signature.CENTRAL_DIRECTORY_END +\n        // number of this disk\n        \"\\x00\\x00\" +\n        // number of the disk with the start of the central directory\n        \"\\x00\\x00\" +\n        // total number of entries in the central directory on this disk\n        decToHex(entriesCount, 2) +\n        // total number of entries in the central directory\n        decToHex(entriesCount, 2) +\n        // size of the central directory   4 bytes\n        decToHex(centralDirLength, 4) +\n        // offset of start of central directory with respect to the starting disk number\n        decToHex(localDirLength, 4) +\n        // .ZIP file comment length\n        decToHex(encodedComment.length, 2) +\n        // .ZIP file comment\n        encodedComment;\n\n    return dirEnd;\n};\n\n/**\n * Generate data descriptors for a file entry.\n * @param {Object} streamInfo the hash generated by a worker, containing information\n * on the file entry.\n * @return {String} the data descriptors.\n */\nvar generateDataDescriptors = function (streamInfo) {\n    var descriptor = \"\";\n    descriptor = signature.DATA_DESCRIPTOR +\n        // crc-32                          4 bytes\n        decToHex(streamInfo[\"crc32\"], 4) +\n        // compressed size                 4 bytes\n        decToHex(streamInfo[\"compressedSize\"], 4) +\n        // uncompressed size               4 bytes\n        decToHex(streamInfo[\"uncompressedSize\"], 4);\n\n    return descriptor;\n};\n\n\n/**\n * A worker to concatenate other workers to create a zip file.\n * @param {Boolean} streamFiles `true` to stream the content of the files,\n * `false` to accumulate it.\n * @param {String} comment the comment to use.\n * @param {String} platform the platform to use, \"UNIX\" or \"DOS\".\n * @param {Function} encodeFileName the function to encode file names and comments.\n */\nfunction ZipFileWorker(streamFiles, comment, platform, encodeFileName) {\n    GenericWorker.call(this, \"ZipFileWorker\");\n    // The number of bytes written so far. This doesn't count accumulated chunks.\n    this.bytesWritten = 0;\n    // The comment of the zip file\n    this.zipComment = comment;\n    // The platform \"generating\" the zip file.\n    this.zipPlatform = platform;\n    // the function to encode file names and comments.\n    this.encodeFileName = encodeFileName;\n    // Should we stream the content of the files ?\n    this.streamFiles = streamFiles;\n    // If `streamFiles` is false, we will need to accumulate the content of the\n    // files to calculate sizes / crc32 (and write them *before* the content).\n    // This boolean indicates if we are accumulating chunks (it will change a lot\n    // during the lifetime of this worker).\n    this.accumulate = false;\n    // The buffer receiving chunks when accumulating content.\n    this.contentBuffer = [];\n    // The list of generated directory records.\n    this.dirRecords = [];\n    // The offset (in bytes) from the beginning of the zip file for the current source.\n    this.currentSourceOffset = 0;\n    // The total number of entries in this zip file.\n    this.entriesCount = 0;\n    // the name of the file currently being added, null when handling the end of the zip file.\n    // Used for the emitted metadata.\n    this.currentFile = null;\n\n\n\n    this._sources = [];\n}\nutils.inherits(ZipFileWorker, GenericWorker);\n\n/**\n * @see GenericWorker.push\n */\nZipFileWorker.prototype.push = function (chunk) {\n\n    var currentFilePercent = chunk.meta.percent || 0;\n    var entriesCount = this.entriesCount;\n    var remainingFiles = this._sources.length;\n\n    if(this.accumulate) {\n        this.contentBuffer.push(chunk);\n    } else {\n        this.bytesWritten += chunk.data.length;\n\n        GenericWorker.prototype.push.call(this, {\n            data : chunk.data,\n            meta : {\n                currentFile : this.currentFile,\n                percent : entriesCount ? (currentFilePercent + 100 * (entriesCount - remainingFiles - 1)) / entriesCount : 100\n            }\n        });\n    }\n};\n\n/**\n * The worker started a new source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the new source.\n */\nZipFileWorker.prototype.openedSource = function (streamInfo) {\n    this.currentSourceOffset = this.bytesWritten;\n    this.currentFile = streamInfo[\"file\"].name;\n\n    var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n\n    // don't stream folders (because they don't have any content)\n    if(streamedContent) {\n        var record = generateZipParts(streamInfo, streamedContent, false, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n        this.push({\n            data : record.fileRecord,\n            meta : {percent:0}\n        });\n    } else {\n        // we need to wait for the whole file before pushing anything\n        this.accumulate = true;\n    }\n};\n\n/**\n * The worker finished a source (an other worker).\n * @param {Object} streamInfo the streamInfo object from the finished source.\n */\nZipFileWorker.prototype.closedSource = function (streamInfo) {\n    this.accumulate = false;\n    var streamedContent = this.streamFiles && !streamInfo[\"file\"].dir;\n    var record = generateZipParts(streamInfo, streamedContent, true, this.currentSourceOffset, this.zipPlatform, this.encodeFileName);\n\n    this.dirRecords.push(record.dirRecord);\n    if(streamedContent) {\n        // after the streamed file, we put data descriptors\n        this.push({\n            data : generateDataDescriptors(streamInfo),\n            meta : {percent:100}\n        });\n    } else {\n        // the content wasn't streamed, we need to push everything now\n        // first the file record, then the content\n        this.push({\n            data : record.fileRecord,\n            meta : {percent:0}\n        });\n        while(this.contentBuffer.length) {\n            this.push(this.contentBuffer.shift());\n        }\n    }\n    this.currentFile = null;\n};\n\n/**\n * @see GenericWorker.flush\n */\nZipFileWorker.prototype.flush = function () {\n\n    var localDirLength = this.bytesWritten;\n    for(var i = 0; i < this.dirRecords.length; i++) {\n        this.push({\n            data : this.dirRecords[i],\n            meta : {percent:100}\n        });\n    }\n    var centralDirLength = this.bytesWritten - localDirLength;\n\n    var dirEnd = generateCentralDirectoryEnd(this.dirRecords.length, centralDirLength, localDirLength, this.zipComment, this.encodeFileName);\n\n    this.push({\n        data : dirEnd,\n        meta : {percent:100}\n    });\n};\n\n/**\n * Prepare the next source to be read.\n */\nZipFileWorker.prototype.prepareNextSource = function () {\n    this.previous = this._sources.shift();\n    this.openedSource(this.previous.streamInfo);\n    if (this.isPaused) {\n        this.previous.pause();\n    } else {\n        this.previous.resume();\n    }\n};\n\n/**\n * @see GenericWorker.registerPrevious\n */\nZipFileWorker.prototype.registerPrevious = function (previous) {\n    this._sources.push(previous);\n    var self = this;\n\n    previous.on(\"data\", function (chunk) {\n        self.processChunk(chunk);\n    });\n    previous.on(\"end\", function () {\n        self.closedSource(self.previous.streamInfo);\n        if(self._sources.length) {\n            self.prepareNextSource();\n        } else {\n            self.end();\n        }\n    });\n    previous.on(\"error\", function (e) {\n        self.error(e);\n    });\n    return this;\n};\n\n/**\n * @see GenericWorker.resume\n */\nZipFileWorker.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if (!this.previous && this._sources.length) {\n        this.prepareNextSource();\n        return true;\n    }\n    if (!this.previous && !this._sources.length && !this.generatedError) {\n        this.end();\n        return true;\n    }\n};\n\n/**\n * @see GenericWorker.error\n */\nZipFileWorker.prototype.error = function (e) {\n    var sources = this._sources;\n    if(!GenericWorker.prototype.error.call(this, e)) {\n        return false;\n    }\n    for(var i = 0; i < sources.length; i++) {\n        try {\n            sources[i].error(e);\n        } catch(e) {\n            // the `error` exploded, nothing to do\n        }\n    }\n    return true;\n};\n\n/**\n * @see GenericWorker.lock\n */\nZipFileWorker.prototype.lock = function () {\n    GenericWorker.prototype.lock.call(this);\n    var sources = this._sources;\n    for(var i = 0; i < sources.length; i++) {\n        sources[i].lock();\n    }\n};\n\nmodule.exports = ZipFileWorker;\n"
  },
  {
    "path": "lib/generate/index.js",
    "content": "\"use strict\";\n\nvar compressions = require(\"../compressions\");\nvar ZipFileWorker = require(\"./ZipFileWorker\");\n\n/**\n * Find the compression to use.\n * @param {String} fileCompression the compression defined at the file level, if any.\n * @param {String} zipCompression the compression defined at the load() level.\n * @return {Object} the compression object to use.\n */\nvar getCompression = function (fileCompression, zipCompression) {\n\n    var compressionName = fileCompression || zipCompression;\n    var compression = compressions[compressionName];\n    if (!compression) {\n        throw new Error(compressionName + \" is not a valid compression method !\");\n    }\n    return compression;\n};\n\n/**\n * Create a worker to generate a zip file.\n * @param {JSZip} zip the JSZip instance at the right root level.\n * @param {Object} options to generate the zip file.\n * @param {String} comment the comment to use.\n */\nexports.generateWorker = function (zip, options, comment) {\n\n    var zipFileWorker = new ZipFileWorker(options.streamFiles, comment, options.platform, options.encodeFileName);\n    var entriesCount = 0;\n    try {\n\n        zip.forEach(function (relativePath, file) {\n            entriesCount++;\n            var compression = getCompression(file.options.compression, options.compression);\n            var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};\n            var dir = file.dir, date = file.date;\n\n            file._compressWorker(compression, compressionOptions)\n                .withStreamInfo(\"file\", {\n                    name : relativePath,\n                    dir : dir,\n                    date : date,\n                    comment : file.comment || \"\",\n                    unixPermissions : file.unixPermissions,\n                    dosPermissions : file.dosPermissions\n                })\n                .pipe(zipFileWorker);\n        });\n        zipFileWorker.entriesCount = entriesCount;\n    } catch (e) {\n        zipFileWorker.error(e);\n    }\n\n    return zipFileWorker;\n};\n"
  },
  {
    "path": "lib/index.js",
    "content": "\"use strict\";\n\n/**\n * Representation a of zip file in js\n * @constructor\n */\nfunction JSZip() {\n    // if this constructor is used without `new`, it adds `new` before itself:\n    if(!(this instanceof JSZip)) {\n        return new JSZip();\n    }\n\n    if(arguments.length) {\n        throw new Error(\"The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.\");\n    }\n\n    // object containing the files :\n    // {\n    //   \"folder/\" : {...},\n    //   \"folder/data.txt\" : {...}\n    // }\n    // NOTE: we use a null prototype because we do not\n    // want filenames like \"toString\" coming from a zip file\n    // to overwrite methods and attributes in a normal Object.\n    this.files = Object.create(null);\n\n    this.comment = null;\n\n    // Where we are in the hierarchy\n    this.root = \"\";\n    this.clone = function() {\n        var newObj = new JSZip();\n        for (var i in this) {\n            if (typeof this[i] !== \"function\") {\n                newObj[i] = this[i];\n            }\n        }\n        return newObj;\n    };\n}\nJSZip.prototype = require(\"./object\");\nJSZip.prototype.loadAsync = require(\"./load\");\nJSZip.support = require(\"./support\");\nJSZip.defaults = require(\"./defaults\");\n\n// TODO find a better way to handle this version,\n// a require('package.json').version doesn't work with webpack, see #327\nJSZip.version = \"3.10.1\";\n\nJSZip.loadAsync = function (content, options) {\n    return new JSZip().loadAsync(content, options);\n};\n\nJSZip.external = require(\"./external\");\nmodule.exports = JSZip;\n"
  },
  {
    "path": "lib/license_header.js",
    "content": "/*!\n\nJSZip v__VERSION__ - A JavaScript class for generating and reading zip files\n<http://stuartk.com/jszip>\n\n(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>\nDual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.\n\nJSZip uses the library pako released under the MIT license :\nhttps://github.com/nodeca/pako/blob/main/LICENSE\n*/\n"
  },
  {
    "path": "lib/load.js",
    "content": "\"use strict\";\nvar utils = require(\"./utils\");\nvar external = require(\"./external\");\nvar utf8 = require(\"./utf8\");\nvar ZipEntries = require(\"./zipEntries\");\nvar Crc32Probe = require(\"./stream/Crc32Probe\");\nvar nodejsUtils = require(\"./nodejsUtils\");\n\n/**\n * Check the CRC32 of an entry.\n * @param {ZipEntry} zipEntry the zip entry to check.\n * @return {Promise} the result.\n */\nfunction checkEntryCRC32(zipEntry) {\n    return new external.Promise(function (resolve, reject) {\n        var worker = zipEntry.decompressed.getContentWorker().pipe(new Crc32Probe());\n        worker.on(\"error\", function (e) {\n            reject(e);\n        })\n            .on(\"end\", function () {\n                if (worker.streamInfo.crc32 !== zipEntry.decompressed.crc32) {\n                    reject(new Error(\"Corrupted zip : CRC32 mismatch\"));\n                } else {\n                    resolve();\n                }\n            })\n            .resume();\n    });\n}\n\nmodule.exports = function (data, options) {\n    var zip = this;\n    options = utils.extend(options || {}, {\n        base64: false,\n        checkCRC32: false,\n        optimizedBinaryString: false,\n        createFolders: false,\n        decodeFileName: utf8.utf8decode\n    });\n\n    if (nodejsUtils.isNode && nodejsUtils.isStream(data)) {\n        return external.Promise.reject(new Error(\"JSZip can't accept a stream when loading a zip file.\"));\n    }\n\n    return utils.prepareContent(\"the loaded zip file\", data, true, options.optimizedBinaryString, options.base64)\n        .then(function (data) {\n            var zipEntries = new ZipEntries(options);\n            zipEntries.load(data);\n            return zipEntries;\n        }).then(function checkCRC32(zipEntries) {\n            var promises = [external.Promise.resolve(zipEntries)];\n            var files = zipEntries.files;\n            if (options.checkCRC32) {\n                for (var i = 0; i < files.length; i++) {\n                    promises.push(checkEntryCRC32(files[i]));\n                }\n            }\n            return external.Promise.all(promises);\n        }).then(function addFiles(results) {\n            var zipEntries = results.shift();\n            var files = zipEntries.files;\n            for (var i = 0; i < files.length; i++) {\n                var input = files[i];\n\n                var unsafeName = input.fileNameStr;\n                var safeName = utils.resolve(input.fileNameStr);\n\n                zip.file(safeName, input.decompressed, {\n                    binary: true,\n                    optimizedBinaryString: true,\n                    date: input.date,\n                    dir: input.dir,\n                    comment: input.fileCommentStr.length ? input.fileCommentStr : null,\n                    unixPermissions: input.unixPermissions,\n                    dosPermissions: input.dosPermissions,\n                    createFolders: options.createFolders\n                });\n                if (!input.dir) {\n                    zip.file(safeName).unsafeOriginalName = unsafeName;\n                }\n            }\n            if (zipEntries.zipComment.length) {\n                zip.comment = zipEntries.zipComment;\n            }\n\n            return zip;\n        });\n};\n"
  },
  {
    "path": "lib/nodejs/NodejsStreamInputAdapter.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"../stream/GenericWorker\");\n\n/**\n * A worker that use a nodejs stream as source.\n * @constructor\n * @param {String} filename the name of the file entry for this stream.\n * @param {Readable} stream the nodejs stream.\n */\nfunction NodejsStreamInputAdapter(filename, stream) {\n    GenericWorker.call(this, \"Nodejs stream input adapter for \" + filename);\n    this._upstreamEnded = false;\n    this._bindStream(stream);\n}\n\nutils.inherits(NodejsStreamInputAdapter, GenericWorker);\n\n/**\n * Prepare the stream and bind the callbacks on it.\n * Do this ASAP on node 0.10 ! A lazy binding doesn't always work.\n * @param {Stream} stream the nodejs stream to use.\n */\nNodejsStreamInputAdapter.prototype._bindStream = function (stream) {\n    var self = this;\n    this._stream = stream;\n    stream.pause();\n    stream\n        .on(\"data\", function (chunk) {\n            self.push({\n                data: chunk,\n                meta : {\n                    percent : 0\n                }\n            });\n        })\n        .on(\"error\", function (e) {\n            if(self.isPaused) {\n                this.generatedError = e;\n            } else {\n                self.error(e);\n            }\n        })\n        .on(\"end\", function () {\n            if(self.isPaused) {\n                self._upstreamEnded = true;\n            } else {\n                self.end();\n            }\n        });\n};\nNodejsStreamInputAdapter.prototype.pause = function () {\n    if(!GenericWorker.prototype.pause.call(this)) {\n        return false;\n    }\n    this._stream.pause();\n    return true;\n};\nNodejsStreamInputAdapter.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if(this._upstreamEnded) {\n        this.end();\n    } else {\n        this._stream.resume();\n    }\n\n    return true;\n};\n\nmodule.exports = NodejsStreamInputAdapter;\n"
  },
  {
    "path": "lib/nodejs/NodejsStreamOutputAdapter.js",
    "content": "\"use strict\";\n\nvar Readable = require(\"readable-stream\").Readable;\n\nvar utils = require(\"../utils\");\nutils.inherits(NodejsStreamOutputAdapter, Readable);\n\n/**\n* A nodejs stream using a worker as source.\n* @see the SourceWrapper in http://nodejs.org/api/stream.html\n* @constructor\n* @param {StreamHelper} helper the helper wrapping the worker\n* @param {Object} options the nodejs stream options\n* @param {Function} updateCb the update callback.\n*/\nfunction NodejsStreamOutputAdapter(helper, options, updateCb) {\n    Readable.call(this, options);\n    this._helper = helper;\n\n    var self = this;\n    helper.on(\"data\", function (data, meta) {\n        if (!self.push(data)) {\n            self._helper.pause();\n        }\n        if(updateCb) {\n            updateCb(meta);\n        }\n    })\n        .on(\"error\", function(e) {\n            self.emit(\"error\", e);\n        })\n        .on(\"end\", function () {\n            self.push(null);\n        });\n}\n\n\nNodejsStreamOutputAdapter.prototype._read = function() {\n    this._helper.resume();\n};\n\nmodule.exports = NodejsStreamOutputAdapter;\n"
  },
  {
    "path": "lib/nodejsUtils.js",
    "content": "\"use strict\";\n\nmodule.exports = {\n    /**\n     * True if this is running in Nodejs, will be undefined in a browser.\n     * In a browser, browserify won't include this file and the whole module\n     * will be resolved an empty object.\n     */\n    isNode : typeof Buffer !== \"undefined\",\n    /**\n     * Create a new nodejs Buffer from an existing content.\n     * @param {Object} data the data to pass to the constructor.\n     * @param {String} encoding the encoding to use.\n     * @return {Buffer} a new Buffer.\n     */\n    newBufferFrom: function(data, encoding) {\n        if (Buffer.from && Buffer.from !== Uint8Array.from) {\n            return Buffer.from(data, encoding);\n        } else {\n            if (typeof data === \"number\") {\n                // Safeguard for old Node.js versions. On newer versions,\n                // Buffer.from(number) / Buffer(number, encoding) already throw.\n                throw new Error(\"The \\\"data\\\" argument must not be a number\");\n            }\n            return new Buffer(data, encoding);\n        }\n    },\n    /**\n     * Create a new nodejs Buffer with the specified size.\n     * @param {Integer} size the size of the buffer.\n     * @return {Buffer} a new Buffer.\n     */\n    allocBuffer: function (size) {\n        if (Buffer.alloc) {\n            return Buffer.alloc(size);\n        } else {\n            var buf = new Buffer(size);\n            buf.fill(0);\n            return buf;\n        }\n    },\n    /**\n     * Find out if an object is a Buffer.\n     * @param {Object} b the object to test.\n     * @return {Boolean} true if the object is a Buffer, false otherwise.\n     */\n    isBuffer : function(b){\n        return Buffer.isBuffer(b);\n    },\n\n    isStream : function (obj) {\n        return obj &&\n            typeof obj.on === \"function\" &&\n            typeof obj.pause === \"function\" &&\n            typeof obj.resume === \"function\";\n    }\n};\n"
  },
  {
    "path": "lib/object.js",
    "content": "\"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        // ignore warning about unwanted properties because this.files is a null prototype object\n        /* eslint-disable-next-line guard-for-in */\n        for (filename in this.files) {\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     * @deprecated This method has been removed in JSZip 3.0, please check the upgrade guide.\n     */\n    generate: function() {\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 preferred 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"
  },
  {
    "path": "lib/readable-stream-browser.js",
    "content": "\"use strict\";\n/*\n * This file is used by module bundlers (browserify/webpack/etc) when\n * including a stream implementation. We use \"readable-stream\" to get a\n * consistent behavior between nodejs versions but bundlers often have a shim\n * for \"stream\". Using this shim greatly improve the compatibility and greatly\n * reduce the final size of the bundle (only one stream implementation, not\n * two).\n */\nmodule.exports = require(\"stream\");\n"
  },
  {
    "path": "lib/reader/ArrayReader.js",
    "content": "\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction ArrayReader(data) {\n    DataReader.call(this, data);\n    for(var i = 0; i < this.data.length; i++) {\n        data[i] = data[i] & 0xFF;\n    }\n}\nutils.inherits(ArrayReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nArrayReader.prototype.byteAt = function(i) {\n    return this.data[this.zero + i];\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nArrayReader.prototype.lastIndexOfSignature = function(sig) {\n    var sig0 = sig.charCodeAt(0),\n        sig1 = sig.charCodeAt(1),\n        sig2 = sig.charCodeAt(2),\n        sig3 = sig.charCodeAt(3);\n    for (var i = this.length - 4; i >= 0; --i) {\n        if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {\n            return i - this.zero;\n        }\n    }\n\n    return -1;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nArrayReader.prototype.readAndCheckSignature = function (sig) {\n    var sig0 = sig.charCodeAt(0),\n        sig1 = sig.charCodeAt(1),\n        sig2 = sig.charCodeAt(2),\n        sig3 = sig.charCodeAt(3),\n        data = this.readData(4);\n    return sig0 === data[0] && sig1 === data[1] && sig2 === data[2] && sig3 === data[3];\n};\n/**\n * @see DataReader.readData\n */\nArrayReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    if(size === 0) {\n        return [];\n    }\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = ArrayReader;\n"
  },
  {
    "path": "lib/reader/DataReader.js",
    "content": "\"use strict\";\nvar utils = require(\"../utils\");\n\nfunction DataReader(data) {\n    this.data = data; // type : see implementation\n    this.length = data.length;\n    this.index = 0;\n    this.zero = 0;\n}\nDataReader.prototype = {\n    /**\n     * Check that the offset will not go too far.\n     * @param {string} offset the additional offset to check.\n     * @throws {Error} an Error if the offset is out of bounds.\n     */\n    checkOffset: function(offset) {\n        this.checkIndex(this.index + offset);\n    },\n    /**\n     * Check that the specified index will not be too far.\n     * @param {string} newIndex the index to check.\n     * @throws {Error} an Error if the index is out of bounds.\n     */\n    checkIndex: function(newIndex) {\n        if (this.length < this.zero + newIndex || newIndex < 0) {\n            throw new Error(\"End of data reached (data length = \" + this.length + \", asked index = \" + (newIndex) + \"). Corrupted zip ?\");\n        }\n    },\n    /**\n     * Change the index.\n     * @param {number} newIndex The new index.\n     * @throws {Error} if the new index is out of the data.\n     */\n    setIndex: function(newIndex) {\n        this.checkIndex(newIndex);\n        this.index = newIndex;\n    },\n    /**\n     * Skip the next n bytes.\n     * @param {number} n the number of bytes to skip.\n     * @throws {Error} if the new index is out of the data.\n     */\n    skip: function(n) {\n        this.setIndex(this.index + n);\n    },\n    /**\n     * Get the byte at the specified index.\n     * @param {number} i the index to use.\n     * @return {number} a byte.\n     */\n    byteAt: function() {\n        // see implementations\n    },\n    /**\n     * Get the next number with a given byte size.\n     * @param {number} size the number of bytes to read.\n     * @return {number} the corresponding number.\n     */\n    readInt: function(size) {\n        var result = 0,\n            i;\n        this.checkOffset(size);\n        for (i = this.index + size - 1; i >= this.index; i--) {\n            result = (result << 8) + this.byteAt(i);\n        }\n        this.index += size;\n        return result;\n    },\n    /**\n     * Get the next string with a given byte size.\n     * @param {number} size the number of bytes to read.\n     * @return {string} the corresponding string.\n     */\n    readString: function(size) {\n        return utils.transformTo(\"string\", this.readData(size));\n    },\n    /**\n     * Get raw data without conversion, <size> bytes.\n     * @param {number} size the number of bytes to read.\n     * @return {Object} the raw data, implementation specific.\n     */\n    readData: function() {\n        // see implementations\n    },\n    /**\n     * Find the last occurrence of a zip signature (4 bytes).\n     * @param {string} sig the signature to find.\n     * @return {number} the index of the last occurrence, -1 if not found.\n     */\n    lastIndexOfSignature: function() {\n        // see implementations\n    },\n    /**\n     * Read the signature (4 bytes) at the current position and compare it with sig.\n     * @param {string} sig the expected signature\n     * @return {boolean} true if the signature matches, false otherwise.\n     */\n    readAndCheckSignature: function() {\n        // see implementations\n    },\n    /**\n     * Get the next date.\n     * @return {Date} the date.\n     */\n    readDate: function() {\n        var dostime = this.readInt(4);\n        return new Date(Date.UTC(\n            ((dostime >> 25) & 0x7f) + 1980, // year\n            ((dostime >> 21) & 0x0f) - 1, // month\n            (dostime >> 16) & 0x1f, // day\n            (dostime >> 11) & 0x1f, // hour\n            (dostime >> 5) & 0x3f, // minute\n            (dostime & 0x1f) << 1)); // second\n    }\n};\nmodule.exports = DataReader;\n"
  },
  {
    "path": "lib/reader/NodeBufferReader.js",
    "content": "\"use strict\";\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction NodeBufferReader(data) {\n    Uint8ArrayReader.call(this, data);\n}\nutils.inherits(NodeBufferReader, Uint8ArrayReader);\n\n/**\n * @see DataReader.readData\n */\nNodeBufferReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = NodeBufferReader;\n"
  },
  {
    "path": "lib/reader/StringReader.js",
    "content": "\"use strict\";\nvar DataReader = require(\"./DataReader\");\nvar utils = require(\"../utils\");\n\nfunction StringReader(data) {\n    DataReader.call(this, data);\n}\nutils.inherits(StringReader, DataReader);\n/**\n * @see DataReader.byteAt\n */\nStringReader.prototype.byteAt = function(i) {\n    return this.data.charCodeAt(this.zero + i);\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nStringReader.prototype.lastIndexOfSignature = function(sig) {\n    return this.data.lastIndexOf(sig) - this.zero;\n};\n/**\n * @see DataReader.readAndCheckSignature\n */\nStringReader.prototype.readAndCheckSignature = function (sig) {\n    var data = this.readData(4);\n    return sig === data;\n};\n/**\n * @see DataReader.readData\n */\nStringReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    // this will work because the constructor applied the \"& 0xff\" mask.\n    var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = StringReader;\n"
  },
  {
    "path": "lib/reader/Uint8ArrayReader.js",
    "content": "\"use strict\";\nvar ArrayReader = require(\"./ArrayReader\");\nvar utils = require(\"../utils\");\n\nfunction Uint8ArrayReader(data) {\n    ArrayReader.call(this, data);\n}\nutils.inherits(Uint8ArrayReader, ArrayReader);\n/**\n * @see DataReader.readData\n */\nUint8ArrayReader.prototype.readData = function(size) {\n    this.checkOffset(size);\n    if(size === 0) {\n        // in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].\n        return new Uint8Array(0);\n    }\n    var result = this.data.subarray(this.zero + this.index, this.zero + this.index + size);\n    this.index += size;\n    return result;\n};\nmodule.exports = Uint8ArrayReader;\n"
  },
  {
    "path": "lib/reader/readerFor.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar support = require(\"../support\");\nvar ArrayReader = require(\"./ArrayReader\");\nvar StringReader = require(\"./StringReader\");\nvar NodeBufferReader = require(\"./NodeBufferReader\");\nvar Uint8ArrayReader = require(\"./Uint8ArrayReader\");\n\n/**\n * Create a reader adapted to the data.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data to read.\n * @return {DataReader} the data reader.\n */\nmodule.exports = function (data) {\n    var type = utils.getTypeOf(data);\n    utils.checkSupport(type);\n    if (type === \"string\" && !support.uint8array) {\n        return new StringReader(data);\n    }\n    if (type === \"nodebuffer\") {\n        return new NodeBufferReader(data);\n    }\n    if (support.uint8array) {\n        return new Uint8ArrayReader(utils.transformTo(\"uint8array\", data));\n    }\n    return new ArrayReader(utils.transformTo(\"array\", data));\n};\n"
  },
  {
    "path": "lib/signature.js",
    "content": "\"use strict\";\nexports.LOCAL_FILE_HEADER = \"PK\\x03\\x04\";\nexports.CENTRAL_FILE_HEADER = \"PK\\x01\\x02\";\nexports.CENTRAL_DIRECTORY_END = \"PK\\x05\\x06\";\nexports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = \"PK\\x06\\x07\";\nexports.ZIP64_CENTRAL_DIRECTORY_END = \"PK\\x06\\x06\";\nexports.DATA_DESCRIPTOR = \"PK\\x07\\x08\";\n"
  },
  {
    "path": "lib/stream/ConvertWorker.js",
    "content": "\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which convert chunks to a specified type.\n * @constructor\n * @param {String} destType the destination type.\n */\nfunction ConvertWorker(destType) {\n    GenericWorker.call(this, \"ConvertWorker to \" + destType);\n    this.destType = destType;\n}\nutils.inherits(ConvertWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nConvertWorker.prototype.processChunk = function (chunk) {\n    this.push({\n        data : utils.transformTo(this.destType, chunk.data),\n        meta : chunk.meta\n    });\n};\nmodule.exports = ConvertWorker;\n"
  },
  {
    "path": "lib/stream/Crc32Probe.js",
    "content": "\"use strict\";\n\nvar GenericWorker = require(\"./GenericWorker\");\nvar crc32 = require(\"../crc32\");\nvar utils = require(\"../utils\");\n\n/**\n * A worker which calculate the crc32 of the data flowing through.\n * @constructor\n */\nfunction Crc32Probe() {\n    GenericWorker.call(this, \"Crc32Probe\");\n    this.withStreamInfo(\"crc32\", 0);\n}\nutils.inherits(Crc32Probe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nCrc32Probe.prototype.processChunk = function (chunk) {\n    this.streamInfo.crc32 = crc32(chunk.data, this.streamInfo.crc32 || 0);\n    this.push(chunk);\n};\nmodule.exports = Crc32Probe;\n"
  },
  {
    "path": "lib/stream/DataLengthProbe.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n/**\n * A worker which calculate the total length of the data flowing through.\n * @constructor\n * @param {String} propName the name used to expose the length\n */\nfunction DataLengthProbe(propName) {\n    GenericWorker.call(this, \"DataLengthProbe for \" + propName);\n    this.propName = propName;\n    this.withStreamInfo(propName, 0);\n}\nutils.inherits(DataLengthProbe, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nDataLengthProbe.prototype.processChunk = function (chunk) {\n    if(chunk) {\n        var length = this.streamInfo[this.propName] || 0;\n        this.streamInfo[this.propName] = length + chunk.data.length;\n    }\n    GenericWorker.prototype.processChunk.call(this, chunk);\n};\nmodule.exports = DataLengthProbe;\n\n"
  },
  {
    "path": "lib/stream/DataWorker.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar GenericWorker = require(\"./GenericWorker\");\n\n// the size of the generated chunks\n// TODO expose this as a public variable\nvar DEFAULT_BLOCK_SIZE = 16 * 1024;\n\n/**\n * A worker that reads a content and emits chunks.\n * @constructor\n * @param {Promise} dataP the promise of the data to split\n */\nfunction DataWorker(dataP) {\n    GenericWorker.call(this, \"DataWorker\");\n    var self = this;\n    this.dataIsReady = false;\n    this.index = 0;\n    this.max = 0;\n    this.data = null;\n    this.type = \"\";\n\n    this._tickScheduled = false;\n\n    dataP.then(function (data) {\n        self.dataIsReady = true;\n        self.data = data;\n        self.max = data && data.length || 0;\n        self.type = utils.getTypeOf(data);\n        if(!self.isPaused) {\n            self._tickAndRepeat();\n        }\n    }, function (e) {\n        self.error(e);\n    });\n}\n\nutils.inherits(DataWorker, GenericWorker);\n\n/**\n * @see GenericWorker.cleanUp\n */\nDataWorker.prototype.cleanUp = function () {\n    GenericWorker.prototype.cleanUp.call(this);\n    this.data = null;\n};\n\n/**\n * @see GenericWorker.resume\n */\nDataWorker.prototype.resume = function () {\n    if(!GenericWorker.prototype.resume.call(this)) {\n        return false;\n    }\n\n    if (!this._tickScheduled && this.dataIsReady) {\n        this._tickScheduled = true;\n        utils.delay(this._tickAndRepeat, [], this);\n    }\n    return true;\n};\n\n/**\n * Trigger a tick a schedule an other call to this function.\n */\nDataWorker.prototype._tickAndRepeat = function() {\n    this._tickScheduled = false;\n    if(this.isPaused || this.isFinished) {\n        return;\n    }\n    this._tick();\n    if(!this.isFinished) {\n        utils.delay(this._tickAndRepeat, [], this);\n        this._tickScheduled = true;\n    }\n};\n\n/**\n * Read and push a chunk.\n */\nDataWorker.prototype._tick = function() {\n\n    if(this.isPaused || this.isFinished) {\n        return false;\n    }\n\n    var size = DEFAULT_BLOCK_SIZE;\n    var data = null, nextIndex = Math.min(this.max, this.index + size);\n    if (this.index >= this.max) {\n        // EOF\n        return this.end();\n    } else {\n        switch(this.type) {\n        case \"string\":\n            data = this.data.substring(this.index, nextIndex);\n            break;\n        case \"uint8array\":\n            data = this.data.subarray(this.index, nextIndex);\n            break;\n        case \"array\":\n        case \"nodebuffer\":\n            data = this.data.slice(this.index, nextIndex);\n            break;\n        }\n        this.index = nextIndex;\n        return this.push({\n            data : data,\n            meta : {\n                percent : this.max ? this.index / this.max * 100 : 0\n            }\n        });\n    }\n};\n\nmodule.exports = DataWorker;\n"
  },
  {
    "path": "lib/stream/GenericWorker.js",
    "content": "\"use strict\";\n\n/**\n * A worker that does nothing but passing chunks to the next one. This is like\n * a nodejs stream but with some differences. On the good side :\n * - it works on IE 6-9 without any issue / polyfill\n * - it weights less than the full dependencies bundled with browserify\n * - it forwards errors (no need to declare an error handler EVERYWHERE)\n *\n * A chunk is an object with 2 attributes : `meta` and `data`. The former is an\n * object containing anything (`percent` for example), see each worker for more\n * details. The latter is the real data (String, Uint8Array, etc).\n *\n * @constructor\n * @param {String} name the name of the stream (mainly used for debugging purposes)\n */\nfunction GenericWorker(name) {\n    // the name of the worker\n    this.name = name || \"default\";\n    // an object containing metadata about the workers chain\n    this.streamInfo = {};\n    // an error which happened when the worker was paused\n    this.generatedError = null;\n    // an object containing metadata to be merged by this worker into the general metadata\n    this.extraStreamInfo = {};\n    // true if the stream is paused (and should not do anything), false otherwise\n    this.isPaused = true;\n    // true if the stream is finished (and should not do anything), false otherwise\n    this.isFinished = false;\n    // true if the stream is locked to prevent further structure updates (pipe), false otherwise\n    this.isLocked = false;\n    // the event listeners\n    this._listeners = {\n        \"data\":[],\n        \"end\":[],\n        \"error\":[]\n    };\n    // the previous worker, if any\n    this.previous = null;\n}\n\nGenericWorker.prototype = {\n    /**\n     * Push a chunk to the next workers.\n     * @param {Object} chunk the chunk to push\n     */\n    push : function (chunk) {\n        this.emit(\"data\", chunk);\n    },\n    /**\n     * End the stream.\n     * @return {Boolean} true if this call ended the worker, false otherwise.\n     */\n    end : function () {\n        if (this.isFinished) {\n            return false;\n        }\n\n        this.flush();\n        try {\n            this.emit(\"end\");\n            this.cleanUp();\n            this.isFinished = true;\n        } catch (e) {\n            this.emit(\"error\", e);\n        }\n        return true;\n    },\n    /**\n     * End the stream with an error.\n     * @param {Error} e the error which caused the premature end.\n     * @return {Boolean} true if this call ended the worker with an error, false otherwise.\n     */\n    error : function (e) {\n        if (this.isFinished) {\n            return false;\n        }\n\n        if(this.isPaused) {\n            this.generatedError = e;\n        } else {\n            this.isFinished = true;\n\n            this.emit(\"error\", e);\n\n            // in the workers chain exploded in the middle of the chain,\n            // the error event will go downward but we also need to notify\n            // workers upward that there has been an error.\n            if(this.previous) {\n                this.previous.error(e);\n            }\n\n            this.cleanUp();\n        }\n        return true;\n    },\n    /**\n     * Add a callback on an event.\n     * @param {String} name the name of the event (data, end, error)\n     * @param {Function} listener the function to call when the event is triggered\n     * @return {GenericWorker} the current object for chainability\n     */\n    on : function (name, listener) {\n        this._listeners[name].push(listener);\n        return this;\n    },\n    /**\n     * Clean any references when a worker is ending.\n     */\n    cleanUp : function () {\n        this.streamInfo = this.generatedError = this.extraStreamInfo = null;\n        this._listeners = [];\n    },\n    /**\n     * Trigger an event. This will call registered callback with the provided arg.\n     * @param {String} name the name of the event (data, end, error)\n     * @param {Object} arg the argument to call the callback with.\n     */\n    emit : function (name, arg) {\n        if (this._listeners[name]) {\n            for(var i = 0; i < this._listeners[name].length; i++) {\n                this._listeners[name][i].call(this, arg);\n            }\n        }\n    },\n    /**\n     * Chain a worker with an other.\n     * @param {Worker} next the worker receiving events from the current one.\n     * @return {worker} the next worker for chainability\n     */\n    pipe : function (next) {\n        return next.registerPrevious(this);\n    },\n    /**\n     * Same as `pipe` in the other direction.\n     * Using an API with `pipe(next)` is very easy.\n     * Implementing the API with the point of view of the next one registering\n     * a source is easier, see the ZipFileWorker.\n     * @param {Worker} previous the previous worker, sending events to this one\n     * @return {Worker} the current worker for chainability\n     */\n    registerPrevious : function (previous) {\n        if (this.isLocked) {\n            throw new Error(\"The stream '\" + this + \"' has already been used.\");\n        }\n\n        // sharing the streamInfo...\n        this.streamInfo = previous.streamInfo;\n        // ... and adding our own bits\n        this.mergeStreamInfo();\n        this.previous =  previous;\n        var self = this;\n        previous.on(\"data\", function (chunk) {\n            self.processChunk(chunk);\n        });\n        previous.on(\"end\", function () {\n            self.end();\n        });\n        previous.on(\"error\", function (e) {\n            self.error(e);\n        });\n        return this;\n    },\n    /**\n     * Pause the stream so it doesn't send events anymore.\n     * @return {Boolean} true if this call paused the worker, false otherwise.\n     */\n    pause : function () {\n        if(this.isPaused || this.isFinished) {\n            return false;\n        }\n        this.isPaused = true;\n\n        if(this.previous) {\n            this.previous.pause();\n        }\n        return true;\n    },\n    /**\n     * Resume a paused stream.\n     * @return {Boolean} true if this call resumed the worker, false otherwise.\n     */\n    resume : function () {\n        if(!this.isPaused || this.isFinished) {\n            return false;\n        }\n        this.isPaused = false;\n\n        // if true, the worker tried to resume but failed\n        var withError = false;\n        if(this.generatedError) {\n            this.error(this.generatedError);\n            withError = true;\n        }\n        if(this.previous) {\n            this.previous.resume();\n        }\n\n        return !withError;\n    },\n    /**\n     * Flush any remaining bytes as the stream is ending.\n     */\n    flush : function () {},\n    /**\n     * Process a chunk. This is usually the method overridden.\n     * @param {Object} chunk the chunk to process.\n     */\n    processChunk : function(chunk) {\n        this.push(chunk);\n    },\n    /**\n     * Add a key/value to be added in the workers chain streamInfo once activated.\n     * @param {String} key the key to use\n     * @param {Object} value the associated value\n     * @return {Worker} the current worker for chainability\n     */\n    withStreamInfo : function (key, value) {\n        this.extraStreamInfo[key] = value;\n        this.mergeStreamInfo();\n        return this;\n    },\n    /**\n     * Merge this worker's streamInfo into the chain's streamInfo.\n     */\n    mergeStreamInfo : function () {\n        for(var key in this.extraStreamInfo) {\n            if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) {\n                continue;\n            }\n            this.streamInfo[key] = this.extraStreamInfo[key];\n        }\n    },\n\n    /**\n     * Lock the stream to prevent further updates on the workers chain.\n     * After calling this method, all calls to pipe will fail.\n     */\n    lock: function () {\n        if (this.isLocked) {\n            throw new Error(\"The stream '\" + this + \"' has already been used.\");\n        }\n        this.isLocked = true;\n        if (this.previous) {\n            this.previous.lock();\n        }\n    },\n\n    /**\n     *\n     * Pretty print the workers chain.\n     */\n    toString : function () {\n        var me = \"Worker \" + this.name;\n        if (this.previous) {\n            return this.previous + \" -> \" + me;\n        } else {\n            return me;\n        }\n    }\n};\n\nmodule.exports = GenericWorker;\n"
  },
  {
    "path": "lib/stream/StreamHelper.js",
    "content": "\"use strict\";\n\nvar utils = require(\"../utils\");\nvar ConvertWorker = require(\"./ConvertWorker\");\nvar GenericWorker = require(\"./GenericWorker\");\nvar base64 = require(\"../base64\");\nvar support = require(\"../support\");\nvar external = require(\"../external\");\n\nvar NodejsStreamOutputAdapter = null;\nif (support.nodestream) {\n    try {\n        NodejsStreamOutputAdapter = require(\"../nodejs/NodejsStreamOutputAdapter\");\n    } catch(e) {\n        // ignore\n    }\n}\n\n/**\n * Apply the final transformation of the data. If the user wants a Blob for\n * example, it's easier to work with an U8intArray and finally do the\n * ArrayBuffer/Blob conversion.\n * @param {String} type the name of the final type\n * @param {String|Uint8Array|Buffer} content the content to transform\n * @param {String} mimeType the mime type of the content, if applicable.\n * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the content in the right format.\n */\nfunction transformZipOutput(type, content, mimeType) {\n    switch(type) {\n    case \"blob\" :\n        return utils.newBlob(utils.transformTo(\"arraybuffer\", content), mimeType);\n    case \"base64\" :\n        return base64.encode(content);\n    default :\n        return utils.transformTo(type, content);\n    }\n}\n\n/**\n * Concatenate an array of data of the given type.\n * @param {String} type the type of the data in the given array.\n * @param {Array} dataArray the array containing the data chunks to concatenate\n * @return {String|Uint8Array|Buffer} the concatenated data\n * @throws Error if the asked type is unsupported\n */\nfunction concat (type, dataArray) {\n    var i, index = 0, res = null, totalLength = 0;\n    for(i = 0; i < dataArray.length; i++) {\n        totalLength += dataArray[i].length;\n    }\n    switch(type) {\n    case \"string\":\n        return dataArray.join(\"\");\n    case \"array\":\n        return Array.prototype.concat.apply([], dataArray);\n    case \"uint8array\":\n        res = new Uint8Array(totalLength);\n        for(i = 0; i < dataArray.length; i++) {\n            res.set(dataArray[i], index);\n            index += dataArray[i].length;\n        }\n        return res;\n    case \"nodebuffer\":\n        return Buffer.concat(dataArray);\n    default:\n        throw new Error(\"concat : unsupported type '\"  + type + \"'\");\n    }\n}\n\n/**\n * Listen a StreamHelper, accumulate its content and concatenate it into a\n * complete block.\n * @param {StreamHelper} helper the helper to use.\n * @param {Function} updateCallback a callback called on each update. Called\n * with one arg :\n * - the metadata linked to the update received.\n * @return Promise the promise for the accumulation.\n */\nfunction accumulate(helper, updateCallback) {\n    return new external.Promise(function (resolve, reject){\n        var dataArray = [];\n        var chunkType = helper._internalType,\n            resultType = helper._outputType,\n            mimeType = helper._mimeType;\n        helper\n            .on(\"data\", function (data, meta) {\n                dataArray.push(data);\n                if(updateCallback) {\n                    updateCallback(meta);\n                }\n            })\n            .on(\"error\", function(err) {\n                dataArray = [];\n                reject(err);\n            })\n            .on(\"end\", function (){\n                try {\n                    var result = transformZipOutput(resultType, concat(chunkType, dataArray), mimeType);\n                    resolve(result);\n                } catch (e) {\n                    reject(e);\n                }\n                dataArray = [];\n            })\n            .resume();\n    });\n}\n\n/**\n * An helper to easily use workers outside of JSZip.\n * @constructor\n * @param {Worker} worker the worker to wrap\n * @param {String} outputType the type of data expected by the use\n * @param {String} mimeType the mime type of the content, if applicable.\n */\nfunction StreamHelper(worker, outputType, mimeType) {\n    var internalType = outputType;\n    switch(outputType) {\n    case \"blob\":\n    case \"arraybuffer\":\n        internalType = \"uint8array\";\n        break;\n    case \"base64\":\n        internalType = \"string\";\n        break;\n    }\n\n    try {\n        // the type used internally\n        this._internalType = internalType;\n        // the type used to output results\n        this._outputType = outputType;\n        // the mime type\n        this._mimeType = mimeType;\n        utils.checkSupport(internalType);\n        this._worker = worker.pipe(new ConvertWorker(internalType));\n        // the last workers can be rewired without issues but we need to\n        // prevent any updates on previous workers.\n        worker.lock();\n    } catch(e) {\n        this._worker = new GenericWorker(\"error\");\n        this._worker.error(e);\n    }\n}\n\nStreamHelper.prototype = {\n    /**\n     * Listen a StreamHelper, accumulate its content and concatenate it into a\n     * complete block.\n     * @param {Function} updateCb the update callback.\n     * @return Promise the promise for the accumulation.\n     */\n    accumulate : function (updateCb) {\n        return accumulate(this, updateCb);\n    },\n    /**\n     * Add a listener on an event triggered on a stream.\n     * @param {String} evt the name of the event\n     * @param {Function} fn the listener\n     * @return {StreamHelper} the current helper.\n     */\n    on : function (evt, fn) {\n        var self = this;\n\n        if(evt === \"data\") {\n            this._worker.on(evt, function (chunk) {\n                fn.call(self, chunk.data, chunk.meta);\n            });\n        } else {\n            this._worker.on(evt, function () {\n                utils.delay(fn, arguments, self);\n            });\n        }\n        return this;\n    },\n    /**\n     * Resume the flow of chunks.\n     * @return {StreamHelper} the current helper.\n     */\n    resume : function () {\n        utils.delay(this._worker.resume, [], this._worker);\n        return this;\n    },\n    /**\n     * Pause the flow of chunks.\n     * @return {StreamHelper} the current helper.\n     */\n    pause : function () {\n        this._worker.pause();\n        return this;\n    },\n    /**\n     * Return a nodejs stream for this helper.\n     * @param {Function} updateCb the update callback.\n     * @return {NodejsStreamOutputAdapter} the nodejs stream.\n     */\n    toNodejsStream : function (updateCb) {\n        utils.checkSupport(\"nodestream\");\n        if (this._outputType !== \"nodebuffer\") {\n            // an object stream containing blob/arraybuffer/uint8array/string\n            // is strange and I don't know if it would be useful.\n            // I you find this comment and have a good usecase, please open a\n            // bug report !\n            throw new Error(this._outputType + \" is not supported by this method\");\n        }\n\n        return new NodejsStreamOutputAdapter(this, {\n            objectMode : this._outputType !== \"nodebuffer\"\n        }, updateCb);\n    }\n};\n\n\nmodule.exports = StreamHelper;\n"
  },
  {
    "path": "lib/support.js",
    "content": "\"use strict\";\n\nexports.base64 = true;\nexports.array = true;\nexports.string = true;\nexports.arraybuffer = typeof ArrayBuffer !== \"undefined\" && typeof Uint8Array !== \"undefined\";\nexports.nodebuffer = typeof Buffer !== \"undefined\";\n// contains true if JSZip can read/generate Uint8Array, false otherwise.\nexports.uint8array = typeof Uint8Array !== \"undefined\";\n\nif (typeof ArrayBuffer === \"undefined\") {\n    exports.blob = false;\n}\nelse {\n    var buffer = new ArrayBuffer(0);\n    try {\n        exports.blob = new Blob([buffer], {\n            type: \"application/zip\"\n        }).size === 0;\n    }\n    catch (e) {\n        try {\n            var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n            var builder = new Builder();\n            builder.append(buffer);\n            exports.blob = builder.getBlob(\"application/zip\").size === 0;\n        }\n        catch (e) {\n            exports.blob = false;\n        }\n    }\n}\n\ntry {\n    exports.nodestream = !!require(\"readable-stream\").Readable;\n} catch(e) {\n    exports.nodestream = false;\n}\n"
  },
  {
    "path": "lib/utf8.js",
    "content": "\"use strict\";\n\nvar utils = require(\"./utils\");\nvar support = require(\"./support\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * The following functions come from pako, from pako/lib/utils/strings\n * released under the MIT license, see pako https://github.com/nodeca/pako/\n */\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Array(256);\nfor (var i=0; i<256; i++) {\n    _utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);\n}\n_utf8len[254]=_utf8len[254]=1; // Invalid sequence start\n\n// convert string to array (typed, when possible)\nvar string2buf = function (str) {\n    var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n    // count binary size\n    for (m_pos = 0; m_pos < str_len; m_pos++) {\n        c = str.charCodeAt(m_pos);\n        if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n            c2 = str.charCodeAt(m_pos+1);\n            if ((c2 & 0xfc00) === 0xdc00) {\n                c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n                m_pos++;\n            }\n        }\n        buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n    }\n\n    // allocate buffer\n    if (support.uint8array) {\n        buf = new Uint8Array(buf_len);\n    } else {\n        buf = new Array(buf_len);\n    }\n\n    // convert\n    for (i=0, m_pos = 0; i < buf_len; m_pos++) {\n        c = str.charCodeAt(m_pos);\n        if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {\n            c2 = str.charCodeAt(m_pos+1);\n            if ((c2 & 0xfc00) === 0xdc00) {\n                c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n                m_pos++;\n            }\n        }\n        if (c < 0x80) {\n            /* one byte */\n            buf[i++] = c;\n        } else if (c < 0x800) {\n            /* two bytes */\n            buf[i++] = 0xC0 | (c >>> 6);\n            buf[i++] = 0x80 | (c & 0x3f);\n        } else if (c < 0x10000) {\n            /* three bytes */\n            buf[i++] = 0xE0 | (c >>> 12);\n            buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n            buf[i++] = 0x80 | (c & 0x3f);\n        } else {\n            /* four bytes */\n            buf[i++] = 0xf0 | (c >>> 18);\n            buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n            buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n            buf[i++] = 0x80 | (c & 0x3f);\n        }\n    }\n\n    return buf;\n};\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max   - length limit (mandatory);\nvar utf8border = function(buf, max) {\n    var pos;\n\n    max = max || buf.length;\n    if (max > buf.length) { max = buf.length; }\n\n    // go back from last position, until start of sequence found\n    pos = max-1;\n    while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n    // Fuckup - very small and broken sequence,\n    // return max, because we should return something anyway.\n    if (pos < 0) { return max; }\n\n    // If we came to start of buffer - that means vuffer is too small,\n    // return max too.\n    if (pos === 0) { return max; }\n\n    return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n};\n\n// convert array to string\nvar buf2string = function (buf) {\n    var i, out, c, c_len;\n    var len = buf.length;\n\n    // Reserve max possible length (2 words per char)\n    // NB: by unknown reasons, Array is significantly faster for\n    //     String.fromCharCode.apply than Uint16Array.\n    var utf16buf = new Array(len*2);\n\n    for (out=0, i=0; i<len;) {\n        c = buf[i++];\n        // quick process ascii\n        if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n        c_len = _utf8len[c];\n        // skip 5 & 6 byte codes\n        if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }\n\n        // apply mask on first byte\n        c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n        // join the rest\n        while (c_len > 1 && i < len) {\n            c = (c << 6) | (buf[i++] & 0x3f);\n            c_len--;\n        }\n\n        // terminated by end of string?\n        if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n        if (c < 0x10000) {\n            utf16buf[out++] = c;\n        } else {\n            c -= 0x10000;\n            utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n            utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n        }\n    }\n\n    // shrinkBuf(utf16buf, out)\n    if (utf16buf.length !== out) {\n        if(utf16buf.subarray) {\n            utf16buf = utf16buf.subarray(0, out);\n        } else {\n            utf16buf.length = out;\n        }\n    }\n\n    // return String.fromCharCode.apply(null, utf16buf);\n    return utils.applyFromCharCode(utf16buf);\n};\n\n\n// That's all for the pako functions.\n\n\n/**\n * Transform a javascript string into an array (typed if possible) of bytes,\n * UTF-8 encoded.\n * @param {String} str the string to encode\n * @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.\n */\nexports.utf8encode = function utf8encode(str) {\n    if (support.nodebuffer) {\n        return nodejsUtils.newBufferFrom(str, \"utf-8\");\n    }\n\n    return string2buf(str);\n};\n\n\n/**\n * Transform a bytes array (or a representation) representing an UTF-8 encoded\n * string into a javascript string.\n * @param {Array|Uint8Array|Buffer} buf the data de decode\n * @return {String} the decoded string.\n */\nexports.utf8decode = function utf8decode(buf) {\n    if (support.nodebuffer) {\n        return utils.transformTo(\"nodebuffer\", buf).toString(\"utf-8\");\n    }\n\n    buf = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", buf);\n\n    return buf2string(buf);\n};\n\n/**\n * A worker to decode utf8 encoded binary chunks into string chunks.\n * @constructor\n */\nfunction Utf8DecodeWorker() {\n    GenericWorker.call(this, \"utf-8 decode\");\n    // the last bytes if a chunk didn't end with a complete codepoint.\n    this.leftOver = null;\n}\nutils.inherits(Utf8DecodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8DecodeWorker.prototype.processChunk = function (chunk) {\n\n    var data = utils.transformTo(support.uint8array ? \"uint8array\" : \"array\", chunk.data);\n\n    // 1st step, re-use what's left of the previous chunk\n    if (this.leftOver && this.leftOver.length) {\n        if(support.uint8array) {\n            var previousData = data;\n            data = new Uint8Array(previousData.length + this.leftOver.length);\n            data.set(this.leftOver, 0);\n            data.set(previousData, this.leftOver.length);\n        } else {\n            data = this.leftOver.concat(data);\n        }\n        this.leftOver = null;\n    }\n\n    var nextBoundary = utf8border(data);\n    var usableData = data;\n    if (nextBoundary !== data.length) {\n        if (support.uint8array) {\n            usableData = data.subarray(0, nextBoundary);\n            this.leftOver = data.subarray(nextBoundary, data.length);\n        } else {\n            usableData = data.slice(0, nextBoundary);\n            this.leftOver = data.slice(nextBoundary, data.length);\n        }\n    }\n\n    this.push({\n        data : exports.utf8decode(usableData),\n        meta : chunk.meta\n    });\n};\n\n/**\n * @see GenericWorker.flush\n */\nUtf8DecodeWorker.prototype.flush = function () {\n    if(this.leftOver && this.leftOver.length) {\n        this.push({\n            data : exports.utf8decode(this.leftOver),\n            meta : {}\n        });\n        this.leftOver = null;\n    }\n};\nexports.Utf8DecodeWorker = Utf8DecodeWorker;\n\n/**\n * A worker to endcode string chunks into utf8 encoded binary chunks.\n * @constructor\n */\nfunction Utf8EncodeWorker() {\n    GenericWorker.call(this, \"utf-8 encode\");\n}\nutils.inherits(Utf8EncodeWorker, GenericWorker);\n\n/**\n * @see GenericWorker.processChunk\n */\nUtf8EncodeWorker.prototype.processChunk = function (chunk) {\n    this.push({\n        data : exports.utf8encode(chunk.data),\n        meta : chunk.meta\n    });\n};\nexports.Utf8EncodeWorker = Utf8EncodeWorker;\n"
  },
  {
    "path": "lib/utils.js",
    "content": "\"use strict\";\n\nvar support = require(\"./support\");\nvar base64 = require(\"./base64\");\nvar nodejsUtils = require(\"./nodejsUtils\");\nvar external = require(\"./external\");\nrequire(\"setimmediate\");\n\n\n/**\n * Convert a string that pass as a \"binary string\": it should represent a byte\n * array but may have > 255 char codes. Be sure to take only the first byte\n * and returns the byte array.\n * @param {String} str the string to transform.\n * @return {Array|Uint8Array} the string in a binary format.\n */\nfunction string2binary(str) {\n    var result = null;\n    if (support.uint8array) {\n        result = new Uint8Array(str.length);\n    } else {\n        result = new Array(str.length);\n    }\n    return stringToArrayLike(str, result);\n}\n\n/**\n * Create a new blob with the given content and the given type.\n * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use\n * an Uint8Array because the stock browser of android 4 won't accept it (it\n * will be silently converted to a string, \"[object Uint8Array]\").\n *\n * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:\n * when a large amount of Array is used to create the Blob, the amount of\n * memory consumed is nearly 100 times the original data amount.\n *\n * @param {String} type the mime type of the blob.\n * @return {Blob} the created blob.\n */\nexports.newBlob = function(part, type) {\n    exports.checkSupport(\"blob\");\n\n    try {\n        // Blob constructor\n        return new Blob([part], {\n            type: type\n        });\n    }\n    catch (e) {\n\n        try {\n            // deprecated, browser only, old way\n            var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;\n            var builder = new Builder();\n            builder.append(part);\n            return builder.getBlob(type);\n        }\n        catch (e) {\n\n            // well, fuck ?!\n            throw new Error(\"Bug : can't construct the Blob.\");\n        }\n    }\n\n\n};\n/**\n * The identity function.\n * @param {Object} input the input.\n * @return {Object} the same input.\n */\nfunction identity(input) {\n    return input;\n}\n\n/**\n * Fill in an array with a string.\n * @param {String} str the string to use.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.\n */\nfunction stringToArrayLike(str, array) {\n    for (var i = 0; i < str.length; ++i) {\n        array[i] = str.charCodeAt(i) & 0xFF;\n    }\n    return array;\n}\n\n/**\n * An helper for the function arrayLikeToString.\n * This contains static information and functions that\n * can be optimized by the browser JIT compiler.\n */\nvar arrayToStringHelper = {\n    /**\n     * Transform an array of int into a string, chunk by chunk.\n     * See the performances notes on arrayLikeToString.\n     * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n     * @param {String} type the type of the array.\n     * @param {Integer} chunk the chunk size.\n     * @return {String} the resulting string.\n     * @throws Error if the chunk is too big for the stack.\n     */\n    stringifyByChunk: function(array, type, chunk) {\n        var result = [], k = 0, len = array.length;\n        // shortcut\n        if (len <= chunk) {\n            return String.fromCharCode.apply(null, array);\n        }\n        while (k < len) {\n            if (type === \"array\" || type === \"nodebuffer\") {\n                result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));\n            }\n            else {\n                result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));\n            }\n            k += chunk;\n        }\n        return result.join(\"\");\n    },\n    /**\n     * Call String.fromCharCode on every item in the array.\n     * This is the naive implementation, which generate A LOT of intermediate string.\n     * This should be used when everything else fail.\n     * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n     * @return {String} the result.\n     */\n    stringifyByChar: function(array){\n        var resultStr = \"\";\n        for(var i = 0; i < array.length; i++) {\n            resultStr += String.fromCharCode(array[i]);\n        }\n        return resultStr;\n    },\n    applyCanBeUsed : {\n        /**\n         * true if the browser accepts to use String.fromCharCode on Uint8Array\n         */\n        uint8array : (function () {\n            try {\n                return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;\n            } catch (e) {\n                return false;\n            }\n        })(),\n        /**\n         * true if the browser accepts to use String.fromCharCode on nodejs Buffer.\n         */\n        nodebuffer : (function () {\n            try {\n                return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;\n            } catch (e) {\n                return false;\n            }\n        })()\n    }\n};\n\n/**\n * Transform an array-like object to a string.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.\n * @return {String} the result.\n */\nfunction arrayLikeToString(array) {\n    // Performances notes :\n    // --------------------\n    // String.fromCharCode.apply(null, array) is the fastest, see\n    // see http://jsperf.com/converting-a-uint8array-to-a-string/2\n    // but the stack is limited (and we can get huge arrays !).\n    //\n    // result += String.fromCharCode(array[i]); generate too many strings !\n    //\n    // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2\n    // TODO : we now have workers that split the work. Do we still need that ?\n    var chunk = 65536,\n        type = exports.getTypeOf(array),\n        canUseApply = true;\n    if (type === \"uint8array\") {\n        canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;\n    } else if (type === \"nodebuffer\") {\n        canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;\n    }\n\n    if (canUseApply) {\n        while (chunk > 1) {\n            try {\n                return arrayToStringHelper.stringifyByChunk(array, type, chunk);\n            } catch (e) {\n                chunk = Math.floor(chunk / 2);\n            }\n        }\n    }\n\n    // no apply or chunk error : slow and painful algorithm\n    // default browser on android 4.*\n    return arrayToStringHelper.stringifyByChar(array);\n}\n\nexports.applyFromCharCode = arrayLikeToString;\n\n\n/**\n * Copy the data from an array-like to an other array-like.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.\n * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.\n * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.\n */\nfunction arrayLikeToArrayLike(arrayFrom, arrayTo) {\n    for (var i = 0; i < arrayFrom.length; i++) {\n        arrayTo[i] = arrayFrom[i];\n    }\n    return arrayTo;\n}\n\n// a matrix containing functions to transform everything into everything.\nvar transform = {};\n\n// string to ?\ntransform[\"string\"] = {\n    \"string\": identity,\n    \"array\": function(input) {\n        return stringToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return transform[\"string\"][\"uint8array\"](input).buffer;\n    },\n    \"uint8array\": function(input) {\n        return stringToArrayLike(input, new Uint8Array(input.length));\n    },\n    \"nodebuffer\": function(input) {\n        return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));\n    }\n};\n\n// array to ?\ntransform[\"array\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": identity,\n    \"arraybuffer\": function(input) {\n        return (new Uint8Array(input)).buffer;\n    },\n    \"uint8array\": function(input) {\n        return new Uint8Array(input);\n    },\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(input);\n    }\n};\n\n// arraybuffer to ?\ntransform[\"arraybuffer\"] = {\n    \"string\": function(input) {\n        return arrayLikeToString(new Uint8Array(input));\n    },\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));\n    },\n    \"arraybuffer\": identity,\n    \"uint8array\": function(input) {\n        return new Uint8Array(input);\n    },\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(new Uint8Array(input));\n    }\n};\n\n// uint8array to ?\ntransform[\"uint8array\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return input.buffer;\n    },\n    \"uint8array\": identity,\n    \"nodebuffer\": function(input) {\n        return nodejsUtils.newBufferFrom(input);\n    }\n};\n\n// nodebuffer to ?\ntransform[\"nodebuffer\"] = {\n    \"string\": arrayLikeToString,\n    \"array\": function(input) {\n        return arrayLikeToArrayLike(input, new Array(input.length));\n    },\n    \"arraybuffer\": function(input) {\n        return transform[\"nodebuffer\"][\"uint8array\"](input).buffer;\n    },\n    \"uint8array\": function(input) {\n        return arrayLikeToArrayLike(input, new Uint8Array(input.length));\n    },\n    \"nodebuffer\": identity\n};\n\n/**\n * Transform an input into any type.\n * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.\n * If no output type is specified, the unmodified input will be returned.\n * @param {String} outputType the output type.\n * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.\n * @throws {Error} an Error if the browser doesn't support the requested output type.\n */\nexports.transformTo = function(outputType, input) {\n    if (!input) {\n        // undefined, null, etc\n        // an empty string won't harm.\n        input = \"\";\n    }\n    if (!outputType) {\n        return input;\n    }\n    exports.checkSupport(outputType);\n    var inputType = exports.getTypeOf(input);\n    var result = transform[inputType][outputType](input);\n    return result;\n};\n\n/**\n * Resolve all relative path components, \".\" and \"..\", in a path. If these relative components\n * traverse above the root then the resulting path will only contain the final path component.\n *\n * All empty components, e.g. \"//\", are removed.\n * @param {string} path A path with / or \\ separators\n * @returns {string} The path with all relative path components resolved.\n */\nexports.resolve = function(path) {\n    var parts = path.split(\"/\");\n    var result = [];\n    for (var index = 0; index < parts.length; index++) {\n        var part = parts[index];\n        // Allow the first and last component to be empty for trailing slashes.\n        if (part === \".\" || (part === \"\" && index !== 0 && index !== parts.length - 1)) {\n            continue;\n        } else if (part === \"..\") {\n            result.pop();\n        } else {\n            result.push(part);\n        }\n    }\n    return result.join(\"/\");\n};\n\n/**\n * Return the type of the input.\n * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.\n * @param {Object} input the input to identify.\n * @return {String} the (lowercase) type of the input.\n */\nexports.getTypeOf = function(input) {\n    if (typeof input === \"string\") {\n        return \"string\";\n    }\n    if (Object.prototype.toString.call(input) === \"[object Array]\") {\n        return \"array\";\n    }\n    if (support.nodebuffer && nodejsUtils.isBuffer(input)) {\n        return \"nodebuffer\";\n    }\n    if (support.uint8array && input instanceof Uint8Array) {\n        return \"uint8array\";\n    }\n    if (support.arraybuffer && input instanceof ArrayBuffer) {\n        return \"arraybuffer\";\n    }\n};\n\n/**\n * Throw an exception if the type is not supported.\n * @param {String} type the type to check.\n * @throws {Error} an Error if the browser doesn't support the requested type.\n */\nexports.checkSupport = function(type) {\n    var supported = support[type.toLowerCase()];\n    if (!supported) {\n        throw new Error(type + \" is not supported by this platform\");\n    }\n};\n\nexports.MAX_VALUE_16BITS = 65535;\nexports.MAX_VALUE_32BITS = -1; // well, \"\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\\xFF\" is parsed as -1\n\n/**\n * Prettify a string read as binary.\n * @param {string} str the string to prettify.\n * @return {string} a pretty string.\n */\nexports.pretty = function(str) {\n    var res = \"\",\n        code, i;\n    for (i = 0; i < (str || \"\").length; i++) {\n        code = str.charCodeAt(i);\n        res += \"\\\\x\" + (code < 16 ? \"0\" : \"\") + code.toString(16).toUpperCase();\n    }\n    return res;\n};\n\n/**\n * Defer the call of a function.\n * @param {Function} callback the function to call asynchronously.\n * @param {Array} args the arguments to give to the callback.\n */\nexports.delay = function(callback, args, self) {\n    setImmediate(function () {\n        callback.apply(self || null, args || []);\n    });\n};\n\n/**\n * Extends a prototype with an other, without calling a constructor with\n * side effects. Inspired by nodejs' `utils.inherits`\n * @param {Function} ctor the constructor to augment\n * @param {Function} superCtor the parent constructor to use\n */\nexports.inherits = function (ctor, superCtor) {\n    var Obj = function() {};\n    Obj.prototype = superCtor.prototype;\n    ctor.prototype = new Obj();\n};\n\n/**\n * Merge the objects passed as parameters into a new one.\n * @private\n * @param {...Object} var_args All objects to merge.\n * @return {Object} a new object with the data of the others.\n */\nexports.extend = function() {\n    var result = {}, i, attr;\n    for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers\n        for (attr in arguments[i]) {\n            if (Object.prototype.hasOwnProperty.call(arguments[i], attr) && typeof result[attr] === \"undefined\") {\n                result[attr] = arguments[i][attr];\n            }\n        }\n    }\n    return result;\n};\n\n/**\n * Transform arbitrary content into a Promise.\n * @param {String} name a name for the content being processed.\n * @param {Object} inputData the content to process.\n * @param {Boolean} isBinary true if the content is not an unicode string\n * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.\n * @param {Boolean} isBase64 true if the string content is encoded with base64.\n * @return {Promise} a promise in a format usable by JSZip.\n */\nexports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {\n\n    // if inputData is already a promise, this flatten it.\n    var promise = external.Promise.resolve(inputData).then(function(data) {\n\n\n        var isBlob = support.blob && (data instanceof Blob || [\"[object File]\", \"[object Blob]\"].indexOf(Object.prototype.toString.call(data)) !== -1);\n\n        if (isBlob && typeof FileReader !== \"undefined\") {\n            return new external.Promise(function (resolve, reject) {\n                var reader = new FileReader();\n\n                reader.onload = function(e) {\n                    resolve(e.target.result);\n                };\n                reader.onerror = function(e) {\n                    reject(e.target.error);\n                };\n                reader.readAsArrayBuffer(data);\n            });\n        } else {\n            return data;\n        }\n    });\n\n    return promise.then(function(data) {\n        var dataType = exports.getTypeOf(data);\n\n        if (!dataType) {\n            return external.Promise.reject(\n                new Error(\"Can't read the data of '\" + name + \"'. Is it \" +\n                          \"in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?\")\n            );\n        }\n        // special case : it's way easier to work with Uint8Array than with ArrayBuffer\n        if (dataType === \"arraybuffer\") {\n            data = exports.transformTo(\"uint8array\", data);\n        } else if (dataType === \"string\") {\n            if (isBase64) {\n                data = base64.decode(data);\n            }\n            else if (isBinary) {\n                // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask\n                if (isOptimizedBinaryString !== true) {\n                    // this is a string, not in a base64 format.\n                    // Be sure that this is a correct \"binary string\"\n                    data = string2binary(data);\n                }\n            }\n        }\n        return data;\n    });\n};\n"
  },
  {
    "path": "lib/zipEntries.js",
    "content": "\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar sig = require(\"./signature\");\nvar ZipEntry = require(\"./zipEntry\");\nvar support = require(\"./support\");\n//  class ZipEntries {{{\n/**\n * All the entries in the zip file.\n * @constructor\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntries(loadOptions) {\n    this.files = [];\n    this.loadOptions = loadOptions;\n}\nZipEntries.prototype = {\n    /**\n     * Check that the reader is on the specified signature.\n     * @param {string} expectedSignature the expected signature.\n     * @throws {Error} if it is an other signature.\n     */\n    checkSignature: function(expectedSignature) {\n        if (!this.reader.readAndCheckSignature(expectedSignature)) {\n            this.reader.index -= 4;\n            var signature = this.reader.readString(4);\n            throw new Error(\"Corrupted zip or bug: unexpected signature \" + \"(\" + utils.pretty(signature) + \", expected \" + utils.pretty(expectedSignature) + \")\");\n        }\n    },\n    /**\n     * Check if the given signature is at the given index.\n     * @param {number} askedIndex the index to check.\n     * @param {string} expectedSignature the signature to expect.\n     * @return {boolean} true if the signature is here, false otherwise.\n     */\n    isSignature: function(askedIndex, expectedSignature) {\n        var currentIndex = this.reader.index;\n        this.reader.setIndex(askedIndex);\n        var signature = this.reader.readString(4);\n        var result = signature === expectedSignature;\n        this.reader.setIndex(currentIndex);\n        return result;\n    },\n    /**\n     * Read the end of the central directory.\n     */\n    readBlockEndOfCentral: function() {\n        this.diskNumber = this.reader.readInt(2);\n        this.diskWithCentralDirStart = this.reader.readInt(2);\n        this.centralDirRecordsOnThisDisk = this.reader.readInt(2);\n        this.centralDirRecords = this.reader.readInt(2);\n        this.centralDirSize = this.reader.readInt(4);\n        this.centralDirOffset = this.reader.readInt(4);\n\n        this.zipCommentLength = this.reader.readInt(2);\n        // warning : the encoding depends of the system locale\n        // On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.\n        // On a windows machine, this field is encoded with the localized windows code page.\n        var zipComment = this.reader.readData(this.zipCommentLength);\n        var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n        // To get consistent behavior with the generation part, we will assume that\n        // this is utf8 encoded unless specified otherwise.\n        var decodeContent = utils.transformTo(decodeParamType, zipComment);\n        this.zipComment = this.loadOptions.decodeFileName(decodeContent);\n    },\n    /**\n     * Read the end of the Zip 64 central directory.\n     * Not merged with the method readEndOfCentral :\n     * The end of central can coexist with its Zip64 brother,\n     * I don't want to read the wrong number of bytes !\n     */\n    readBlockZip64EndOfCentral: function() {\n        this.zip64EndOfCentralSize = this.reader.readInt(8);\n        this.reader.skip(4);\n        // this.versionMadeBy = this.reader.readString(2);\n        // this.versionNeeded = this.reader.readInt(2);\n        this.diskNumber = this.reader.readInt(4);\n        this.diskWithCentralDirStart = this.reader.readInt(4);\n        this.centralDirRecordsOnThisDisk = this.reader.readInt(8);\n        this.centralDirRecords = this.reader.readInt(8);\n        this.centralDirSize = this.reader.readInt(8);\n        this.centralDirOffset = this.reader.readInt(8);\n\n        this.zip64ExtensibleData = {};\n        var extraDataSize = this.zip64EndOfCentralSize - 44,\n            index = 0,\n            extraFieldId,\n            extraFieldLength,\n            extraFieldValue;\n        while (index < extraDataSize) {\n            extraFieldId = this.reader.readInt(2);\n            extraFieldLength = this.reader.readInt(4);\n            extraFieldValue = this.reader.readData(extraFieldLength);\n            this.zip64ExtensibleData[extraFieldId] = {\n                id: extraFieldId,\n                length: extraFieldLength,\n                value: extraFieldValue\n            };\n        }\n    },\n    /**\n     * Read the end of the Zip 64 central directory locator.\n     */\n    readBlockZip64EndOfCentralLocator: function() {\n        this.diskWithZip64CentralDirStart = this.reader.readInt(4);\n        this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);\n        this.disksCount = this.reader.readInt(4);\n        if (this.disksCount > 1) {\n            throw new Error(\"Multi-volumes zip are not supported\");\n        }\n    },\n    /**\n     * Read the local files, based on the offset read in the central part.\n     */\n    readLocalFiles: function() {\n        var i, file;\n        for (i = 0; i < this.files.length; i++) {\n            file = this.files[i];\n            this.reader.setIndex(file.localHeaderOffset);\n            this.checkSignature(sig.LOCAL_FILE_HEADER);\n            file.readLocalPart(this.reader);\n            file.handleUTF8();\n            file.processAttributes();\n        }\n    },\n    /**\n     * Read the central directory.\n     */\n    readCentralDir: function() {\n        var file;\n\n        this.reader.setIndex(this.centralDirOffset);\n        while (this.reader.readAndCheckSignature(sig.CENTRAL_FILE_HEADER)) {\n            file = new ZipEntry({\n                zip64: this.zip64\n            }, this.loadOptions);\n            file.readCentralPart(this.reader);\n            this.files.push(file);\n        }\n\n        if (this.centralDirRecords !== this.files.length) {\n            if (this.centralDirRecords !== 0 && this.files.length === 0) {\n                // We expected some records but couldn't find ANY.\n                // This is really suspicious, as if something went wrong.\n                throw new Error(\"Corrupted zip or bug: expected \" + this.centralDirRecords + \" records in central dir, got \" + this.files.length);\n            } else {\n                // We found some records but not all.\n                // Something is wrong but we got something for the user: no error here.\n                // console.warn(\"expected\", this.centralDirRecords, \"records in central dir, got\", this.files.length);\n            }\n        }\n    },\n    /**\n     * Read the end of central directory.\n     */\n    readEndOfCentral: function() {\n        var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);\n        if (offset < 0) {\n            // Check if the content is a truncated zip or complete garbage.\n            // A \"LOCAL_FILE_HEADER\" is not required at the beginning (auto\n            // extractible zip for example) but it can give a good hint.\n            // If an ajax request was used without responseType, we will also\n            // get unreadable data.\n            var isGarbage = !this.isSignature(0, sig.LOCAL_FILE_HEADER);\n\n            if (isGarbage) {\n                throw new Error(\"Can't find end of central directory : is this a zip file ? \" +\n                                \"If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html\");\n            } else {\n                throw new Error(\"Corrupted zip: can't find end of central directory\");\n            }\n\n        }\n        this.reader.setIndex(offset);\n        var endOfCentralDirOffset = offset;\n        this.checkSignature(sig.CENTRAL_DIRECTORY_END);\n        this.readBlockEndOfCentral();\n\n\n        /* extract from the zip spec :\n            4)  If one of the fields in the end of central directory\n                record is too small to hold required data, the field\n                should be set to -1 (0xFFFF or 0xFFFFFFFF) and the\n                ZIP64 format record should be created.\n            5)  The end of central directory record and the\n                Zip64 end of central directory locator record must\n                reside on the same disk when splitting or spanning\n                an archive.\n         */\n        if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {\n            this.zip64 = true;\n\n            /*\n            Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from\n            the zip file can fit into a 32bits integer. This cannot be solved : JavaScript represents\n            all numbers as 64-bit double precision IEEE 754 floating point numbers.\n            So, we have 53bits for integers and bitwise operations treat everything as 32bits.\n            see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators\n            and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5\n            */\n\n            // should look for a zip64 EOCD locator\n            offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n            if (offset < 0) {\n                throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory locator\");\n            }\n            this.reader.setIndex(offset);\n            this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);\n            this.readBlockZip64EndOfCentralLocator();\n\n            // now the zip64 EOCD record\n            if (!this.isSignature(this.relativeOffsetEndOfZip64CentralDir, sig.ZIP64_CENTRAL_DIRECTORY_END)) {\n                // console.warn(\"ZIP64 end of central directory not where expected.\");\n                this.relativeOffsetEndOfZip64CentralDir = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n                if (this.relativeOffsetEndOfZip64CentralDir < 0) {\n                    throw new Error(\"Corrupted zip: can't find the ZIP64 end of central directory\");\n                }\n            }\n            this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);\n            this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);\n            this.readBlockZip64EndOfCentral();\n        }\n\n        var expectedEndOfCentralDirOffset = this.centralDirOffset + this.centralDirSize;\n        if (this.zip64) {\n            expectedEndOfCentralDirOffset += 20; // end of central dir 64 locator\n            expectedEndOfCentralDirOffset += 12 /* should not include the leading 12 bytes */ + this.zip64EndOfCentralSize;\n        }\n\n        var extraBytes = endOfCentralDirOffset - expectedEndOfCentralDirOffset;\n\n        if (extraBytes > 0) {\n            // console.warn(extraBytes, \"extra bytes at beginning or within zipfile\");\n            if (this.isSignature(endOfCentralDirOffset, sig.CENTRAL_FILE_HEADER)) {\n                // The offsets seem wrong, but we have something at the specified offset.\n                // So… we keep it.\n            } else {\n                // the offset is wrong, update the \"zero\" of the reader\n                // this happens if data has been prepended (crx files for example)\n                this.reader.zero = extraBytes;\n            }\n        } else if (extraBytes < 0) {\n            throw new Error(\"Corrupted zip: missing \" + Math.abs(extraBytes) + \" bytes.\");\n        }\n    },\n    prepareReader: function(data) {\n        this.reader = readerFor(data);\n    },\n    /**\n     * Read a zip file and create ZipEntries.\n     * @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.\n     */\n    load: function(data) {\n        this.prepareReader(data);\n        this.readEndOfCentral();\n        this.readCentralDir();\n        this.readLocalFiles();\n    }\n};\n// }}} end of ZipEntries\nmodule.exports = ZipEntries;\n"
  },
  {
    "path": "lib/zipEntry.js",
    "content": "\"use strict\";\nvar readerFor = require(\"./reader/readerFor\");\nvar utils = require(\"./utils\");\nvar CompressedObject = require(\"./compressedObject\");\nvar crc32fn = require(\"./crc32\");\nvar utf8 = require(\"./utf8\");\nvar compressions = require(\"./compressions\");\nvar support = require(\"./support\");\n\nvar MADE_BY_DOS = 0x00;\nvar MADE_BY_UNIX = 0x03;\n\n/**\n * Find a compression registered in JSZip.\n * @param {string} compressionMethod the method magic to find.\n * @return {Object|null} the JSZip compression object, null if none found.\n */\nvar findCompression = function(compressionMethod) {\n    for (var method in compressions) {\n        if (!Object.prototype.hasOwnProperty.call(compressions, method)) {\n            continue;\n        }\n        if (compressions[method].magic === compressionMethod) {\n            return compressions[method];\n        }\n    }\n    return null;\n};\n\n// class ZipEntry {{{\n/**\n * An entry in the zip file.\n * @constructor\n * @param {Object} options Options of the current file.\n * @param {Object} loadOptions Options for loading the stream.\n */\nfunction ZipEntry(options, loadOptions) {\n    this.options = options;\n    this.loadOptions = loadOptions;\n}\nZipEntry.prototype = {\n    /**\n     * say if the file is encrypted.\n     * @return {boolean} true if the file is encrypted, false otherwise.\n     */\n    isEncrypted: function() {\n        // bit 1 is set\n        return (this.bitFlag & 0x0001) === 0x0001;\n    },\n    /**\n     * say if the file has utf-8 filename/comment.\n     * @return {boolean} true if the filename/comment is in utf-8, false otherwise.\n     */\n    useUTF8: function() {\n        // bit 11 is set\n        return (this.bitFlag & 0x0800) === 0x0800;\n    },\n    /**\n     * Read the local part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readLocalPart: function(reader) {\n        var compression, localExtraFieldsLength;\n\n        // we already know everything from the central dir !\n        // If the central dir data are false, we are doomed.\n        // On the bright side, the local part is scary  : zip64, data descriptors, both, etc.\n        // The less data we get here, the more reliable this should be.\n        // Let's skip the whole header and dash to the data !\n        reader.skip(22);\n        // in some zip created on windows, the filename stored in the central dir contains \\ instead of /.\n        // Strangely, the filename here is OK.\n        // I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes\n        // or APPNOTE#4.4.17.1, \"All slashes MUST be forward slashes '/'\") but there are a lot of bad zip generators...\n        // Search \"unzip mismatching \"local\" filename continuing with \"central\" filename version\" on\n        // the internet.\n        //\n        // I think I see the logic here : the central directory is used to display\n        // content and the local directory is used to extract the files. Mixing / and \\\n        // may be used to display \\ to windows users and use / when extracting the files.\n        // Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394\n        this.fileNameLength = reader.readInt(2);\n        localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir\n        // the fileName is stored as binary data, the handleUTF8 method will take care of the encoding.\n        this.fileName = reader.readData(this.fileNameLength);\n        reader.skip(localExtraFieldsLength);\n\n        if (this.compressedSize === -1 || this.uncompressedSize === -1) {\n            throw new Error(\"Bug or corrupted zip : didn't get enough information from the central directory \" + \"(compressedSize === -1 || uncompressedSize === -1)\");\n        }\n\n        compression = findCompression(this.compressionMethod);\n        if (compression === null) { // no compression found\n            throw new Error(\"Corrupted zip : compression \" + utils.pretty(this.compressionMethod) + \" unknown (inner file : \" + utils.transformTo(\"string\", this.fileName) + \")\");\n        }\n        this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));\n    },\n\n    /**\n     * Read the central part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readCentralPart: function(reader) {\n        this.versionMadeBy = reader.readInt(2);\n        reader.skip(2);\n        // this.versionNeeded = reader.readInt(2);\n        this.bitFlag = reader.readInt(2);\n        this.compressionMethod = reader.readString(2);\n        this.date = reader.readDate();\n        this.crc32 = reader.readInt(4);\n        this.compressedSize = reader.readInt(4);\n        this.uncompressedSize = reader.readInt(4);\n        var fileNameLength = reader.readInt(2);\n        this.extraFieldsLength = reader.readInt(2);\n        this.fileCommentLength = reader.readInt(2);\n        this.diskNumberStart = reader.readInt(2);\n        this.internalFileAttributes = reader.readInt(2);\n        this.externalFileAttributes = reader.readInt(4);\n        this.localHeaderOffset = reader.readInt(4);\n\n        if (this.isEncrypted()) {\n            throw new Error(\"Encrypted zip are not supported\");\n        }\n\n        // will be read in the local part, see the comments there\n        reader.skip(fileNameLength);\n        this.readExtraFields(reader);\n        this.parseZIP64ExtraField(reader);\n        this.fileComment = reader.readData(this.fileCommentLength);\n    },\n\n    /**\n     * Parse the external file attributes and get the unix/dos permissions.\n     */\n    processAttributes: function () {\n        this.unixPermissions = null;\n        this.dosPermissions = null;\n        var madeBy = this.versionMadeBy >> 8;\n\n        // Check if we have the DOS directory flag set.\n        // We look for it in the DOS and UNIX permissions\n        // but some unknown platform could set it as a compatibility flag.\n        this.dir = this.externalFileAttributes & 0x0010 ? true : false;\n\n        if(madeBy === MADE_BY_DOS) {\n            // first 6 bits (0 to 5)\n            this.dosPermissions = this.externalFileAttributes & 0x3F;\n        }\n\n        if(madeBy === MADE_BY_UNIX) {\n            this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;\n            // the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);\n        }\n\n        // fail safe : if the name ends with a / it probably means a folder\n        if (!this.dir && this.fileNameStr.slice(-1) === \"/\") {\n            this.dir = true;\n        }\n    },\n\n    /**\n     * Parse the ZIP64 extra field and merge the info in the current ZipEntry.\n     * @param {DataReader} reader the reader to use.\n     */\n    parseZIP64ExtraField: function() {\n        if (!this.extraFields[0x0001]) {\n            return;\n        }\n\n        // should be something, preparing the extra reader\n        var extraReader = readerFor(this.extraFields[0x0001].value);\n\n        // I really hope that these 64bits integer can fit in 32 bits integer, because js\n        // won't let us have more.\n        if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {\n            this.uncompressedSize = extraReader.readInt(8);\n        }\n        if (this.compressedSize === utils.MAX_VALUE_32BITS) {\n            this.compressedSize = extraReader.readInt(8);\n        }\n        if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {\n            this.localHeaderOffset = extraReader.readInt(8);\n        }\n        if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {\n            this.diskNumberStart = extraReader.readInt(4);\n        }\n    },\n    /**\n     * Read the central part of a zip file and add the info in this object.\n     * @param {DataReader} reader the reader to use.\n     */\n    readExtraFields: function(reader) {\n        var end = reader.index + this.extraFieldsLength,\n            extraFieldId,\n            extraFieldLength,\n            extraFieldValue;\n\n        if (!this.extraFields) {\n            this.extraFields = {};\n        }\n\n        while (reader.index + 4 < end) {\n            extraFieldId = reader.readInt(2);\n            extraFieldLength = reader.readInt(2);\n            extraFieldValue = reader.readData(extraFieldLength);\n\n            this.extraFields[extraFieldId] = {\n                id: extraFieldId,\n                length: extraFieldLength,\n                value: extraFieldValue\n            };\n        }\n\n        reader.setIndex(end);\n    },\n    /**\n     * Apply an UTF8 transformation if needed.\n     */\n    handleUTF8: function() {\n        var decodeParamType = support.uint8array ? \"uint8array\" : \"array\";\n        if (this.useUTF8()) {\n            this.fileNameStr = utf8.utf8decode(this.fileName);\n            this.fileCommentStr = utf8.utf8decode(this.fileComment);\n        } else {\n            var upath = this.findExtraFieldUnicodePath();\n            if (upath !== null) {\n                this.fileNameStr = upath;\n            } else {\n                // ASCII text or unsupported code page\n                var fileNameByteArray =  utils.transformTo(decodeParamType, this.fileName);\n                this.fileNameStr = this.loadOptions.decodeFileName(fileNameByteArray);\n            }\n\n            var ucomment = this.findExtraFieldUnicodeComment();\n            if (ucomment !== null) {\n                this.fileCommentStr = ucomment;\n            } else {\n                // ASCII text or unsupported code page\n                var commentByteArray =  utils.transformTo(decodeParamType, this.fileComment);\n                this.fileCommentStr = this.loadOptions.decodeFileName(commentByteArray);\n            }\n        }\n    },\n\n    /**\n     * Find the unicode path declared in the extra field, if any.\n     * @return {String} the unicode path, null otherwise.\n     */\n    findExtraFieldUnicodePath: function() {\n        var upathField = this.extraFields[0x7075];\n        if (upathField) {\n            var extraReader = readerFor(upathField.value);\n\n            // wrong version\n            if (extraReader.readInt(1) !== 1) {\n                return null;\n            }\n\n            // the crc of the filename changed, this field is out of date.\n            if (crc32fn(this.fileName) !== extraReader.readInt(4)) {\n                return null;\n            }\n\n            return utf8.utf8decode(extraReader.readData(upathField.length - 5));\n        }\n        return null;\n    },\n\n    /**\n     * Find the unicode comment declared in the extra field, if any.\n     * @return {String} the unicode comment, null otherwise.\n     */\n    findExtraFieldUnicodeComment: function() {\n        var ucommentField = this.extraFields[0x6375];\n        if (ucommentField) {\n            var extraReader = readerFor(ucommentField.value);\n\n            // wrong version\n            if (extraReader.readInt(1) !== 1) {\n                return null;\n            }\n\n            // the crc of the comment changed, this field is out of date.\n            if (crc32fn(this.fileComment) !== extraReader.readInt(4)) {\n                return null;\n            }\n\n            return utf8.utf8decode(extraReader.readData(ucommentField.length - 5));\n        }\n        return null;\n    }\n};\nmodule.exports = ZipEntry;\n"
  },
  {
    "path": "lib/zipObject.js",
    "content": "\"use strict\";\n\nvar StreamHelper = require(\"./stream/StreamHelper\");\nvar DataWorker = require(\"./stream/DataWorker\");\nvar utf8 = require(\"./utf8\");\nvar CompressedObject = require(\"./compressedObject\");\nvar GenericWorker = require(\"./stream/GenericWorker\");\n\n/**\n * A simple object representing a file in the zip file.\n * @constructor\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data\n * @param {Object} options the options of the file\n */\nvar ZipObject = function(name, data, options) {\n    this.name = name;\n    this.dir = options.dir;\n    this.date = options.date;\n    this.comment = options.comment;\n    this.unixPermissions = options.unixPermissions;\n    this.dosPermissions = options.dosPermissions;\n\n    this._data = data;\n    this._dataBinary = options.binary;\n    // keep only the compression\n    this.options = {\n        compression : options.compression,\n        compressionOptions : options.compressionOptions\n    };\n};\n\nZipObject.prototype = {\n    /**\n     * Create an internal stream for the content of this object.\n     * @param {String} type the type of each chunk.\n     * @return StreamHelper the stream.\n     */\n    internalStream: function (type) {\n        var result = null, outputType = \"string\";\n        try {\n            if (!type) {\n                throw new Error(\"No output type specified.\");\n            }\n            outputType = type.toLowerCase();\n            var askUnicodeString = outputType === \"string\" || outputType === \"text\";\n            if (outputType === \"binarystring\" || outputType === \"text\") {\n                outputType = \"string\";\n            }\n            result = this._decompressWorker();\n\n            var isUnicodeString = !this._dataBinary;\n\n            if (isUnicodeString && !askUnicodeString) {\n                result = result.pipe(new utf8.Utf8EncodeWorker());\n            }\n            if (!isUnicodeString && askUnicodeString) {\n                result = result.pipe(new utf8.Utf8DecodeWorker());\n            }\n        } catch (e) {\n            result = new GenericWorker(\"error\");\n            result.error(e);\n        }\n\n        return new StreamHelper(result, outputType, \"\");\n    },\n\n    /**\n     * Prepare the content in the asked type.\n     * @param {String} type the type of the result.\n     * @param {Function} onUpdate a function to call on each internal update.\n     * @return Promise the promise of the result.\n     */\n    async: function (type, onUpdate) {\n        return this.internalStream(type).accumulate(onUpdate);\n    },\n\n    /**\n     * Prepare the content as a nodejs stream.\n     * @param {String} type the type of each chunk.\n     * @param {Function} onUpdate a function to call on each internal update.\n     * @return Stream the stream.\n     */\n    nodeStream: function (type, onUpdate) {\n        return this.internalStream(type || \"nodebuffer\").toNodejsStream(onUpdate);\n    },\n\n    /**\n     * Return a worker for the compressed content.\n     * @private\n     * @param {Object} compression the compression object to use.\n     * @param {Object} compressionOptions the options to use when compressing.\n     * @return Worker the worker.\n     */\n    _compressWorker: function (compression, compressionOptions) {\n        if (\n            this._data instanceof CompressedObject &&\n            this._data.compression.magic === compression.magic\n        ) {\n            return this._data.getCompressedWorker();\n        } else {\n            var result = this._decompressWorker();\n            if(!this._dataBinary) {\n                result = result.pipe(new utf8.Utf8EncodeWorker());\n            }\n            return CompressedObject.createWorkerFrom(result, compression, compressionOptions);\n        }\n    },\n    /**\n     * Return a worker for the decompressed content.\n     * @private\n     * @return Worker the worker.\n     */\n    _decompressWorker : function () {\n        if (this._data instanceof CompressedObject) {\n            return this._data.getContentWorker();\n        } else if (this._data instanceof GenericWorker) {\n            return this._data;\n        } else {\n            return new DataWorker(this._data);\n        }\n    }\n};\n\nvar removedMethods = [\"asText\", \"asBinary\", \"asNodeBuffer\", \"asUint8Array\", \"asArrayBuffer\"];\nvar removedFn = function () {\n    throw new Error(\"This method has been removed in JSZip 3.0, please check the upgrade guide.\");\n};\n\nfor(var i = 0; i < removedMethods.length; i++) {\n    ZipObject.prototype[removedMethods[i]] = removedFn;\n}\nmodule.exports = ZipObject;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"jszip\",\n  \"version\": \"3.10.1\",\n  \"author\": \"Stuart Knightley <stuart@stuartk.com>\",\n  \"description\": \"Create, read and edit .zip files with JavaScript http://stuartk.com/jszip\",\n  \"scripts\": {\n    \"test\": \"npm run test-node && npm run test-browser && tsc\",\n    \"test-node\": \"qunit --require ./test/helpers/test-utils.js --require ./test/helpers/node-test-utils.js test/asserts/\",\n    \"test-browser\": \"grunt build && node test/run.js --test\",\n    \"benchmark\": \"npm run benchmark-node && npm run benchmark-browser\",\n    \"benchmark-node\": \"node test/benchmark/node.js\",\n    \"benchmark-browser\": \"node test/run.js --benchmark\",\n    \"lint\": \"eslint .\"\n  },\n  \"contributors\": [\n    {\n      \"name\": \"Franz Buchinger\"\n    },\n    {\n      \"name\": \"António Afonso\"\n    },\n    {\n      \"name\": \"David Duponchel\"\n    },\n    {\n      \"name\": \"yiminghe\"\n    }\n  ],\n  \"main\": \"./lib/index\",\n  \"browser\": {\n    \"./lib/index\": \"./dist/jszip.min.js\",\n    \"readable-stream\": \"./lib/readable-stream-browser.js\"\n  },\n  \"types\": \"./index.d.ts\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/Stuk/jszip.git\"\n  },\n  \"keywords\": [\n    \"zip\",\n    \"deflate\",\n    \"inflate\"\n  ],\n  \"devDependencies\": {\n    \"benchmark\": \"^2.1.4\",\n    \"browserify\": \"~13.0.0\",\n    \"eslint\": \"^8.18.0\",\n    \"grunt\": \"~0.4.1\",\n    \"grunt-browserify\": \"~5.0.0\",\n    \"grunt-cli\": \"~1.1.0\",\n    \"grunt-contrib-uglify\": \"~4.0.1\",\n    \"http-server\": \"^13.0.2\",\n    \"jszip-utils\": \"~0.0.2\",\n    \"package-json-versionify\": \"1.0.2\",\n    \"playwright\": \"^1.51.0\",\n    \"qunit\": \"~2.9.2\",\n    \"tmp\": \"0.0.28\",\n    \"typescript\": \"^4.6.3\"\n  },\n  \"dependencies\": {\n    \"lie\": \"~3.3.0\",\n    \"pako\": \"~1.0.2\",\n    \"readable-stream\": \"~2.3.6\",\n    \"setimmediate\": \"^1.0.5\"\n  },\n  \"license\": \"(MIT OR GPL-3.0-or-later)\"\n}\n"
  },
  {
    "path": "sponsors.md",
    "content": "---\ntitle: \"Sponsors\"\nlayout: default\nsection: main\n---\n\n[JSZip](https://github.com/Stuk/jszip) was created in 2009 by [Stuart](https://github.com/Stuk). Since then it has received well over [600 million downloads](https://npm-stat.com/charts.html?package=jszip&from=2009-06-20&to=2022-06-20), is depended on by over 3000 packages on npm, and powers zipping and unzipping on sites large and small.\n\nThis project only exists because of all the work dedicated to it by me and the other contributors.\n\nIf you or your company has benefited from JSZip then please consider [sponsoring on Github](https://github.com/sponsors/Stuk).\n\n## 💎 Diamond\n\n## 🥇 Gold\n\n## 🥈 Silver\n\n## 🥉 Bronze\n\n## Supporters\n"
  },
  {
    "path": "test/.eslintrc.js",
    "content": "\"use strict\";\n\nmodule.exports = {\n    globals: {\n        JSZip: false,\n        JSZipUtils: false,\n        JSZipTestUtils: false,\n        QUnit: false,\n    },\n};\n"
  },
  {
    "path": "test/asserts/constructor.js",
    "content": "\"use strict\";\n\nQUnit.module(\"constructor\");\n\nQUnit.test(\"JSZip exists\", function(assert){\n    assert.ok(JSZip, \"JSZip exists\");\n});\n\nQUnit.test(\"new JSZip()\", function(assert){\n    var zip = new JSZip();\n    assert.ok(zip instanceof JSZip, \"Constructor works\");\n});\n\nQUnit.test(\"JSZip()\", function(assert){\n    var zip = JSZip();\n    assert.ok(zip instanceof JSZip, \"Constructor adds `new` before itself where necessary\");\n});\n"
  },
  {
    "path": "test/asserts/delete.js",
    "content": "\"use strict\";\n\nQUnit.module(\"delete\");\n\nJSZipTestUtils.testZipFile(\"Delete file\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.file(\"Remove.txt\", \"This file should be deleted\\n\");\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    zip.remove(\"Remove.txt\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete file in folder\", \"ref/folder.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.folder(\"folder\").file(\"Remove.txt\", \"This folder and file should be deleted\\n\");\n    zip.remove(\"folder/Remove.txt\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete file in folder, with a relative path\", \"ref/folder.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    var folder = zip.folder(\"folder\");\n    folder.file(\"Remove.txt\", \"This folder and file should be deleted\\n\");\n    folder.remove(\"Remove.txt\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete folder\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.folder(\"remove\").file(\"Remove.txt\", \"This folder and file should be deleted\\n\");\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    zip.remove(\"remove\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete folder with a final /\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.folder(\"remove\").file(\"Remove.txt\", \"This folder and file should be deleted\\n\");\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    zip.remove(\"remove/\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete unknown path\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    zip.remove(\"unknown_file\");\n    zip.remove(\"unknown_folder/Hello.txt\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete nested folders\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.folder(\"remove\").file(\"Remove.txt\", \"This folder and file should be deleted\\n\");\n    zip.folder(\"remove/second\").file(\"Sub.txt\", \"This should be removed\");\n    zip.file(\"remove/second/another.txt\", \"Another file\");\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    zip.remove(\"remove\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Delete nested folders from relative path\", \"ref/folder.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.folder(\"folder\");\n    zip.folder(\"folder/1/2/3\");\n    zip.folder(\"folder\").remove(\"1\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        JSZipTestUtils.checkGenerateStability(assert, actual);\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n"
  },
  {
    "path": "test/asserts/deprecated.js",
    "content": "\"use strict\";\n\nQUnit.module(\"deprecated\");\n\nQUnit.test(\"Removed load method throws an exception\", function(assert) {\n    assert.throws(\n        function() {\n            new JSZip().load(\"\");\n        },\n        /upgrade guide/,\n        \"load() throws an exception\"\n    );\n});\nQUnit.test(\"Removed constructor with data throws an exception\", function(assert) {\n    assert.throws(\n        function() {\n            // eslint-disable-next-line no-new\n            new JSZip(\"\");\n        },\n        /upgrade guide/,\n        \"new JSZip(data) throws an exception\"\n    );\n});\nQUnit.test(\"Removed asText method throws an exception\", function(assert) {\n    var file = JSZipTestUtils.createZipAll().file(\"Hello.txt\");\n    assert.throws(\n        function() {\n            file.asText();\n        },\n        /upgrade guide/,\n        \"file.asText() throws an exception\"\n    );\n});\nQUnit.test(\"Removed generate method throws an exception\", function(assert) {\n    assert.throws(\n        function() {\n            new JSZip().generate({type:\"string\"});\n        },\n        /upgrade guide/,\n        \"generate() throws an exception\"\n    );\n});\n"
  },
  {
    "path": "test/asserts/external.js",
    "content": "\"use strict\";\n\nQUnit.module(\"external\");\n\n/**\n * Creates a wrapper around an existing Promise implementation to count\n * calls and detect custom implementations.\n * @param {Promise} OriginalPromise the promise to wrap\n * @return {Promise} the wrapped promise\n */\nfunction createPromiseProxy(OriginalPromise) {\n    function MyShinyPromise (input) {\n        if (input.then) { // thenable, we wrap it\n            this._promise = input;\n        } else { // executor\n            this._promise = new OriginalPromise(input);\n        }\n        MyShinyPromise.calls++;\n    }\n    MyShinyPromise.calls = 0;\n    MyShinyPromise.prototype = {\n        then: function (onFulfilled, onRejected) {\n            return new MyShinyPromise(this._promise.then(onFulfilled, onRejected));\n        },\n        \"catch\": function (onRejected) {\n            return new MyShinyPromise(this._promise[\"catch\"](onRejected));\n        },\n        isACustomImplementation: true\n    };\n\n    MyShinyPromise.resolve = function (value) {\n        return new MyShinyPromise(OriginalPromise.resolve(value));\n    };\n    MyShinyPromise.reject = function (value) {\n        return new MyShinyPromise(OriginalPromise.reject(value));\n    };\n    MyShinyPromise.all = function (value) {\n        return new MyShinyPromise(OriginalPromise.all(value));\n    };\n    return MyShinyPromise;\n}\n\nQUnit.test(\"JSZip.external.Promise\", function (assert) {\n    assert.ok(JSZip.external.Promise, \"JSZip.external.Promise is defined\");\n    assert.ok(JSZip.external.Promise.resolve, \"JSZip.external.Promise looks like a Promise\");\n    assert.ok(JSZip.external.Promise.reject, \"JSZip.external.Promise looks like a Promise\");\n});\n\nQUnit.test(\"load JSZip doesn't override the global Promise\", function (assert) {\n    if (typeof Promise !== \"undefined\"){\n        assert.equal(Promise, JSZipTestUtils.oldPromise, \"the previous Promise didn't change\");\n        assert.equal(Promise, JSZip.external.Promise, \"JSZip.external.Promise reused the global Promise\");\n    } else {\n        assert.ok(JSZip.external.Promise, \"JSZip.external.Promise is defined even if the global Promise doesn't exist\");\n    }\n});\n\nQUnit.test(\"external.Promise can be replaced in .async()\", function (assert) {\n    var done = assert.async();\n    var OriginalPromise = JSZip.external.Promise;\n    var MyShinyPromise = createPromiseProxy(OriginalPromise);\n\n    JSZip.external.Promise = MyShinyPromise;\n\n    var promise = JSZipTestUtils.createZipAll().file(\"Hello.txt\").async(\"string\").then(function () {\n        assert.ok(MyShinyPromise.calls > 0, \"at least 1 call of the new Promise\");\n        JSZip.external.Promise = OriginalPromise;\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n\n    assert.ok(promise.isACustomImplementation, \"the custom implementation is used\");\n});\n\nQUnit.test(\"external.Promise can be replaced in .generateAsync()\", function (assert) {\n    var done = assert.async();\n    var OriginalPromise = JSZip.external.Promise;\n    var MyShinyPromise = createPromiseProxy(OriginalPromise);\n\n    JSZip.external.Promise = MyShinyPromise;\n\n    var promise = JSZipTestUtils.createZipAll().generateAsync({type:\"string\"}).then(function () {\n        assert.ok(MyShinyPromise.calls > 0, \"at least 1 call of the new Promise\");\n        JSZip.external.Promise = OriginalPromise;\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n\n    assert.ok(promise.isACustomImplementation, \"the custom implementation is used\");\n});\n\nJSZipTestUtils.testZipFile(\"external.Promise can be replaced in .loadAsync()\", \"ref/all.zip\", function (assert, all) {\n    var done = assert.async();\n    var OriginalPromise = JSZip.external.Promise;\n    var MyShinyPromise = createPromiseProxy(OriginalPromise);\n\n    JSZip.external.Promise = MyShinyPromise;\n\n    var promise = JSZip.loadAsync(all).then(function () {\n        assert.ok(MyShinyPromise.calls > 0, \"at least 1 call of the new Promise\");\n        JSZip.external.Promise = OriginalPromise;\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n\n    assert.ok(promise.isACustomImplementation, \"the custom implementation is used\");\n});\n"
  },
  {
    "path": "test/asserts/file.js",
    "content": "\"use strict\";\n\nQUnit.module(\"file\", function () {\n\n    function str2blob (str) {\n        var u8 = new Uint8Array(str.length);\n        for(var i = 0; i < str.length; i++) {\n            u8[i] = str.charCodeAt(i);\n        }\n        try {\n            // don't use an Uint8Array, see the comment on utils.newBlob\n            return new Blob([u8.buffer], {type:\"text/plain\"});\n        } catch (e) {\n            var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;\n            var builder = new Builder();\n            builder.append(u8.buffer);\n            return builder.getBlob(\"text/plain\");\n        }\n    }\n\n    QUnit.module(\"add\");\n\n    JSZipTestUtils.testZipFile(\"Zip text file !\", \"ref/text.zip\", function(assert, expected) {\n        var done = assert.async();\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\");\n        JSZipTestUtils.checkBasicStreamBehavior(assert, zip.generateInternalStream({type:\"binarystring\"}));\n        zip.generateAsync({type:\"binarystring\"}).then(function (actual) {\n            assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"Zip text, folder and image\", \"ref/all.zip\", function(assert, expected) {\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\");\n        zip.folder(\"images\").file(\"smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n            assert.ok(JSZipTestUtils.similar(actual, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"Add a file to overwrite\", \"ref/text.zip\", function(assert, expected) {\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"hello ?\");\n        zip.file(\"Hello.txt\", \"Hello World\\n\");\n\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function (actual) {\n            assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"Zip text file with date\", \"ref/text.zip\", function(assert, expected) {\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\", {date : new Date(\"July 17, 2009 14:36:57\")});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n            /*\n               Expected differing bytes:\n               2  version number\n               4  central dir version numbers\n               4  external file attributes\n\n               10 Total\n               */\n            assert.ok(JSZipTestUtils.similar(actual, expected, 10) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n\n    JSZipTestUtils.testZipFile(\"Zip image file\", \"ref/image.zip\", function(assert, expected) {\n        var zip = new JSZip();\n        zip.file(\"smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n            assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"add file: from XHR (with bytes > 255)\", \"ref/text.zip\", function(assert, textZip) {\n        var zip = new JSZip();\n        zip.file(\"text.zip\", textZip, {binary:true});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n            // high-order byte is discarded and won't mess up the result\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    QUnit.test(\"add file: wrong string as base64\", function(assert) {\n        var zip = new JSZip();\n        zip.file(\"text.txt\", \"a random string\", {base64:true});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function() {\n            assert.ok(false, \"generateAsync should fail\");\n            done();\n        })[\"catch\"](function (e) {\n            assert.equal(e.message, \"Invalid base64 input, bad content length.\", \"triggers the correct error\");\n            done();\n        });\n    });\n\n    QUnit.test(\"add file: data url instead of base64\", function(assert) {\n        var zip = new JSZip();\n        zip.file(\"text.txt\", \"data:image/png;base64,YmFzZTY0\", {base64:true});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function() {\n            assert.ok(false, \"generateAsync should fail\");\n            done();\n        })[\"catch\"](function (e) {\n            assert.equal(e.message, \"Invalid base64 input, it looks like a data url.\", \"triggers the correct error\");\n            done();\n        });\n    });\n\n    function testFileDataGetters (assert, opts) {\n        if (typeof opts.rawData === \"undefined\") {\n            opts.rawData = opts.textData;\n        }\n        _actualTestFileDataGetters.testGetter(assert, opts, \"string\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"text\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"base64\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"array\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"binarystring\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"arraybuffer\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"uint8array\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"nodebuffer\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"blob\");\n        _actualTestFileDataGetters.testGetter(assert, opts, \"unknown\");\n        _actualTestFileDataGetters.testGetter(assert, opts, null);\n\n        var done = assert.async();\n        opts.zip.generateAsync({type:\"binarystring\"})\n            .then(JSZip.loadAsync)\n            .then(function(zip) {\n                var reloaded = {\n                    name : \"(reloaded) \" + opts.name,\n                    zip : zip,\n                    textData : opts.textData,\n                    rawData : opts.rawData\n                };\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"string\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"text\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"base64\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"array\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"binarystring\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"arraybuffer\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"uint8array\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"nodebuffer\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"blob\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, \"unknown\");\n                _actualTestFileDataGetters.testGetter(assert, reloaded, null);\n\n                opts.zip.file(\"file.txt\", \"changing the content after the call won't change the result\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n        opts.zip.file(\"file.txt\", \"changing the content after the call won't change the result\");\n    }\n\n    var _actualTestFileDataGetters = {\n        testGetter : function (assert, opts, askedType) {\n            var asyncTestName = \"[test = \" + opts.name + \"] [method = async(\" + askedType + \")] \";\n\n            var stream = opts.zip.file(\"file.txt\").internalStream(askedType);\n            JSZipTestUtils.checkBasicStreamBehavior(assert, stream, asyncTestName);\n\n            var done = assert.async();\n            opts.zip.file(\"file.txt\").async(askedType).then(function(result) {\n                _actualTestFileDataGetters[\"assert_\" + askedType](opts, null, result, asyncTestName);\n                done();\n            }, function (err) {\n                _actualTestFileDataGetters[\"assert_\" + askedType](opts, err, null, asyncTestName);\n                done();\n            });\n        },\n        assert_string: function (opts, err, txt, testName) {\n            QUnit.assert.equal(err, null, testName + \"no error\");\n            QUnit.assert.equal(txt, opts.textData, testName + \"content ok\");\n        },\n        assert_text: function () {\n            this.assert_string.apply(this, arguments);\n        },\n        assert_base64: function (opts, err, bin, testName) {\n            QUnit.assert.equal(err, null, testName + \"no error\");\n            QUnit.assert.equal(bin, JSZipTestUtils.base64encode(opts.rawData), testName + \"content ok\");\n        },\n        assert_binarystring : function (opts, err, bin, testName) {\n            QUnit.assert.equal(err, null, testName + \"no error\");\n            QUnit.assert.equal(bin, opts.rawData, testName + \"content ok\");\n        },\n        assert_array : function (opts, err, array, testName) {\n            QUnit.assert.equal(err, null, testName + \"no error\");\n            QUnit.assert.ok(array instanceof Array, testName + \"the result is a instance of Array\");\n            var actual = JSZipTestUtils.toString(array);\n            QUnit.assert.equal(actual, opts.rawData, testName + \"content ok\");\n        },\n        assert_arraybuffer : function (opts, err, buffer, testName) {\n            if (JSZip.support.arraybuffer) {\n                QUnit.assert.equal(err, null, testName + \"no error\");\n                QUnit.assert.ok(buffer instanceof ArrayBuffer, testName + \"the result is a instance of ArrayBuffer\");\n                var actual = JSZipTestUtils.toString(buffer);\n                QUnit.assert.equal(actual, opts.rawData, testName + \"content ok\");\n            } else {\n                QUnit.assert.equal(buffer, null, testName + \"no data\");\n                QUnit.assert.ok(err.message.match(\"not supported by this platform\"), testName + \"the error message is useful\");\n            }\n        },\n        assert_uint8array : function (opts, err, bufferView, testName) {\n            if (JSZip.support.uint8array) {\n                QUnit.assert.equal(err, null, testName + \"no error\");\n                QUnit.assert.ok(bufferView instanceof Uint8Array, testName+ \"the result is a instance of Uint8Array\");\n                var actual = JSZipTestUtils.toString(bufferView);\n                QUnit.assert.equal(actual, opts.rawData, testName + \"content ok\");\n            } else {\n                QUnit.assert.equal(bufferView, null, testName + \"no data\");\n                QUnit.assert.ok(err.message.match(\"not supported by this platform\"), testName + \"the error message is useful\");\n            }\n        },\n        assert_nodebuffer : function (opts, err, buffer, testName) {\n            if (JSZip.support.nodebuffer) {\n                QUnit.assert.equal(err, null, testName + \"no error\");\n                QUnit.assert.ok(buffer instanceof Buffer, testName + \"the result is a instance of Buffer\");\n                var actual = JSZipTestUtils.toString(buffer);\n                QUnit.assert.equal(actual, opts.rawData, testName + \"content ok\");\n            } else {\n                QUnit.assert.equal(buffer, null, testName + \"no data\");\n                QUnit.assert.ok(err.message.match(\"not supported by this platform\"), testName + \"the error message is useful\");\n            }\n        },\n        assert_blob : function (opts, err, blob, testName) {\n            if (JSZip.support.blob) {\n                QUnit.assert.equal(err, null, testName + \"no error\");\n                QUnit.assert.ok(blob instanceof Blob, testName + \"the result is a instance of Blob\");\n                QUnit.assert.equal(blob.type,  \"\", testName + \"the result has the right mime type\");\n                QUnit.assert.equal(blob.size, opts.rawData.length, testName + \"the result has the right length\");\n            } else {\n                QUnit.assert.equal(blob, null, testName + \"no data\");\n                QUnit.assert.ok(err.message.match(\"not supported by this platform\"), testName + \"the error message is useful\");\n            }\n        },\n        assert_unknown : function (opts, err, buffer, testName) {\n            QUnit.assert.equal(buffer, null, testName + \"no data\");\n            QUnit.assert.ok(err.message.match(\"not supported by this platform\"), testName + \"the error message is useful\");\n        },\n        assert_null : function (opts, err, buffer, testName) {\n            QUnit.assert.equal(buffer, null, testName + \"no data\");\n            QUnit.assert.ok(err.message.match(\"No output type specified\"), testName + \"the error message is useful\");\n        }\n    };\n\n    QUnit.test(\"add file: file(name, undefined)\", function (assert) {\n        var zip = new JSZip(), undef;\n        zip.file(\"file.txt\", undef);\n        testFileDataGetters(assert, {name : \"undefined\", zip : zip, textData : \"\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", undef, {binary:true});\n        testFileDataGetters(assert, {name : \"undefined as binary\", zip : zip, textData : \"\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", undef, {base64:true});\n        testFileDataGetters(assert, {name : \"undefined as base64\", zip : zip, textData : \"\"});\n    });\n\n    QUnit.test(\"add file: file(name, null)\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"file.txt\", null);\n        testFileDataGetters(assert, {name : \"null\", zip : zip, textData : \"\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", null, {binary:true});\n        testFileDataGetters(assert, {name : \"null as binary\", zip : zip, textData : \"\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", null, {base64:true});\n        testFileDataGetters(assert, {name : \"null as base64\", zip : zip, textData : \"\"});\n    });\n\n    QUnit.test(\"add file: file(name, stringAsText)\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"file.txt\", \"€15\\n\", {binary:false});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", \"test\\r\\ntest\\r\\n\", {binary:false});\n        testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n    });\n\n    QUnit.test(\"add file: file(name, stringAsBinary)\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"file.txt\", \"\\xE2\\x82\\xAC15\\n\", {binary:true});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", \"test\\r\\ntest\\r\\n\", {binary:true});\n        testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n    });\n\n    QUnit.test(\"add file: file(name, array)\", function (assert) {\n        var zip = new JSZip();\n        function toArray(str) {\n            var array = new Array(str.length);\n            for (var i = 0; i < str.length; i++) {\n                array[i] = str.charCodeAt(i);\n            }\n            return array;\n        }\n        zip.file(\"file.txt\", toArray(\"\\xE2\\x82\\xAC15\\n\"), {binary:true});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", toArray(\"test\\r\\ntest\\r\\n\"), {binary:true});\n        testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n    });\n\n    QUnit.test(\"add file: file(name, base64)\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"file.txt\", \"4oKsMTUK\", {base64:true});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", \"dGVzdA0KdGVzdA0K\", {base64:true});\n        testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n    });\n\n    QUnit.test(\"add file: file(name, unsupported)\", function (assert) {\n        var done = assert.async();\n        var zip = new JSZip();\n        zip.file(\"test.txt\", new Date());\n\n        zip.file(\"test.txt\")\n            .async(\"string\")\n        // XXX zip.file(name, data) returns a ZipObject for chaining,\n        // we need to try to get the value to get the error\n            .then(function () {\n                assert.ok(false, \"An unsupported object was added, but no exception thrown\");\n                done();\n            }, function (e) {\n                assert.ok(e.message.match(\"Is it in a supported JavaScript type\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    if (JSZip.support.uint8array) {\n        QUnit.test(\"add file: file(name, Uint8Array)\", function (assert) {\n            var str2array = function (str) {\n                var array = new Uint8Array(str.length);\n                for(var i = 0; i < str.length; i++) {\n                    array[i] = str.charCodeAt(i);\n                }\n                return array;\n            };\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2array(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2array(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2array(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n    if (JSZip.support.arraybuffer) {\n        QUnit.test(\"add file: file(name, ArrayBuffer)\", function (assert) {\n            var str2buffer = function (str) {\n                var array = new Uint8Array(str.length);\n                for(var i = 0; i < str.length; i++) {\n                    array[i] = str.charCodeAt(i);\n                }\n                return array.buffer;\n            };\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n    if (JSZip.support.blob) {\n        QUnit.test(\"add file: file(name, Blob)\", function (assert) {\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2blob(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2blob(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2blob(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n    if (typeof Promise !== \"undefined\") {\n        QUnit.test(\"add file: file(name, native Promise)\", function (assert) {\n            var str2promise = function (str) {\n                return new Promise(function(resolve) {\n                    setTimeout(function () {\n                        resolve(str);\n                    }, 10);\n                });\n            };\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2promise(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2promise(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2promise(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n    QUnit.test(\"add file: file(name, polyfill Promise[string] as binary)\", function (assert) {\n        var str2promise = function (str) {\n            return new JSZip.external.Promise(function(resolve) {\n                setTimeout(function () {\n                    resolve(str);\n                }, 10);\n            });\n        };\n        var zip = new JSZip();\n        zip.file(\"file.txt\", str2promise(\"\\xE2\\x82\\xAC15\\n\"), {binary: true});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n    });\n\n    QUnit.test(\"add file: file(name, polyfill Promise[string] force text)\", function (assert) {\n        var str2promise = function (str) {\n            return new JSZip.external.Promise(function(resolve) {\n                setTimeout(function () {\n                    resolve(str);\n                }, 10);\n            });\n        };\n        var zip = new JSZip();\n        zip.file(\"file.txt\", str2promise(\"€15\\n\"), {binary: false});\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n    });\n\n    /*\n     * Fix #325 for this one\n     *\n    QUnit.test(\"add file: file(name, polyfill Promise[string] as text)\", function (assert) {\n        var str2promise = function (str) {\n            return new JSZip.external.Promise(function(resolve, reject) {\n                setTimeout(function () {\n                    resolve(str);\n                }, 10);\n            });\n        };\n        var zip = new JSZip();\n        zip.file(\"file.txt\", str2promise(\"€15\\n\"));\n        testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", str2promise(\"test\\r\\ntest\\r\\n\"));\n        testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n        zip = new JSZip();\n        zip.file(\"file.txt\", str2promise(\"\"));\n        testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n    });\n   */\n\n    if (JSZip.support.blob) {\n        QUnit.test(\"add file: file(name, polyfill Promise[Blob])\", function (assert) {\n            var str2promiseOfBlob = function (str) {\n                return new JSZip.external.Promise(function(resolve) {\n                    setTimeout(function () {\n                        resolve(str2blob(str));\n                    }, 10);\n                });\n            };\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2promiseOfBlob(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2promiseOfBlob(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2promiseOfBlob(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n    if (JSZip.support.nodebuffer) {\n        QUnit.test(\"add file: file(name, Buffer)\", function (assert) {\n            var str2buffer = function (str) {\n                var array = new Buffer(str.length);\n                for(var i = 0; i < str.length; i++) {\n                    array[i] = str.charCodeAt(i);\n                }\n                return array;\n            };\n            var zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"\\xE2\\x82\\xAC15\\n\"));\n            testFileDataGetters(assert, {name : \"utf8\", zip : zip, textData : \"€15\\n\", rawData : \"\\xE2\\x82\\xAC15\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"test\\r\\ntest\\r\\n\"));\n            testFileDataGetters(assert, {name : \"\\\\r\\\\n\", zip : zip, textData : \"test\\r\\ntest\\r\\n\"});\n\n            zip = new JSZip();\n            zip.file(\"file.txt\", str2buffer(\"\"));\n            testFileDataGetters(assert, {name : \"empty content\", zip : zip, textData : \"\"});\n        });\n    }\n\n\n    QUnit.module(\"about folders\");\n\n    QUnit.test(\"Zip folder() shouldn't throw an exception\", function (assert) {\n        var zip = new JSZip();\n        try {\n            zip.folder();\n            assert.ok(true, \"no exception thrown\");\n        } catch (e) {\n            assert.ok(false, e.message||e);\n        }\n    });\n\n    JSZipTestUtils.testZipFile(\"Zip empty folder\", \"ref/folder.zip\", function(assert, expected) {\n        var zip = new JSZip();\n        zip.folder(\"folder\");\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"}).then(function(actual) {\n            assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, actual);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    QUnit.test(\"file() creates a folder with dir:true\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"folder\", null, {\n            dir : true\n        });\n        assert.ok(zip.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n    });\n\n    QUnit.test(\"file() creates a folder with the right unix permissions\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"folder\", null, {\n            unixPermissions : parseInt(\"40500\", 8)\n        });\n        assert.ok(zip.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n    });\n\n    QUnit.test(\"file() creates a folder with the right dos permissions\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"folder\", null, {\n            dosPermissions : parseInt(\"010000\", 2)\n        });\n        assert.ok(zip.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n    });\n\n    QUnit.test(\"A folder stays a folder when created with file\", function (assert) {\n        var referenceDate = new Date(\"July 17, 2009 14:36:56\");\n        var referenceComment = \"my comment\";\n        var zip = new JSZip();\n        zip.file(\"folder\", null, {\n            dir : true,\n            date : referenceDate,\n            comment : referenceComment,\n            unixPermissions : parseInt(\"40500\", 8)\n        });\n\n        assert.ok(zip.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n        assert.equal(zip.files[\"folder/\"].date.getTime(), referenceDate.getTime(), \"the folder with options has the correct date\");\n        assert.equal(zip.files[\"folder/\"].comment, referenceComment, \"the folder with options has the correct comment\");\n        assert.equal(zip.files[\"folder/\"].unixPermissions.toString(8), \"40500\", \"the folder with options has the correct UNIX permissions\");\n\n        var done = assert.async();\n        zip.generateAsync({type:\"string\", platform:\"UNIX\"})\n            .then(JSZip.loadAsync)\n            .then(function (reloaded) {\n                assert.ok(reloaded.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n\n                assert.ok(reloaded.files[\"folder/\"].dir, \"the folder with options is marked as a folder\");\n                assert.equal(reloaded.files[\"folder/\"].date.getTime(), referenceDate.getTime(), \"the folder with options has the correct date\");\n                assert.equal(reloaded.files[\"folder/\"].comment, referenceComment, \"the folder with options has the correct comment\");\n                assert.equal(reloaded.files[\"folder/\"].unixPermissions.toString(8), \"40500\", \"the folder with options has the correct UNIX permissions\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n    });\n\n    QUnit.test(\"file() adds a slash for directories\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"folder_without_slash\", null, {\n            dir : true\n        });\n        zip.file(\"folder_with_slash/\", null, {\n            dir : true\n        });\n        assert.ok(zip.files[\"folder_without_slash/\"], \"added a slash if not provided\");\n        assert.ok(zip.files[\"folder_with_slash/\"], \"keep the existing slash\");\n    });\n\n    QUnit.test(\"folder() doesn't overwrite existing entries\", function (assert) {\n        var referenceComment = \"my comment\";\n        var zip = new JSZip();\n        zip.file(\"folder\", null, {\n            dir : true,\n            comment : referenceComment,\n            unixPermissions : parseInt(\"40500\", 8)\n        });\n\n        // calling folder() doesn't override it\n        zip.folder(\"folder\");\n\n        assert.equal(zip.files[\"folder/\"].comment, referenceComment, \"the folder with options has the correct comment\");\n        assert.equal(zip.files[\"folder/\"].unixPermissions.toString(8), \"40500\", \"the folder with options has the correct UNIX permissions\");\n    });\n\n    QUnit.test(\"createFolders works on a file\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"false/0/1/2/file\", \"content\", {createFolders:false, unixPermissions:\"644\"});\n        zip.file(\"true/0/1/2/file\", \"content\", {createFolders:true, unixPermissions:\"644\"});\n\n        assert.ok(!zip.files[\"false/\"], \"the false/ folder doesn't exist\");\n        assert.ok(zip.files[\"true/\"], \"the true/ folder exists\");\n        assert.equal(zip.files[\"true/\"].unixPermissions, null, \"the options are not propagated\");\n    });\n\n    QUnit.test(\"createFolders works on a folder\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"false/0/1/2/folder\", null, {createFolders:false, unixPermissions:\"777\",dir:true});\n        zip.file(\"true/0/1/2/folder\", null, {createFolders:true, unixPermissions:\"777\",dir:true});\n\n        assert.ok(!zip.files[\"false/\"], \"the false/ folder doesn't exist\");\n        assert.ok(zip.files[\"true/\"], \"the true/ folder exists\");\n        assert.equal(zip.files[\"true/\"].unixPermissions, null, \"the options are not propagated\");\n    });\n\n    QUnit.test(\"folder follows the default createFolders settings\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"true/0/1/2/folder\");\n        assert.ok(zip.files[\"true/\"], \"the true/ folder exists\");\n    });\n\n\n    QUnit.test(\"A folder stays a folder\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"folder/\");\n        assert.ok(zip.files[\"folder/\"].dir, \"the folder is marked as a folder\");\n\n\n        var done = assert.async();\n\n        zip.generateAsync({type:\"binarystring\"})\n            .then(JSZip.loadAsync)\n            .then(function (reloaded) {\n                assert.ok(reloaded.files[\"folder/\"].dir, \"the folder is marked as a folder\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    QUnit.test(\"Folders are created by default\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"test/Readme\", \"Hello World!\\n\");\n        assert.ok(zip.files[\"test/Readme\"], \"the file exists\");\n        assert.ok(zip.files[\"test/\"], \"the folder exists\");\n    });\n\n    QUnit.test(\"Folders can be avoided with createFolders\", function (assert) {\n        var zip = new JSZip();\n        zip.file(\"test/Readme\", \"Hello World!\\n\", {createFolders: false});\n        assert.ok(zip.files[\"test/Readme\"], \"the file exists\");\n        assert.ok(!zip.files[\"test/\"], \"the folder doesn't exist\");\n    });\n\n    QUnit.module(\"find entries\");\n\n\n    QUnit.test(\"Finding a file\", function(assert) {\n        var zip = new JSZip();\n        zip.file(\"Readme\", \"Hello World!\\n\");\n        zip.file(\"Readme.French\", \"Bonjour tout le monde!\\n\");\n        zip.file(\"Readme.Pirate\", \"Ahoy m'hearty!\\n\");\n\n        var done = assert.async();\n        zip.file(\"Readme.French\").async(\"string\").then(function (content) {\n            assert.equal(content, \"Bonjour tout le monde!\\n\", \"Exact match found\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n        assert.equal(zip.file(\"Readme.Deutsch\"), null, \"Match exactly nothing\");\n        assert.equal(zip.file(/Readme\\../).length, 2, \"Match regex free text\");\n        assert.equal(zip.file(/pirate/i).length, 1, \"Match regex 1 result\");\n    });\n\n    QUnit.test(\"Finding a file (text search) with a relative folder\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"files/default\").file(\"Readme\", \"Hello World!\\n\");\n        zip.folder(\"files/translation\").file(\"Readme.French\", \"Bonjour tout le monde!\\n\");\n        zip.folder(\"files\").folder(\"translation\").file(\"Readme.Pirate\", \"Ahoy m'hearty!\\n\");\n\n        var done = assert.async(3);\n        zip.file(\"files/translation/Readme.French\").async(\"string\").then(function (content) {\n            assert.equal(content, \"Bonjour tout le monde!\\n\", \"finding file with the full path\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n        zip.folder(\"files\").file(\"translation/Readme.French\").async(\"string\").then(function (content) {\n            assert.equal(content, \"Bonjour tout le monde!\\n\", \"finding file with a relative path\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n        zip.folder(\"files/translation\").file(\"Readme.French\").async(\"string\").then(function (content) {\n            assert.equal(content, \"Bonjour tout le monde!\\n\", \"finding file with a relative path\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    QUnit.test(\"Finding files (regex) with a relative folder\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"files/default\").file(\"Readme\", \"Hello World!\\n\");\n        zip.folder(\"files/translation\").file(\"Readme.French\", \"Bonjour tout le monde!\\n\");\n        zip.folder(\"files\").folder(\"translation\").file(\"Readme.Pirate\", \"Ahoy m'hearty!\\n\");\n\n        assert.equal(zip.file(/Readme/).length, 3, \"match files in subfolders\");\n        assert.equal(zip.folder(\"files/translation\").file(/Readme/).length, 2, \"regex match only in subfolders\");\n        assert.equal(zip.folder(\"files\").folder(\"translation\").file(/Readme/).length, 2, \"regex match only in subfolders\");\n        assert.equal(zip.folder(\"files/translation\").file(/pirate/i).length, 1, \"regex match only in subfolders\");\n        assert.equal(zip.folder(\"files/translation\").file(/^readme/i).length, 2, \"regex match only with the relative path\");\n        assert.equal(zip.folder(\"files/default\").file(/pirate/i).length, 0, \"regex match only in subfolders\");\n    });\n\n    QUnit.test(\"Finding folders\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"root/\").folder(\"sub1/\");\n        zip.folder(\"root/sub2/subsub1\");\n\n        assert.equal(zip.folder(/sub2\\/$/).length, 1, \"unique result\");\n        assert.equal(zip.folder(/sub1/).length, 2, \"multiple results\");\n        assert.equal(zip.folder(/root/).length, 4, \"match on whole path\");\n    });\n\n    QUnit.test(\"Finding folders with relative path\", function (assert) {\n        var zip = new JSZip();\n        zip.folder(\"root/\").folder(\"sub1/\");\n        zip.folder(\"root/sub2/subsub1\");\n        var root = zip.folder(\"root/sub2\");\n\n        assert.equal(root.folder(/sub2\\/$/).length, 0, \"current folder is not matched\");\n        assert.equal(root.folder(/sub1/).length, 1, \"sub folder is matched\");\n        assert.equal(root.folder(/^subsub1/).length, 1, \"relative folder path is used\");\n        assert.equal(root.folder(/root/).length, 0, \"parent folder is not matched\");\n    });\n\n    function zipObjectsAssertions(assert, zipObject) {\n        var date = new Date(\"July 17, 2009 14:36:57\");\n\n        assert.equal(zipObject.name, \"Hello.txt\", \"ZipObject#name is here\");\n\n        assert.equal(zipObject.comment, \"my comment\", \"ZipObject#comment is here\");\n\n        // the zip date has a 2s resolution\n        var delta = Math.abs(zipObject.date.getTime() - date.getTime());\n        assert.ok(delta < 2000/* ms */, date, \"ZipObject#date is here\");\n    }\n    QUnit.test(\"ZipObject attributes\", function (assert) {\n        var date = new Date(\"July 17, 2009 14:36:57\");\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\", {comment:\"my comment\", date:date});\n        zipObjectsAssertions(assert, zip.file(\"Hello.txt\"));\n        zipObjectsAssertions(assert, zip.files[\"Hello.txt\"]);\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"})\n            .then(JSZip.loadAsync)\n            .then(function(reloaded) {\n                zipObjectsAssertions(assert, reloaded.file(\"Hello.txt\"));\n                zipObjectsAssertions(assert, reloaded.files[\"Hello.txt\"]);\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n    QUnit.test(\"generate uses updated ZipObject date attribute\", function (assert) {\n        var date = new Date(\"July 17, 2009 14:36:57\");\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\", {comment:\"my comment\"}); // date = now\n        zip.files[\"Hello.txt\"].date = date;\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\"})\n            .then(JSZip.loadAsync)\n            .then(function(reloaded) {\n                zipObjectsAssertions(assert, reloaded.file(\"Hello.txt\"));\n                zipObjectsAssertions(assert, reloaded.files[\"Hello.txt\"]);\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n});\n"
  },
  {
    "path": "test/asserts/filter.js",
    "content": "\"use strict\";\n\nQUnit.module(\"filter\");\n\nQUnit.test(\"Filtering a zip\", function(assert) {\n    var zip = new JSZip();\n    zip.file(\"1.txt\", \"1\\n\");\n    zip.file(\"2.txt\", \"2\\n\");\n    zip.file(\"3.log\", \"3\\n\");\n    var result = zip.filter(function(relativeFilename) {\n        return relativeFilename.indexOf(\".txt\") !== -1;\n    });\n    assert.equal(result.length, 2, \"filter has filtered\");\n    assert.ok(result[0].name.indexOf(\".txt\") !== -1, \"filter has filtered the good file\");\n    assert.ok(result[1].name.indexOf(\".txt\") !== -1, \"filter has filtered the good file\");\n});\n\nQUnit.test(\"Filtering a zip from a relative path\", function(assert) {\n    var zip = new JSZip();\n    zip.file(\"foo/1.txt\", \"1\\n\");\n    zip.file(\"foo/2.txt\", \"2\\n\");\n    zip.file(\"foo/3.log\", \"3\\n\");\n    zip.file(\"1.txt\", \"1\\n\");\n    zip.file(\"2.txt\", \"2\\n\");\n    zip.file(\"3.log\", \"3\\n\");\n\n    var count = 0;\n    var result = zip.folder(\"foo\").filter(function(relativeFilename) {\n        count++;\n        return relativeFilename.indexOf(\"3\") !== -1;\n    });\n    assert.equal(count, 3, \"the callback has been called the right number of times\");\n    assert.equal(result.length, 1, \"filter has filtered\");\n    assert.equal(result[0].name, \"foo/3.log\", \"filter has filtered the good file\");\n});\n\nQUnit.test(\"Filtering a zip : the full path is still accessible\", function(assert) {\n    var zip = new JSZip();\n    zip.file(\"foo/1.txt\", \"1\\n\");\n    zip.file(\"foo/2.txt\", \"2\\n\");\n    zip.file(\"foo/3.log\", \"3\\n\");\n    zip.file(\"1.txt\", \"1\\n\");\n    zip.file(\"2.txt\", \"2\\n\");\n    zip.file(\"3.log\", \"3\\n\");\n\n    var result = zip.folder(\"foo\").filter(function(relativeFilename, file) {\n        return file.name.indexOf(\"3\") !== -1;\n    });\n    assert.equal(result.length, 1, \"the filter only match files/folders in the current folder\");\n    assert.equal(result[0].name, \"foo/3.log\", \"filter has filtered the good file\");\n});\n"
  },
  {
    "path": "test/asserts/foreach.js",
    "content": "\"use strict\";\n\nQUnit.module(\"forEach\");\n\nQUnit.test(\"forEach works on /\", function (assert) {\n    var zip = JSZipTestUtils.createZipAll();\n    var count = 0;\n    var calls = [];\n\n    assert.equal(zip.root, \"\");\n\n    zip.forEach(function (path, elt) {\n        assert.equal(path, elt.name, \"the full path is given on / for \" + elt.name);\n        count++;\n        calls.push(path);\n    });\n\n    assert.equal(count, 3, \"the callback has been called the right number of times\");\n    assert.deepEqual(calls, [\"Hello.txt\", \"images/\", \"images/smile.gif\"], \"all paths have been called\");\n});\n\nQUnit.test(\"forEach works on a sub folder\", function (assert) {\n    var zip = new JSZip();\n    var sub = zip.folder(\"subfolder\");\n    sub.file(\"Hello.txt\", \"Hello World\\n\");\n    sub.folder(\"images\").file(\"smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true});\n    var count = 0;\n    var calls = [];\n\n    assert.ok(zip.file(\"subfolder/Hello.txt\"));\n    assert.equal(sub.root, \"subfolder/\");\n\n    sub.forEach(function (path, elt) {\n        assert.equal(path, elt.name.substr(\"subfolder/\".length), \"the full path is given on subfolder/ for \" + path);\n        count++;\n        calls.push(path);\n    });\n\n    assert.equal(count, 3, \"the callback has been called the right number of times\");\n    assert.deepEqual(calls, [\"Hello.txt\", \"images/\", \"images/smile.gif\"], \"all paths have been called\");\n});\n"
  },
  {
    "path": "test/asserts/generate.js",
    "content": "\"use strict\";\n\nQUnit.module(\"generate\");\n\nfunction testGenerateFor(testCases, fn) {\n    while(testCases.length) {\n        var testCase = testCases.shift();\n        fn(testCase.name, testCase.file, testCase.streamFiles);\n    }\n}\n\nfunction testGenerate(assert, options) {\n    var done = assert.async();\n    var triggeredCallback = false;\n    new JSZip.external.Promise(function(resolve) {\n        resolve(options.prepare());\n    })\n        .then(function (zip) {\n            JSZipTestUtils.checkBasicStreamBehavior(assert, zip.generateInternalStream(options.options));\n            return zip;\n        })\n        .then(function(zip) {\n            var promise = zip.generateAsync(options.options);\n            zip.file(\"Hello.txt\", \"updating the zip file after the call won't change the result\");\n            return promise;\n        })\n        .then(function(result) {\n            triggeredCallback = true;\n            options.assertions(null, result);\n\n            if (!options.skipReloadTest) {\n                JSZipTestUtils.checkGenerateStability(assert, result, options.options);\n            }\n            done();\n        }, function (err) {\n            triggeredCallback = true;\n            options.assertions(err, null);\n            done();\n        });\n    assert.ok(!triggeredCallback, \"the async callback is async\");\n}\n\ntestGenerateFor([{\n    name : \"no stream\",\n    file : \"ref/all.zip\",\n    streamFiles : false\n}, {\n    name : \"with stream\",\n    // zip -fd -0 -X -r all-stream.zip Hello.txt images/\n    file : \"ref/all-stream.zip\",\n    streamFiles : true\n}], function(testName, file, streamFiles) {\n\n    JSZipTestUtils.testZipFile(\"generate : type:string. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"binarystring\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                assert.equal(err, null, \"no error\");\n                assert.ok(JSZipTestUtils.similar(result, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n            }\n        });\n    });\n    JSZipTestUtils.testZipFile(\"generate : type:base64. \" + testName, file, function(assert) {\n        testGenerate(assert, {\n            prepare : function () {\n                // fix date to get a predictable output\n                var zip = new JSZip();\n                zip.file(\"Hello.txt\", \"Hello World\\n\", {date: new Date(1234567891011)});\n                zip.file(\"images\", null, {dir:true, date: new Date(1234876591011)});\n                zip.file(\"images/smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true, date: new Date(1234123491011)});\n                return zip;\n            },\n            skipReloadTest : true,\n            options : {type:\"base64\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                assert.equal(err, null, \"no error\");\n                assert.equal(result, JSZipTestUtils.base64encode(\"all.zip.base64,stream=\" + streamFiles), \"generated ZIP matches reference ZIP\");\n            }\n        });\n    });\n\n    JSZipTestUtils.testZipFile(\"generate : type:uint8array. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"uint8array\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                if (JSZip.support.uint8array) {\n                    assert.equal(err, null, \"no error\");\n                    assert.ok(result instanceof Uint8Array, \"the result is a instance of Uint8Array\");\n\n                    // var actual = JSZipTestUtils.toString(result);\n\n                    assert.ok(JSZipTestUtils.similar(result, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n                } else {\n                    assert.equal(result, null, \"no data\");\n                    assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n                }\n            }\n        });\n    });\n\n    JSZipTestUtils.testZipFile(\"generate : type:arraybuffer. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"arraybuffer\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                if (JSZip.support.arraybuffer) {\n                    assert.equal(err, null, \"no error\");\n                    assert.ok(result instanceof ArrayBuffer, \"the result is a instance of ArrayBuffer\");\n\n                    assert.ok(JSZipTestUtils.similar(result, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n                } else {\n                    assert.equal(result, null, \"no data\");\n                    assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n                }\n            }\n        });\n    });\n\n\n    JSZipTestUtils.testZipFile(\"generate : type:nodebuffer. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"nodebuffer\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                if (JSZip.support.nodebuffer) {\n                    assert.equal(err, null, \"no error\");\n                    assert.ok(result instanceof Buffer, \"the result is a instance of ArrayBuffer\");\n\n                    var actual = JSZipTestUtils.toString(result);\n\n                    assert.ok(JSZipTestUtils.similar(actual, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n                } else {\n                    assert.equal(result, null, \"no data\");\n                    assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n                }\n            }\n        });\n    });\n\n    JSZipTestUtils.testZipFile(\"generate : type:blob. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"blob\",streamFiles:streamFiles},\n            skipReloadTest : true,\n            assertions : function (err, result) {\n                if (JSZip.support.blob) {\n                    assert.equal(err, null, \"no error\");\n                    assert.ok(result instanceof Blob, \"the result is a instance of Blob\");\n                    assert.equal(result.type, \"application/zip\", \"the result has the right mime type\");\n                    assert.equal(result.size, expected.length, \"the result has the right length\");\n                } else {\n                    assert.equal(result, null, \"no data\");\n                    assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n                }\n            }\n        });\n    });\n\n    JSZipTestUtils.testZipFile(\"generate : type:blob mimeType:application/ods. \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : JSZipTestUtils.createZipAll,\n            options : {type:\"blob\",mimeType: \"application/ods\",streamFiles:streamFiles},\n            skipReloadTest : true,\n            assertions : function (err, result) {\n                if (JSZip.support.blob) {\n                    assert.equal(err, null, \"no error\");\n                    assert.ok(result instanceof Blob, \"the result is a instance of Blob\");\n                    assert.equal(result.type, \"application/ods\", \"the result has the right mime type\");\n                    assert.equal(result.size, expected.length, \"the result has the right length\");\n                } else {\n                    assert.equal(result, null, \"no data\");\n                    assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n                }\n            }\n        });\n    });\n});\n\n\ntestGenerateFor([{\n    name : \"no stream\",\n    // zip -0 -X store.zip Hello.txt\n    file : \"ref/store.zip\",\n    streamFiles : false\n}, {\n    name : \"with stream\",\n    // zip -0 -X -fd store-stream.zip Hello.txt\n    file : \"ref/store-stream.zip\",\n    streamFiles : true\n}], function(testName, file, streamFiles) {\n    JSZipTestUtils.testZipFile(\"STORE doesn't compress, \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : function () {\n                var zip = new JSZip();\n                zip.file(\"Hello.txt\", \"This a looong file : we need to see the difference between the different compression methods.\\n\");\n                return zip;\n            },\n            options : {type:\"binarystring\", compression:\"STORE\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                assert.equal(err, null, \"no error\");\n                assert.ok(JSZipTestUtils.similar(result, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n            }\n        });\n    });\n});\n\ntestGenerateFor([{\n    name : \"no stream\",\n    // zip -6 -X deflate.zip Hello.txt\n    file : \"ref/deflate.zip\",\n    streamFiles : false\n}, {\n    name : \"with stream\",\n    // zip -6 -X -fd deflate-stream.zip Hello.txt\n    file : \"ref/deflate-stream.zip\",\n    streamFiles : true\n}], function(testName, file, streamFiles) {\n    JSZipTestUtils.testZipFile(\"DEFLATE compress, \" + testName, file, function(assert, expected) {\n        testGenerate(assert, {\n            prepare : function () {\n                var zip = new JSZip();\n                zip.file(\"Hello.txt\", \"This a looong file : we need to see the difference between the different compression methods.\\n\");\n                return zip;\n            },\n            options : {type:\"binarystring\", compression:\"DEFLATE\",streamFiles:streamFiles},\n            assertions : function (err, result) {\n                assert.equal(err, null, \"no error\");\n                assert.ok(JSZipTestUtils.similar(result, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n            }\n        });\n    });\n});\n\nJSZipTestUtils.testZipFile(\"STORE is the default method\", \"ref/text.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.file(\"Hello.txt\", \"Hello World\\n\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\", compression:\"STORE\"}).then(function(content) {\n        // no difference with the \"Zip text file\" test.\n        assert.ok(JSZipTestUtils.similar(content, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\n\nfunction testLazyDecompression(assert, from, to) {\n    var done = assert.async();\n    JSZipTestUtils.createZipAll().generateAsync({type:\"binarystring\", compression:from}).then(function(actual) {\n        done();\n        testGenerate(assert, {\n            prepare : function () {\n                // the zip object will contain compressed objects\n                return JSZip.loadAsync(actual);\n            },\n            skipReloadTest : true,\n            options : {type:\"binarystring\", compression:to},\n            assertions : function (err) {\n                assert.equal(err, null, from + \" -> \" + to + \" : no error\");\n            }\n        });\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n}\nQUnit.test(\"Lazy decompression works\", function(assert) {\n    testLazyDecompression(assert, \"STORE\", \"STORE\");\n    testLazyDecompression(assert, \"DEFLATE\", \"STORE\");\n    testLazyDecompression(assert, \"STORE\", \"DEFLATE\");\n    testLazyDecompression(assert, \"DEFLATE\", \"DEFLATE\");\n});\n\n\n// zip -0 -X empty.zip plop && zip -d empty.zip plop\nJSZipTestUtils.testZipFile(\"empty zip\", \"ref/empty.zip\", function(assert, expected) {\n    testGenerate(assert, {\n        prepare : function () {\n            var zip = new JSZip();\n            return zip;\n        },\n        options : {type:\"binarystring\"},\n        assertions : function (err, result) {\n            assert.equal(err, null, \"no error\");\n            assert.ok(JSZipTestUtils.similar(result, expected, 0 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n        }\n    });\n});\n\nQUnit.test(\"unknown compression throws an exception\", function (assert) {\n    testGenerate(assert, {\n        prepare : JSZipTestUtils.createZipAll,\n        options : {type:\"string\",compression:\"MAYBE\"},\n        assertions : function (err, result) {\n            assert.equal(result, null, \"no data\");\n            assert.ok(err.message.match(\"not a valid compression\"), \"the error message is useful\");\n        }\n    });\n});\n\nQUnit.test(\"missing type throws an exception\", function (assert) {\n    testGenerate(assert, {\n        prepare : JSZipTestUtils.createZipAll,\n        options : {},\n        assertions : function (err, result) {\n            assert.equal(result, null, \"no data\");\n            assert.ok(err.message.match(\"No output type specified.\"), \"the error message is useful\");\n        }\n    });\n});\n\nQUnit.test(\"generateAsync uses the current folder level\", function (assert) {\n    var done = assert.async();\n\n    var zip = new JSZip();\n    zip.file(\"file1\", \"a\");\n    zip.folder(\"root1\");\n    zip.folder(\"root2\").file(\"leaf1\", \"a\");\n    zip.folder(\"root2\")\n        .generateAsync({type:\"string\"})\n        .then(JSZip.loadAsync)\n        .then(function(zip) {\n            assert.ok(!zip.file(\"file1\"), \"root files are not present\");\n            assert.ok(!zip.file(\"root1\"), \"root folders are not present\");\n            assert.ok(!zip.file(\"root2\"), \"root folders are not present\");\n            assert.ok(zip.file(\"leaf1\"), \"leaves are present\");\n\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nQUnit.test(\"generateAsync keep the explicit / folder\", function (assert) {\n    var done = assert.async();\n\n    var zip = new JSZip();\n    zip.file(\"/file1\", \"a\");\n    zip.file(\"/root1/file2\", \"b\");\n    zip.generateAsync({type:\"string\"})\n        .then(JSZip.loadAsync)\n        .then(function(zip) {\n            assert.ok(zip.file(\"/file1\"), \"root files are present\");\n            assert.ok(zip.file(\"/root1/file2\"), \"root folders are present\");\n\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"generate with promises as files\", \"ref/all.zip\", function (assert, expected) {\n    var done = assert.async();\n    var zip = new JSZip();\n    zip.file(\"Hello.txt\", new JSZip.external.Promise(function (resolve) {\n        setTimeout(function () {\n            resolve(\"Hello World\\n\");\n        }, 50);\n    }));\n    zip.folder(\"images\").file(\"smile.gif\", new JSZip.external.Promise(function (resolve) {\n        setTimeout(function () {\n            resolve(\"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\");\n        }, 100);\n    }), {base64: true});\n\n    zip.generateAsync({type:\"string\"})\n        .then(function (result) {\n            assert.ok(JSZipTestUtils.similar(result, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n"
  },
  {
    "path": "test/asserts/load.js",
    "content": "\"use strict\";\n\nQUnit.module(\"load\", function () {\n\n\n    JSZipTestUtils.testZipFile(\"load(string) works\", \"ref/all.zip\", function(assert, file) {\n        var done = assert.async();\n        assert.ok(typeof file === \"string\");\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function(result) {\n                assert.equal(result, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"Load files which shadow Object prototype methods\", \"ref/pollution.zip\", function(assert, file) {\n        var done = assert.async();\n        assert.ok(typeof file === \"string\");\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                assert.notEqual(Object.getPrototypeOf(zip.files), zip.files.__proto__);\n                return zip.file(\"__proto__\").async(\"string\");        })\n            .then(function(result) {\n                assert.equal(result, \"hello\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"load(string) handles bytes > 255\", \"ref/all.zip\", function(assert, file) {\n        var done = assert.async();\n        // the method used to load zip with ajax will remove the extra bits.\n        // adding extra bits :)\n        var updatedFile = \"\";\n        for (var i = 0; i < file.length; i++) {\n            updatedFile += String.fromCharCode((file.charCodeAt(i) & 0xff) + 0x4200);\n        }\n\n        JSZip.loadAsync(updatedFile)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n\n    JSZipTestUtils.testZipFile(\"load(Array) works\", \"ref/deflate.zip\", function(assert, file) {\n        var done = assert.async();\n        var updatedFile = new Array(file.length);\n        for( var i = 0; i < file.length; ++i ) {\n            updatedFile[i] = file.charCodeAt(i);\n        }\n        JSZip.loadAsync(updatedFile)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"This a looong file : we need to see the difference between the different compression methods.\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    JSZipTestUtils.testZipFile(\"load(array) handles bytes > 255\", \"ref/deflate.zip\", function(assert, file) {\n        var done = assert.async();\n        var updatedFile = new Array(file.length);\n        for( var i = 0; i < file.length; ++i ) {\n            updatedFile[i] = file.charCodeAt(i) + 0x4200;\n        }\n        JSZip.loadAsync(updatedFile)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"This a looong file : we need to see the difference between the different compression methods.\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    if (JSZip.support.arraybuffer) {\n        JSZipTestUtils.testZipFile(\"load(ArrayBuffer) works\", \"ref/all.zip\", function(assert, fileAsString) {\n            var done = assert.async(3);\n            var file = new ArrayBuffer(fileAsString.length);\n            var bufferView = new Uint8Array(file);\n            for( var i = 0; i < fileAsString.length; ++i ) {\n                bufferView[i] = fileAsString.charCodeAt(i);\n            }\n\n            assert.ok(file instanceof ArrayBuffer);\n\n            // when reading an arraybuffer, the CompressedObject mechanism will keep it and subarray() a Uint8Array.\n            // if we request a file in the same format, we might get the same Uint8Array or its ArrayBuffer (the original zip file).\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"arraybuffer\");\n                }).then(function (content){\n                    assert.equal(content.byteLength, 12, \"don't get the original buffer\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"uint8array\");\n                }).then(function (content){\n                    assert.equal(content.buffer.byteLength, 12, \"don't get a view of the original buffer\");\n                    done();\n                });\n\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"string\");\n                }).then(function (content){\n                    assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                    done();\n                });\n        });\n    }\n\n    if (JSZip.support.nodebuffer) {\n        JSZipTestUtils.testZipFile(\"load(Buffer) works\", \"ref/all.zip\", function(assert, fileAsString) {\n            var done = assert.async();\n            var file = new Buffer(fileAsString.length);\n            for( var i = 0; i < fileAsString.length; ++i ) {\n                file[i] = fileAsString.charCodeAt(i);\n            }\n\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"string\");\n                }).then(function (content){\n                    assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                    done();\n                });\n        });\n    }\n\n    if (JSZip.support.uint8array) {\n        JSZipTestUtils.testZipFile(\"load(Uint8Array) works\", \"ref/all.zip\", function(assert, fileAsString) {\n            var done = assert.async(3);\n            var file = new Uint8Array(fileAsString.length);\n            for( var i = 0; i < fileAsString.length; ++i ) {\n                file[i] = fileAsString.charCodeAt(i);\n            }\n\n            assert.ok(file instanceof Uint8Array);\n\n            // when reading an arraybuffer, the CompressedObject mechanism will keep it and subarray() a Uint8Array.\n            // if we request a file in the same format, we might get the same Uint8Array or its ArrayBuffer (the original zip file).\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"arraybuffer\");\n                }).then(function (content){\n                    assert.equal(content.byteLength, 12, \"don't get the original buffer\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"uint8array\");\n                }).then(function (content){\n                    assert.equal(content.buffer.byteLength, 12, \"don't get a view of the original buffer\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"string\");\n                }).then(function (content){\n                    assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n    }\n\n    // zip -6 -X deflate.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"zip with DEFLATE\", \"ref/deflate.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"This a looong file : we need to see the difference between the different compression methods.\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // zip -0 -X -z -c archive_comment.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"read zip with comment\", \"ref/archive_comment.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                assert.equal(zip.comment, \"file comment\", \"the archive comment was correctly read.\");\n                assert.equal(zip.file(\"Hello.txt\").comment, \"entry comment\", \"the entry comment was correctly read.\");\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n    JSZipTestUtils.testZipFile(\"generate zip with comment\", \"ref/archive_comment.zip\", function(assert, file) {\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\", {comment:\"entry comment\"});\n        var done = assert.async();\n        zip.generateAsync({type:\"binarystring\", comment:\"file comment\"}).then(function(generated) {\n            assert.ok(JSZipTestUtils.similar(generated, file, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n            JSZipTestUtils.checkGenerateStability(assert, generated);\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // zip -0 extra_attributes.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"zip with extra attributes\", \"ref/extra_attributes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // use -fz to force use of Zip64 format\n    // zip -fz -0 zip64.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"zip 64\", \"ref/zip64.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // use -fd to force data descriptors as if streaming\n    // zip -fd -0 data_descriptor.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"zip with data descriptor\", \"ref/data_descriptor.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // combo of zip64 and data descriptors :\n    // zip -fz -fd -0 data_descriptor_zip64.zip Hello.txt\n    // this generate a corrupted zip file :(\n    // TODO : find how to get the two features\n\n    // zip -0 -X zip_within_zip.zip Hello.txt && zip -0 -X nested.zip Hello.txt zip_within_zip.zip\n    JSZipTestUtils.testZipFile(\"nested zip\", \"ref/nested.zip\", function(assert, file) {\n        var done = assert.async(2);\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"zip_within_zip.zip\").async(\"binarystring\");\n            })\n            .then(JSZip.loadAsync)\n            .then(function (innerZip) {\n                return innerZip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the inner zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // zip -fd -0 nested_data_descriptor.zip data_descriptor.zip\n    JSZipTestUtils.testZipFile(\"nested zip with data descriptors\", \"ref/nested_data_descriptor.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"data_descriptor.zip\").async(\"binarystring\");\n            })\n            .then(JSZip.loadAsync)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the inner zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // zip -fz -0 nested_zip64.zip zip64.zip\n    JSZipTestUtils.testZipFile(\"nested zip 64\", \"ref/nested_zip64.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"zip64.zip\").async(\"binarystring\");\n            })\n            .then(JSZip.loadAsync)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the inner zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // nested zip 64 with data descriptors\n    // zip -fz -fd -0 nested_data_descriptor_zip64.zip data_descriptor_zip64.zip\n    // this generate a corrupted zip file :(\n    // TODO : find how to get the two features\n\n    // zip -X -0 utf8_in_name.zip €15.txt\n    JSZipTestUtils.testZipFile(\"Zip text file with UTF-8 characters in filename\", \"ref/utf8_in_name.zip\", function(assert, file) {\n        var done = assert.async(2);\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                assert.ok(zip.file(\"€15.txt\") !== null, \"the utf8 file is here.\");\n                return zip.file(\"€15.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"€15\\n\", \"the utf8 content was correctly read (with file().async).\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                return zip.files[\"€15.txt\"].async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"€15\\n\", \"the utf8 content was correctly read (with files[].async).\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // Created with winrar\n    // winrar will replace the euro symbol with a '_' but set the correct unicode path in an extra field.\n    JSZipTestUtils.testZipFile(\"Zip text file with UTF-8 characters in filename and windows compatibility\", \"ref/winrar_utf8_in_name.zip\", function(assert, file) {\n        var done = assert.async(2);\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                assert.ok(zip.file(\"€15.txt\") !== null, \"the utf8 file is here.\");\n                return zip.file(\"€15.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"€15\\n\", \"the utf8 content was correctly read (with file().async).\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                return zip.files[\"€15.txt\"].async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"€15\\n\", \"the utf8 content was correctly read (with files[].async).\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // zip backslash.zip -0 -X Hel\\\\lo.txt\n    JSZipTestUtils.testZipFile(\"Zip text file with backslash in filename\", \"ref/backslash.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                return zip.file(\"Hel\\\\lo.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the utf8 content was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // use izarc to generate a zip file on windows\n    JSZipTestUtils.testZipFile(\"Zip text file from windows with \\\\ in central dir\", \"ref/slashes_and_izarc.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip){\n                return zip.folder(\"test\").file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, \"Hello world\\r\\n\", \"the content was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // cat Hello.txt all.zip > all_prepended_bytes.zip\n    JSZipTestUtils.testZipFile(\"zip file with prepended bytes\", \"ref/all_prepended_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success(zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // cat all.zip Hello.txt > all_appended_bytes.zip\n    JSZipTestUtils.testZipFile(\"zip file with appended bytes\", \"ref/all_appended_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success(zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // cat Hello.txt zip64.zip > zip64_prepended_bytes.zip\n    JSZipTestUtils.testZipFile(\"zip64 file with extra bytes\", \"ref/zip64_prepended_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success(zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    // cat zip64.zip Hello.txt > zip64_appended_bytes.zip\n    JSZipTestUtils.testZipFile(\"zip64 file with extra bytes\", \"ref/zip64_appended_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success(zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content) {\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n\n    JSZipTestUtils.testZipFile(\"load(promise) works\", \"ref/all.zip\", function(assert, fileAsString) {\n        var done = assert.async();\n        JSZip.loadAsync(JSZip.external.Promise.resolve(fileAsString))\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            }).then(function (content){\n                assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    });\n\n    if (JSZip.support.blob) {\n        JSZipTestUtils.testZipFile(\"load(blob) works\", \"ref/all.zip\", function(assert, fileAsString) {\n            var u8 = new Uint8Array(fileAsString.length);\n            for( var i = 0; i < fileAsString.length; ++i ) {\n                u8[i] = fileAsString.charCodeAt(i);\n            }\n            var file = null;\n            try {\n                // don't use an Uint8Array, see the comment on utils.newBlob\n                file = new Blob([u8.buffer], {type:\"application/zip\"});\n            } catch (e) {\n                var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;\n                var builder = new Builder();\n                builder.append(u8.buffer);\n                file = builder.getBlob(\"application/zip\");\n            }\n\n            var done = assert.async();\n            JSZip.loadAsync(file)\n                .then(function (zip) {\n                    return zip.file(\"Hello.txt\").async(\"string\");\n                }).then(function (content){\n                    assert.equal(content, \"Hello World\\n\", \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n    }\n\n    JSZipTestUtils.testZipFile(\"valid crc32\", \"ref/all.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file, {checkCRC32:true})\n            .then(function success() {\n                assert.ok(true, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(false, \"An exception were thrown: \" + e.message);\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"loading in a sub folder\", \"ref/all.zip\", function(assert, file) {\n        var done = assert.async();\n        var zip = new JSZip();\n        zip.folder(\"sub\").loadAsync(file)\n            .then(function success(zip) {\n                assert.ok(zip.file(\"Hello.txt\"), \"the zip was correctly read.\");\n                assert.equal(zip.file(\"Hello.txt\").name, \"sub/Hello.txt\", \"the zip was read in a sub folder\");\n                assert.equal(zip.root, \"sub/\", \"the promise contains the correct folder level\");\n                done();\n            }, function failure(e) {\n                assert.ok(false, \"An exception were thrown: \" + e.message);\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"loading overwrite files\", \"ref/all.zip\", function(assert, file) {\n        var done = assert.async();\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"bonjour à tous\");\n        zip.file(\"Bye.txt\", \"au revoir\");\n        zip.loadAsync(file)\n            .then(function success(zip) {\n                return JSZip.external.Promise.all([\n                    zip.file(\"Hello.txt\").async(\"text\"),\n                    zip.file(\"Bye.txt\").async(\"text\")\n                ]);\n            }).then(function (result) {\n                var hello = result[0];\n                var bye = result[1];\n                assert.equal(hello, \"Hello World\\n\", \"conflicting content was overwritten.\");\n                assert.equal(bye, \"au revoir\", \"other content was kept.\");\n                done();\n            }, function failure(e) {\n                assert.ok(false, \"An exception were thrown: \" + e.message);\n                done();\n            });\n    });\n\n    QUnit.module(\"not supported features\");\n\n    // zip -0 -X -e encrypted.zip Hello.txt\n    JSZipTestUtils.testZipFile(\"basic encryption\", \"ref/encrypted.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success() {\n                assert.ok(false, \"Encryption is not supported, but no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.equal(e.message, \"Encrypted zip are not supported\", \"the error message is useful\");\n                done();\n            });\n    });\n\n    QUnit.module(\"corrupted zip\");\n\n    JSZipTestUtils.testZipFile(\"bad compression method\", \"ref/invalid/compression.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    // dd if=all.zip of=all_missing_bytes.zip bs=32 skip=1\n    JSZipTestUtils.testZipFile(\"zip file with missing bytes\", \"ref/all_missing_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    // dd if=zip64.zip of=zip64_missing_bytes.zip bs=32 skip=1\n    JSZipTestUtils.testZipFile(\"zip64 file with missing bytes\", \"ref/zip64_missing_bytes.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"zip file with extra field is Non-standard\", \"ref/extra_filed_non_standard.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function success() {\n                assert.ok(true, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(false, \"An exception were thrown: \" + e.message);\n                done();\n            });\n    });\n\n    QUnit.test(\"not a zip file\", function(assert) {\n        var done = assert.async();\n        JSZip.loadAsync(\"this is not a zip file\")\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"stuk.github.io/jszip/documentation\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    QUnit.test(\"truncated zip file\", function(assert) {\n        var done = assert.async();\n        JSZip.loadAsync(\"PK\\x03\\x04\\x0A\\x00\\x00\\x00<cut>\")\n            .then(function success() {\n                done();\n                assert.ok(false, \"no exception were thrown\");\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"invalid crc32 but no check\", \"ref/invalid/crc32.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file, {checkCRC32:false})\n            .then(function success() {\n                assert.ok(true, \"no exception were thrown\");\n                done();\n            }, function failure() {\n                assert.ok(false, \"An exception were thrown but the check should have been disabled.\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"invalid crc32\", \"ref/invalid/crc32.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file, {checkCRC32:true})\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"bad offset\", \"ref/invalid/bad_offset.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file, {checkCRC32:false})\n            .then(function success() {\n                assert.ok(false, \"no exception were thrown\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"Corrupted zip\"), \"the error message is useful\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"bad decompressed size, read a file\", \"ref/invalid/bad_decompressed_size.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n                return zip.file(\"Hello.txt\").async(\"string\");\n            })\n            .then(function success() {\n                assert.ok(false, \"successful result in an error test\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"size mismatch\"), \"async call : the error message is useful\");\n                done();\n            });\n    });\n\n    JSZipTestUtils.testZipFile(\"bad decompressed size, generate a zip\", \"ref/invalid/bad_decompressed_size.zip\", function(assert, file) {\n        var done = assert.async();\n        JSZip.loadAsync(file)\n            .then(function (zip) {\n\n                // add other files to be sure to trigger the right code path\n                zip.file(\"zz\", \"zz\");\n\n                return zip.generateAsync({\n                    type:\"string\",\n                    compression:\"DEFLATE\" // a different compression to force a read\n                });\n            })\n            .then(function success() {\n                assert.ok(false, \"successful result in an error test\");\n                done();\n            }, function failure(e) {\n                assert.ok(e.message.match(\"size mismatch\"), \"async call : the error message is useful\");\n                done();\n            });\n    });\n\n    QUnit.module(\"complex files\");\n\n    if (typeof window === \"undefined\" || QUnit.urlParams.complexfiles) {\n\n        // http://www.feedbooks.com/book/8/the-metamorphosis\n        JSZipTestUtils.testZipFile(\"Franz Kafka - The Metamorphosis.epub\", \"ref/complex_files/Franz Kafka - The Metamorphosis.epub\", function(assert, file) {\n            var done = assert.async(2);\n            JSZip.loadAsync(file)\n                .then(function(zip) {\n                    assert.equal(zip.filter(function(){return true;}).length, 26, \"the zip contains the good number of elements.\");\n                    return zip.file(\"mimetype\").async(\"string\");\n                })\n                .then(function (content) {\n                    assert.equal(content, \"application/epub+zip\\r\\n\", \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n\n            JSZip.loadAsync(file)\n                .then(function(zip) {\n                    return zip.file(\"OPS/main0.xml\").async(\"string\");\n                })\n                .then(function (content) {\n                // the .ncx file tells us that the first chapter is in the main0.xml file.\n                    assert.ok(content.indexOf(\"One morning, as Gregor Samsa was waking up from anxious dreams\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // a showcase in http://msdn.microsoft.com/en-us/windows/hardware/gg463429\n        JSZipTestUtils.testZipFile(\"Outlook2007_Calendar.xps, createFolders: false\", \"ref/complex_files/Outlook2007_Calendar.xps\", function(assert, file) {\n\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: false})\n                .then(function(zip) {\n                // the zip file contains 15 entries.\n                    assert.equal(zip.filter(function(){return true;}).length, 15, \"the zip contains the good number of elements.\");\n                    return zip.file(\"[Content_Types].xml\").async(\"string\");\n                })\n                .then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.ms-package.xps-fixeddocument+xml\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // Same test as above, but with createFolders option set to true\n        JSZipTestUtils.testZipFile(\"Outlook2007_Calendar.xps, createFolders: true\", \"ref/complex_files/Outlook2007_Calendar.xps\", function(assert, file) {\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: true})\n                .then(function(zip) {\n                // the zip file contains 15 entries, but we get 23 when creating all the sub-folders.\n                    assert.equal(zip.filter(function(){return true;}).length, 23, \"the zip contains the good number of elements.\");\n                    return zip.file(\"[Content_Types].xml\").async(\"string\");\n                })\n                .then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.ms-package.xps-fixeddocument+xml\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // an example file in http://cheeso.members.winisp.net/srcview.aspx?dir=js-unzip\n        // the data come from http://www.antarctica.ac.uk/met/READER/upper_air/\n        JSZipTestUtils.testZipFile(\"AntarcticaTemps.xlsx, createFolders: false\", \"ref/complex_files/AntarcticaTemps.xlsx\", function(assert, file) {\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: false})\n                .then(function(zip) {\n                // the zip file contains 17 entries.\n                    assert.equal(zip.filter(function(){return true;}).length, 17, \"the zip contains the good number of elements.\");\n                    return zip.file(\"[Content_Types].xml\").async(\"string\");\n                }).then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // Same test as above, but with createFolders option set to true\n        JSZipTestUtils.testZipFile(\"AntarcticaTemps.xlsx, createFolders: true\", \"ref/complex_files/AntarcticaTemps.xlsx\", function(assert, file) {\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: true})\n                .then(function(zip) {\n                // the zip file contains 16 entries, but we get 27 when creating all the sub-folders.\n                    assert.equal(zip.filter(function(){return true;}).length, 27, \"the zip contains the good number of elements.\");\n                    return zip.file(\"[Content_Types].xml\").async(\"string\");\n                }).then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // same as two up, but in the Open Document format\n        JSZipTestUtils.testZipFile(\"AntarcticaTemps.ods, createFolders: false\", \"ref/complex_files/AntarcticaTemps.ods\", function (assert, file) {\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: false})\n                .then(function(zip) {\n                // the zip file contains 20 entries.\n                    assert.equal(zip.filter(function () {return true;}).length, 20, \"the zip contains the good number of elements.\");\n                    return zip.file(\"META-INF/manifest.xml\").async(\"string\");\n                })\n                .then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.oasis.opendocument.spreadsheet\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        // same as above, but in the Open Document format\n        JSZipTestUtils.testZipFile(\"AntarcticaTemps.ods, createFolders: true\", \"ref/complex_files/AntarcticaTemps.ods\", function (assert, file) {\n            var done = assert.async();\n            JSZip.loadAsync(file, {createFolders: true})\n                .then(function(zip) {\n                // the zip file contains 19 entries, but we get 27 when creating all the sub-folders.\n                    assert.equal(zip.filter(function () {return true;}).length, 27, \"the zip contains the good number of elements.\");\n                    return zip.file(\"META-INF/manifest.xml\").async(\"string\");\n                })\n                .then(function (content) {\n                    assert.ok(content.indexOf(\"application/vnd.oasis.opendocument.spreadsheet\") !== -1, \"the zip was correctly read.\");\n                    done();\n                })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n    }\n});\n"
  },
  {
    "path": "test/asserts/permissions.js",
    "content": "\"use strict\";\n\nQUnit.module(\"permissions\", function () {\n\n\n    // touch file_{666,640,400,755}\n    // mkdir dir_{777,755,500}\n    // for mode in 777 755 500 666 640 400; do\n    //    chmod $mode *_$mode\n    // done\n    // then :\n    // zip -r linux_zip.zip .\n    // 7z a -r linux_7z.zip .\n    // ...\n    function assertUnixPermissions(assert, file){\n        function doAsserts(zip, fileName, dir, octal) {\n            var mode = parseInt(octal, 8);\n            assert.equal(zip.files[fileName].dosPermissions, null, fileName + \", no DOS permissions\");\n            assert.equal(zip.files[fileName].dir, dir, fileName + \" dir flag\");\n            assert.equal(zip.files[fileName].unixPermissions, mode, fileName + \" mode \" + octal);\n        }\n\n        var done = assert.async();\n        JSZip.loadAsync(file, {createFolders:false})\n            .then(function(zip) {\n                doAsserts(zip, \"dir_777/\", true,  \"40777\");\n                doAsserts(zip, \"dir_755/\", true,  \"40755\");\n                doAsserts(zip, \"dir_500/\", true,  \"40500\");\n                doAsserts(zip, \"file_666\", false, \"100666\");\n                doAsserts(zip, \"file_640\", false, \"100640\");\n                doAsserts(zip, \"file_400\", false, \"100400\");\n                doAsserts(zip, \"file_755\", false, \"100755\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    }\n\n    function assertDosPermissions(assert, file){\n        function doAsserts(zip, fileName, dir, binary) {\n            var mode = parseInt(binary, 2);\n            assert.equal(zip.files[fileName].unixPermissions, null, fileName + \", no UNIX permissions\");\n            assert.equal(zip.files[fileName].dir, dir, fileName + \" dir flag\");\n            assert.equal(zip.files[fileName].dosPermissions, mode, fileName + \" mode \" + mode);\n        }\n\n        var done = assert.async();\n        JSZip.loadAsync(file, {createFolders:false})\n            .then(function(zip) {\n                if (zip.files[\"dir/\"]) {\n                    doAsserts(zip, \"dir/\",           true,  \"010000\");\n                }\n                if (zip.files[\"dir_hidden/\"]) {\n                    doAsserts(zip, \"dir_hidden/\",    true,  \"010010\");\n                }\n                doAsserts(zip, \"file\",           false, \"100000\");\n                doAsserts(zip, \"file_ro\",        false, \"100001\");\n                doAsserts(zip, \"file_hidden\",    false, \"100010\");\n                doAsserts(zip, \"file_ro_hidden\", false, \"100011\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    }\n\n    function reloadAndAssertUnixPermissions(assert, file){\n        var done = assert.async();\n        JSZip.loadAsync(file, {createFolders:false})\n            .then(function (zip) {\n                return zip.generateAsync({type:\"string\", platform:\"UNIX\"});\n            })\n            .then(function (content) {\n                assertUnixPermissions(assert, content);\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    }\n    function reloadAndAssertDosPermissions(assert, file){\n        var done = assert.async();\n        JSZip.loadAsync(file, {createFolders:false})\n            .then(function (zip) {\n                return zip.generateAsync({type:\"string\", platform:\"DOS\"});\n            })\n            .then(function (content) {\n                assertDosPermissions(assert, content);\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n    }\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by zip\", \"ref/permissions/linux_zip.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by zip, reloaded\", \"ref/permissions/linux_zip.zip\", reloadAndAssertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by 7z\", \"ref/permissions/linux_7z.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by 7z, reloaded\", \"ref/permissions/linux_7z.zip\", reloadAndAssertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by file-roller on ubuntu\", \"ref/permissions/linux_file_roller-ubuntu.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by file-roller on ubuntu, reloaded\", \"ref/permissions/linux_file_roller-ubuntu.zip\", reloadAndAssertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by file-roller on xubuntu\", \"ref/permissions/linux_file_roller-xubuntu.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by file-roller on xubuntu, reloaded\", \"ref/permissions/linux_file_roller-xubuntu.zip\", reloadAndAssertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by ark\", \"ref/permissions/linux_ark.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on linux : file created by ark, reloaded\", \"ref/permissions/linux_ark.zip\", reloadAndAssertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on mac : file created by finder\", \"ref/permissions/mac_finder.zip\", assertUnixPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on mac : file created by finder, reloaded\", \"ref/permissions/mac_finder.zip\", reloadAndAssertUnixPermissions);\n\n\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by the compressed folders feature\", \"ref/permissions/windows_compressed_folders.zip\", assertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by the compressed folders feature, reloaded\", \"ref/permissions/windows_compressed_folders.zip\", reloadAndAssertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by 7z\", \"ref/permissions/windows_7z.zip\", assertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by 7z, reloaded\", \"ref/permissions/windows_7z.zip\", reloadAndAssertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by izarc\", \"ref/permissions/windows_izarc.zip\", assertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by izarc, reloaded\", \"ref/permissions/windows_izarc.zip\", reloadAndAssertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by winrar\", \"ref/permissions/windows_winrar.zip\", assertDosPermissions);\n    JSZipTestUtils.testZipFile(\"permissions on windows : file created by winrar, reloaded\", \"ref/permissions/windows_winrar.zip\", reloadAndAssertDosPermissions);\n\n});\n"
  },
  {
    "path": "test/asserts/stream.js",
    "content": "\"use strict\";\n\nQUnit.module(\"stream\", function () {\n\n    QUnit.module(\"internal\");\n\n    QUnit.test(\"A stream is pausable\", function (assert) {\n        // let's get a stream that generates a lot of chunks (~40)\n        var zip = new JSZip();\n        var txt = \"a text\";\n        for(var i = 0; i < 10; i++) {\n            zip.file(i + \".txt\", txt);\n        }\n\n        var allowChunks = true;\n        var chunkCount = 0;\n        var done = assert.async();\n\n        var helper = zip.generateInternalStream({streamFiles:true, type:\"binarystring\"});\n        helper\n            .on(\"data\", function () {\n                chunkCount++;\n                assert.equal(allowChunks, true, \"be sure to get chunks only when allowed\");\n\n                /*\n             * We stop at ~ half of chunks.\n             * A setTimeout aside this stream is not reliable and can be\n             * triggered *after* the completion of the stream.\n             */\n                if (chunkCount === 20) {\n\n                    allowChunks = false;\n                    helper.pause();\n                    setTimeout(function () {\n                        allowChunks = true;\n                        helper.resume();\n                    }, 50);\n                }\n            })\n            .on(\"error\", function (e) {\n                done();\n                assert.ok(false, e.message);\n            })\n            .on(\"end\", function () {\n                done();\n            });\n        helper.resume();\n    });\n\n    QUnit.module(\"nodejs\");\n    if (JSZip.support.nodestream) {\n        var fs = require(\"fs\");\n    }\n\n    function generateStreamTest(name, ref, createFunction, generateOptions) {\n        JSZipTestUtils.testZipFile(name,ref, function(assert, expected) {\n            var done = assert.async();\n\n            var tempFile = require(\"tmp\").tmpNameSync({postfix:\".zip\"});\n\n            var zip = createFunction();\n\n            zip.generateNodeStream(generateOptions)\n                .pipe(fs.createWriteStream(tempFile))\n                .on(\"close\", function () {\n                    fs.readFile(tempFile, function (e, data) {\n                        var actual = JSZipTestUtils.toString(data);\n                        assert.ok(JSZipTestUtils.similar(actual, expected, 3 * JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"generated ZIP matches reference ZIP\");\n                        fs.unlink(tempFile, function (err) {\n                            if (err) {\n                                assert.ok(false, err);\n                            }\n                            done();\n                        });\n                    });\n                })\n                .on(\"error\", function (e) {\n                    assert.ok(false, e.message);\n                    fs.unlink(tempFile, function (err) {\n                        if (err) {\n                            assert.ok(false, err);\n                        }\n                        done();\n                    });\n                });\n        });\n    }\n    function zipObjectStreamTest(name, createFunction) {\n        QUnit.test(name, function(assert) {\n            var tempFile = require(\"tmp\").tmpNameSync({postfix:\".txt\"});\n            var done = assert.async();\n            createFunction().pipe(fs.createWriteStream(tempFile))\n                .on(\"close\", function () {\n                    fs.readFile(tempFile, function (e, data) {\n                        var actual = JSZipTestUtils.toString(data);\n                        assert.equal(actual, \"Hello World\\n\", \"the generated content is ok\");\n                        fs.unlink(tempFile, function (err) {\n                            if (err) {\n                                assert.ok(false, err);\n                            }\n                            done();\n                        });\n                    });\n                })\n                .on(\"error\", function (e) {\n                    assert.ok(false, e.message);\n                    fs.unlink(tempFile, function (err) {\n                        if (err) {\n                            assert.ok(false, err);\n                        }\n                        done();\n                    });\n                });\n        });\n    }\n\n    if (JSZip.support.nodestream) {\n\n        generateStreamTest(\n            \"generateNodeStream(type:nodebuffer / !streamFiles) generates a working stream\", \"ref/all.zip\",\n            JSZipTestUtils.createZipAll,\n            {type:\"nodebuffer\",streamFiles:false}\n        );\n        generateStreamTest(\n            \"generateNodeStream(type:<default> / !streamFiles) generates a working stream\", \"ref/all.zip\",\n            JSZipTestUtils.createZipAll,\n            {streamFiles:false}\n        );\n        generateStreamTest(\n            \"generateNodeStream(<no options>) generates a working stream\", \"ref/all.zip\",\n            JSZipTestUtils.createZipAll\n        );\n        generateStreamTest(\n            \"generateNodeStream(type:nodebuffer / streamFiles) generates a working stream\", \"ref/all-stream.zip\",\n            JSZipTestUtils.createZipAll,\n            {type:\"nodebuffer\",streamFiles:true}\n        );\n        generateStreamTest(\n            \"generateNodeStream(type:<default> / streamFiles) generates a working stream\", \"ref/all-stream.zip\",\n            JSZipTestUtils.createZipAll,\n            {streamFiles:true}\n        );\n\n        generateStreamTest(\n            \"generateNodeStream(type:nodebuffer / !streamFiles) generates a working stream from other streams\", \"ref/all.zip\",\n            function () {\n                var helloStream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n                var imgStream = JSZipTestUtils.createZipAll().file(\"images/smile.gif\").nodeStream();\n                var zip = new JSZip();\n                zip.file(\"Hello.txt\", helloStream);\n                zip.folder(\"images\").file(\"smile.gif\", imgStream);\n\n                return zip;\n            },\n            {type:\"nodebuffer\",streamFiles:false}\n        );\n        generateStreamTest(\n            \"generateNodeStream(type:nodebuffer / streamFiles) generates a working stream from other streams\", \"ref/all-stream.zip\",\n            function () {\n                var helloStream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n                var imgStream = JSZipTestUtils.createZipAll().file(\"images/smile.gif\").nodeStream();\n                var zip = new JSZip();\n                zip.file(\"Hello.txt\", helloStream);\n                zip.folder(\"images\").file(\"smile.gif\", imgStream);\n\n                return zip;\n            },\n            {type:\"nodebuffer\",streamFiles:true}\n        );\n\n\n        zipObjectStreamTest(\"ZipObject#nodeStream generates a working stream[nodebuffer]\", function() {\n            var zip = JSZipTestUtils.createZipAll();\n            return zip.file(\"Hello.txt\").nodeStream(\"nodebuffer\");\n        });\n        zipObjectStreamTest(\"ZipObject#nodeStream generates a working stream[default]\", function() {\n            var zip = JSZipTestUtils.createZipAll();\n            return zip.file(\"Hello.txt\").nodeStream();\n        });\n\n        QUnit.test(\"a ZipObject containing a stream can be read with async\", function(assert) {\n            var done = assert.async();\n            var stream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n            var zip = new JSZip();\n            zip.file(\"Hello.txt\", stream);\n            zip.file(\"Hello.txt\").async(\"text\").then(function(actual) {\n                assert.equal(actual, \"Hello World\\n\", \"the stream has been read correctly\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n        });\n\n        QUnit.test(\"a ZipObject containing a stream can't be read with async 2 times\", function(assert) {\n            var done = assert.async();\n\n            var stream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n            var zip = new JSZip();\n            zip.file(\"Hello.txt\", stream);\n\n            // first time, consume the node stream\n            zip.file(\"Hello.txt\").async(\"text\");\n            // second time, it shouldn't work\n            zip.file(\"Hello.txt\").async(\"text\")\n                .then(function () {\n                    assert.ok(false, \"calling 2 times a stream should generate an error\");\n                    done();\n                }, function ko(e) {\n                    assert.ok(e.message.match(\"has already been used\"), \"the error message is useful\");\n                    done();\n                });\n        });\n\n        QUnit.test(\"a ZipObject containing a stream can't be read with nodeStream 2 times\", function(assert) {\n            var done = assert.async();\n\n            var stream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n            var zip = new JSZip();\n            zip.file(\"Hello.txt\", stream);\n\n            // first time, consume the node stream\n            zip.file(\"Hello.txt\").nodeStream().resume();\n            // second time, it shouldn't work\n            zip.file(\"Hello.txt\").nodeStream()\n                .on(\"error\", function (e) {\n                    assert.ok(e.message.match(\"has already been used\"), \"the error message is useful\");\n                    done();\n                })\n                .on (\"end\", function () {\n                    assert.ok(false, \"calling 2 times a stream should generate an error\");\n                    done();\n                })\n                .resume();\n        });\n\n        QUnit.test(\"generateAsync with a stream can't be read 2 times\", function(assert) {\n            var done = assert.async();\n\n            var stream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n            var zip = new JSZip();\n            zip.file(\"Hello.txt\", stream);\n\n            // first time, consume the node stream\n            zip.generateAsync({type:\"string\"});\n            // second time, it shouldn't work\n            zip.generateAsync({type:\"string\"})\n                .then(function () {\n                    assert.ok(false, \"calling 2 times a stream should generate an error\");\n                    done();\n                }, function ko(e) {\n                    assert.ok(e.message.match(\"has already been used\"), \"the error message is useful\");\n                    done();\n                });\n        });\n\n        QUnit.test(\"generateNodeStream with a stream can't be read 2 times\", function(assert) {\n            var done = assert.async();\n\n            var stream = JSZipTestUtils.createZipAll().file(\"Hello.txt\").nodeStream();\n            var zip = new JSZip();\n            zip.file(\"Hello.txt\", stream);\n\n            // first time, consume the node stream\n            zip.generateNodeStream().resume();\n            // second time, it shouldn't work\n            zip.generateNodeStream()\n                .on(\"error\", function (e) {\n                    assert.ok(e.message.match(\"has already been used\"), \"the error message is useful\");\n                    done();\n                })\n                .on (\"end\", function () {\n                    assert.ok(false, \"calling 2 times a stream should generate an error\");\n                    done();\n                })\n                .resume();\n        });\n\n        QUnit.test(\"loadAsync ends with an error when called with a stream\", function(assert) {\n            var done = assert.async();\n            var stream = JSZipTestUtils.createZipAll().generateNodeStream({\"type\":\"nodebuffer\"});\n            JSZip.loadAsync(stream).then(function () {\n                assert.ok(false, \"loading a zip file from a stream is impossible\");\n                done();\n            }, function (e) {\n                assert.ok(e.message.match(\"can't accept a stream when loading\"), \"the error message is useful\");\n                done();\n            });\n\n        });\n\n    } else {\n        QUnit.test(\"generateNodeStream generates an error\", function(assert) {\n            try {\n                var zip = new JSZip();\n                zip.generateNodeStream({type:\"nodebuffer\",streamFiles:true});\n                assert.ok(false, \"generateNodeStream should generate an error\");\n            } catch(err) {\n                assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n            }\n        });\n\n        QUnit.test(\"ZipObject#nodeStream generates an error\", function(assert) {\n            try {\n                var zip = JSZipTestUtils.createZipAll();\n                zip.file(\"Hello.txt\").nodeStream(\"nodebuffer\");\n                assert.ok(false, \"nodeStream should generate an error\");\n            } catch(err) {\n                assert.ok(err.message.match(\"not supported by this platform\"), \"the error message is useful\");\n            }\n        });\n    }\n});\n"
  },
  {
    "path": "test/asserts/unicode.js",
    "content": "\"use strict\";\n\nQUnit.module(\"unicode\");\n\n// zip -X -0 utf8.zip amount.txt\nJSZipTestUtils.testZipFile(\"Zip text file with UTF-8 characters\", \"ref/utf8.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    zip.file(\"amount.txt\", \"€15\\n\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function (actual) {\n        assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        JSZipTestUtils.checkGenerateStability(assert, actual);\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nQUnit.test(\"Text file with long unicode string\", function(assert) {\n    var expected = \"€\";\n    for(var i = 0; i < 13; i++) {\n        expected = expected + expected;\n    }\n    var zip = new JSZip();\n    zip.file(\"amount.txt\", expected);\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"})\n        .then(JSZip.loadAsync)\n        .then(function (zip) {\n            var file = zip.file(\"amount.txt\");\n            return file.async(\"string\");\n        }).then(function (fileContent){\n            assert.equal(fileContent, expected, \"Generated ZIP can be parsed\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\n// zip -X -0 utf8_in_name.zip €15.txt\nJSZipTestUtils.testZipFile(\"Zip text file with UTF-8 characters in filename\", \"ref/utf8_in_name.zip\", function(assert) {\n    var zip = new JSZip();\n    zip.file(\"€15.txt\", \"€15\\n\");\n    var done = assert.async();\n    zip.generateAsync({type:\"binarystring\"}).then(function (actual) {\n        // zip doesn't generate a strange file like us (utf8 flag AND unicode path extra field)\n        // if one of the files has more data than the other, the bytes are no more aligned and the\n        // error count goes through the roof. The parsing is checked on a other test so I'll\n        // comment this one for now.\n        // assert.ok(JSZipTestUtils.similar(actual, expected, JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY) , \"Generated ZIP matches reference ZIP\");\n        JSZipTestUtils.checkGenerateStability(assert, actual);\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Zip text file with non unicode characters in filename: loadAsync without decodeFileName\", \"ref/local_encoding_in_name.zip\", function(assert, content) {\n\n    var done = assert.async();\n    JSZip.loadAsync(content).then(function (zipUnicode) {\n        assert.ok(!zipUnicode.files[\"Новая папка/\"], \"default : the folder is not found\");\n        assert.ok(!zipUnicode.files[\"Новая папка/Новый текстовый документ.txt\"], \"default : the file is not found\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n\n});\n\nJSZipTestUtils.testZipFile(\"Zip text file with non unicode characters in filename: loadAsync with decodeFileName\", \"ref/local_encoding_in_name.zip\", function(assert, content) {\n    var conversions = {\n        \"bytes 8d ae a2 a0 ef 20 af a0 af aa a0 2f\" : \"Новая папка/\",\n        \"bytes 8d ae a2 a0 ef 20 af a0 af aa a0 2f 8d ae a2 eb a9 20 e2 a5 aa e1 e2 ae a2 eb a9 20 a4 ae aa e3 ac a5 ad e2 2e 74 78 74\" : \"Новая папка/Новый текстовый документ.txt\"\n    };\n\n    var done = assert.async();\n    JSZip.loadAsync(content, {\n        decodeFileName: function (bytes) {\n            // here, a real iconv implementation\n            var key = \"bytes\";\n            for(var i = 0; i < bytes.length; i++) {\n                key += \" \" + bytes[i].toString(16);\n            }\n\n            return conversions[key] || \"\";\n        }\n    }).then(function (zipCP866) {\n        assert.ok(zipCP866.files[\"Новая папка/\"], \"with decodeFileName : the folder has been correctly read\");\n        assert.ok(zipCP866.files[\"Новая папка/Новый текстовый документ.txt\"], \"with decodeFileName : the file has been correctly read\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\nJSZipTestUtils.testZipFile(\"Zip text file with non unicode characters in filename: generateAsync with encodeassert, fileName\", \"ref/local_encoding_in_name.zip\", function(assert, content) {\n    var conversions = {\n        \"\": [],\n        \"Новая папка/\": [0x8d, 0xae, 0xa2, 0xa0, 0xef, 0x20, 0xaf, 0xa0, 0xaf, 0xaa, 0xa0, 0x2f],\n        \"Новая папка/Новый текстовый документ.txt\": [0x8d, 0xae, 0xa2, 0xa0, 0xef, 0x20, 0xaf, 0xa0, 0xaf, 0xaa, 0xa0, 0x2f, 0x8d, 0xae, 0xa2, 0xeb, 0xa9, 0x20, 0xe2, 0xa5, 0xaa, 0xe1, 0xe2, 0xae, 0xa2, 0xeb, 0xa9, 0x20, 0xa4, 0xae, 0xaa, 0xe3, 0xac, 0xa5, 0xad, 0xe2, 0x2e, 0x74, 0x78, 0x74]\n    };\n\n    function decodeCP866(bytes) {\n        for(var text in conversions) {\n            if (conversions[text].length === bytes.length) {\n                return text;\n            }\n        }\n    }\n\n    function encodeCP866(string) {\n        return conversions[string];\n    }\n\n    var done = assert.async();\n    JSZip.loadAsync(content, {\n        decodeFileName: decodeCP866\n    }).then(function (zipCP866) {\n        return zipCP866.generateAsync({\n            type: \"string\",\n            encodeFileName: encodeCP866\n        });\n    }).then(function (regeneratedContent) {\n        return JSZip.loadAsync(regeneratedContent, {\n            decodeFileName: decodeCP866\n        });\n    }).then(function (zipCP866) {\n        // the example zip doesn't contain the unicode path extra field, we can't\n        // compare them.\n        assert.ok(zipCP866.files[\"Новая папка/\"], \"with decodeFileName : the folder has been correctly read\");\n        assert.ok(zipCP866.files[\"Новая папка/Новый текстовый документ.txt\"], \"with decodeFileName : the file has been correctly read\");\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n\n// zip --entry-comments --archive-comment -X -0 pile_of_poo.zip Iñtërnâtiônàlizætiøn☃$'\\360\\237\\222\\251'.txt\nJSZipTestUtils.testZipFile(\"Zip text file and UTF-8, Pile Of Poo test\", \"ref/pile_of_poo.zip\", function(assert, expected) {\n    var zip = new JSZip();\n    // this is the string \"Iñtërnâtiônàlizætiøn☃💩\",\n    // see http://mathiasbynens.be/notes/javascript-unicode\n    // but escaped, to avoid troubles\n    // thanks http://mothereff.in/js-escapes#1I%C3%B1t%C3%ABrn%C3%A2ti%C3%B4n%C3%A0liz%C3%A6ti%C3%B8n%E2%98%83%F0%9F%92%A9\n    var text = \"I\\xF1t\\xEBrn\\xE2ti\\xF4n\\xE0liz\\xE6ti\\xF8n\\u2603\\uD83D\\uDCA9\";\n    zip.file(text + \".txt\", text, {comment : text});\n    var done = assert.async(3);\n    zip.generateAsync({type:\"binarystring\", comment : text}).then(function(actual) {\n\n        JSZipTestUtils.checkGenerateStability(assert, actual);\n\n        JSZip.loadAsync(expected)\n            .then(function (zip) {\n                var file = zip.file(text + \".txt\");\n                assert.ok(file, \"JSZip finds the unicode file name on the external file\");\n                assert.equal(file.comment, text, \"JSZip can decode the external file comment\");\n                return file.async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, text, \"JSZip can decode the external file\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n        JSZip.loadAsync(actual)\n            .then(function (zip) {\n                var file = zip.file(text + \".txt\");\n                assert.ok(file, \"JSZip finds the unicode file name on its own file\");\n                assert.equal(file.comment, text, \"JSZip can decode its own file comment\");\n                return file.async(\"string\");\n            })\n            .then(function (content) {\n                assert.equal(content, text, \"JSZip can decode its own file\");\n                done();\n            })[\"catch\"](JSZipTestUtils.assertNoError);\n\n\n        done();\n    })[\"catch\"](JSZipTestUtils.assertNoError);\n});\n"
  },
  {
    "path": "test/asserts/utils.js",
    "content": "\"use strict\";\n\n// These tests only run in Node\nvar utils = require(\"../../lib/utils\");\n\nQUnit.module(\"utils\");\n\nQUnit.test(\"Paths are resolved correctly\", function (assert) {\n    // Backslashes can be part of filenames\n    assert.strictEqual(utils.resolve(\"root\\\\a\\\\b\"), \"root\\\\a\\\\b\");\n    assert.strictEqual(utils.resolve(\"root/a/b\"), \"root/a/b\");\n    assert.strictEqual(utils.resolve(\"root/a/..\"), \"root\");\n    assert.strictEqual(utils.resolve(\"root/a/../b\"), \"root/b\");\n    assert.strictEqual(utils.resolve(\"root/a/./b\"), \"root/a/b\");\n    assert.strictEqual(utils.resolve(\"root/../../../\"), \"\");\n    assert.strictEqual(utils.resolve(\"////\"), \"/\");\n    assert.strictEqual(utils.resolve(\"/a/b/c\"), \"/a/b/c\");\n    assert.strictEqual(utils.resolve(\"a/b/c/\"), \"a/b/c/\");\n    assert.strictEqual(utils.resolve(\"../../../../../a\"), \"a\");\n    assert.strictEqual(utils.resolve(\"../app.js\"), \"app.js\");\n});\n"
  },
  {
    "path": "test/asserts/version.js",
    "content": "\"use strict\";\n\nQUnit.module(\"version\");\n\nQUnit.test(\"JSZip.version is correct\", function(assert){\n    assert.ok(JSZip.version, \"JSZip.version exists\");\n    assert.ok(JSZip.version.match(/^\\d+\\.\\d+\\.\\d+/), \"JSZip.version looks like a correct version\");\n});\n"
  },
  {
    "path": "test/benchmark/.eslintrc.js",
    "content": "\"use strict\";\n\nmodule.exports = {\n    globals: {\n        // Added by index.html and node.js\n        Benchmark: false,\n    },\n};\n"
  },
  {
    "path": "test/benchmark/benchmark.js",
    "content": "\"use strict\";\n\n(function (root, factory) {\n    if (typeof module === \"object\" && module.exports) {\n        module.exports = factory();\n    } else {\n        root.benchmark = factory();\n    }\n}(typeof self !== \"undefined\" ? self : this, function () {\n    return function (type) {\n        return new Promise(resolve => {\n            const suite = new Benchmark.Suite();\n\n            suite\n                .add(`${type} generateAsync`, {\n                    defer: true,\n                    async fn(deferred) {\n                        const zip = new JSZip();\n\n                        for (let i = 0; i < 50; i++) {\n                            zip.file(\"file_\" + i, \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", { base64: true, date: new Date(1234123491011) });\n                        }\n\n                        await zip.generateAsync({ type });\n                        deferred.resolve();\n                    }\n                })\n                .on(\"cycle\", event => {\n                    // Output benchmark result by converting benchmark result to string\n                    console.log(String(event.target));\n                })\n                .on(\"complete\", () => {\n                    console.log(\"Benchmark complete\");\n                    resolve();\n                })\n                .run({ \"async\": true });\n        });\n    };\n}));\n"
  },
  {
    "path": "test/benchmark/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n    <title>JSZip Benchmark</title>\n</head>\n<body>\n    <script src=\"../../node_modules/benchmark/node_modules/lodash/lodash.js\"></script>\n    <script src=\"../../node_modules/benchmark/benchmark.js\"></script>\n    <script src=\"../../dist/jszip.js\"></script>\n    <script src=\"./benchmark.js\"></script>\n    <script>\n        benchmark(\"arraybuffer\");\n    </script>\n</body>\n</html>\n"
  },
  {
    "path": "test/benchmark/node.js",
    "content": "\"use strict\";\n\nglobalThis.Benchmark = require(\"benchmark\");\nglobalThis.JSZip = require(\"../../lib/index\");\n\nconst benchmark = require(\"./benchmark\");\nbenchmark(\"nodebuffer\");\n"
  },
  {
    "path": "test/helpers/browser-test-utils.js",
    "content": "\"use strict\";\nJSZipTestUtils.loadZipFile = function (name, callback) {\n    JSZipUtils.getBinaryContent(name + \"?_=\" + ( new Date() ).getTime(), callback);\n};\n"
  },
  {
    "path": "test/helpers/node-test-utils.js",
    "content": "\"use strict\";\n\nvar fs = require(\"fs\");\nvar path = require(\"path\");\n\nglobal.JSZip = require(\"../../lib/index\");\n\nglobal.JSZipTestUtils.loadZipFile = function(name, callback) {\n    fs.readFile(path.join(\"test\", name), \"binary\", callback);\n};\nprocess.on(\"uncaughtException\", function(err) {\n    console.log(\"uncaughtException: \" + err, err.stack);\n    process.exit(1);\n});\n\nprocess.on(\"unhandledRejection\", function(err) {\n    console.log(\"unhandledRejection: \" + err, err.stack);\n    process.exit(1);\n});\n"
  },
  {
    "path": "test/helpers/test-utils.js",
    "content": "\"use strict\";\n\n(function (global) {\n    // Expose assert object globally\n    global.assert = QUnit.assert;\n\n    var JSZipTestUtils = {};\n\n    JSZipTestUtils.similar = function similar(actual, expected, mistakes) {\n\n        if(JSZip.support.arraybuffer) {\n            if(actual instanceof ArrayBuffer) {\n                actual = new Uint8Array(actual);\n            }\n            if(expected instanceof ArrayBuffer) {\n                expected = new Uint8Array(expected);\n            }\n        }\n\n        var actualIsString = typeof actual === \"string\";\n        var expectedIsString = typeof expected === \"string\";\n\n        if (actual.length !== expected.length) {\n            mistakes -= Math.abs((actual.length||0) - (expected.length||0));\n        }\n\n        for (var i = 0; i < Math.min(actual.length, expected.length); i++) {\n            // actual is the generated zip, expected is what we got from the xhr.\n            var actualByte = actualIsString ? actual.charCodeAt(i) : actual[i];\n            // expected can be a string with char codes > 255, be sure to take only one byte.\n            var expectedByte = (expectedIsString ? expected.charCodeAt(i) : expected[i]) & 0xFF;\n            if (actualByte !== expectedByte) {\n                mistakes--;\n            }\n        }\n\n        if (mistakes < 0) {\n            return false;\n        } else {\n            return true;\n        }\n    };\n\n    /*\n       Expected differing bytes:\n       2  version number\n       4  date/time\n       4  central dir version numbers\n       4  central dir date/time\n       4  external file attributes\n\n       18 Total\n       */\n    JSZipTestUtils.MAX_BYTES_DIFFERENCE_PER_ZIP_ENTRY = 18;\n\n    JSZipTestUtils.checkGenerateStability = function checkGenerateStability(assert, bytesStream, options) {\n        var done = assert.async();\n\n        options = options || {type:\"binarystring\"};\n        // TODO checkcrc32\n        return new JSZip().loadAsync(bytesStream).then(function (zip) {\n            return zip.generateAsync(options);\n        }).then(function (content) {\n            assert.ok(JSZipTestUtils.similar(bytesStream, content, 0), \"generate stability : stable\");\n            done();\n        })[\"catch\"](JSZipTestUtils.assertNoError);\n    };\n\n    JSZipTestUtils.checkBasicStreamBehavior = function checkBasicStreamBehavior(assert, stream, testName) {\n        var done = assert.async();\n        if (!testName) {\n            testName = \"\";\n        }\n        var triggeredStream = false;\n        stream\n            .on(\"data\", function (data, metadata) {\n            // triggering a lot of passing checks makes the result unreadable\n                if (!data) {\n                    assert.ok(data, testName + \"basic check stream, data event handler, data is defined\");\n                }\n                if(!metadata) {\n                    assert.ok(metadata, testName + \"basic check stream, data event handler, metadata is defined\");\n                }\n                triggeredStream = true;\n            })\n            .on(\"error\", function (e) {\n                assert.ok(e, testName + \"basic check stream, error event handler, error is defined\");\n                triggeredStream = true;\n                done();\n            })\n            .on(\"end\", function () {\n                triggeredStream = true;\n                done();\n            })\n            .resume()\n        ;\n        assert.ok(!triggeredStream, testName + \"basic check stream, the stream callback is async\");\n    };\n\n    JSZipTestUtils.toString = function toString(obj) {\n        if(typeof obj === \"string\" || !obj) {\n            return obj;\n        }\n\n        if(obj instanceof ArrayBuffer) {\n            obj = new Uint8Array(obj);\n        }\n\n        var res = \"\";\n        for(var i = 0; i < obj.length; i++) {\n            res += String.fromCharCode(obj[i]);\n        }\n        return res;\n    };\n\n    // cache for files\n    var refZips = {};\n\n    JSZipTestUtils.fetchFile = function fetchFile(index, url, callback) {\n        if(refZips[url]) {\n            setTimeout(function () {\n                callback(index, null, refZips[url]);\n            }, 0);\n        } else {\n            JSZipTestUtils.loadZipFile(url, function (err, res) {\n                var file = JSZipTestUtils.toString(res);\n                refZips[url] = file;\n                callback(index, err, file);\n            });\n        }\n    };\n\n    JSZipTestUtils.assertNoError = function assertNoError(err) {\n        if (typeof console !== \"undefined\" && console.error) {\n            console.error(err.stack);\n        }\n        QUnit.assert.ok(false, \"unexpected error : \" + err + \",  \" + err.stack);\n    };\n\n    JSZipTestUtils.testZipFile = function testZipFile(testName, zipName, testFunction) {\n        var simpleForm = !(zipName instanceof Array);\n        var filesToFetch = [];\n        if(simpleForm) {\n            filesToFetch = [zipName];\n        } else {\n            filesToFetch = zipName;\n        }\n\n        QUnit.test(testName, function (assert) {\n            var done = assert.async();\n\n            var results = new Array(filesToFetch.length);\n            var count = 0;\n            var fetchError = null;\n            function handleResult(index, err, file) {\n\n                fetchError = fetchError || err;\n                results[index] = file;\n                count++;\n\n                if (count === filesToFetch.length) {\n\n                    done();\n                    if(fetchError) {\n                        assert.ok(false, fetchError);\n                        return;\n                    }\n                    if(simpleForm) {\n                        testFunction.call(null, assert, results[0]);\n                    } else {\n                        testFunction.call(null, assert, results);\n                    }\n                }\n\n            }\n            for (var i = 0; i < filesToFetch.length; i++) {\n                JSZipTestUtils.fetchFile(i, filesToFetch[i], handleResult);\n            }\n        });\n    };\n\n    JSZipTestUtils.createZipAll = function createZipAll() {\n        var zip = new JSZip();\n        zip.file(\"Hello.txt\", \"Hello World\\n\");\n        zip.folder(\"images\").file(\"smile.gif\", \"R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=\", {base64: true});\n        return zip;\n    };\n\n    var base64Dict = {\n        \"\": \"\",\n        \"\\xE2\\x82\\xAC15\\n\": \"4oKsMTUK\",\n        \"test\\r\\ntest\\r\\n\": \"dGVzdA0KdGVzdA0K\",\n        \"all.zip.base64,stream=false\": \"UEsDBAoAAAAAAO+7TTrj5ZWwDAAAAAwAAAAJAAAASGVsbG8udHh0SGVsbG8gV29ybGQKUEsDBAoAAAAAAA9qUToAAAAAAAAAAAAAAAAHAAAAaW1hZ2VzL1BLAwQKAAAAAACZoEg6PD/riikAAAApAAAAEAAAAGltYWdlcy9zbWlsZS5naWZHSUY4N2EFAAUAgAIAAAAA/94ALAAAAAAFAAUAAAIIjA+RZ6sKUgEAO1BLAQIUAAoAAAAAAO+7TTrj5ZWwDAAAAAwAAAAJAAAAAAAAAAAAAAAAAAAAAABIZWxsby50eHRQSwECFAAKAAAAAAAPalE6AAAAAAAAAAAAAAAABwAAAAAAAAAAABAAAAAzAAAAaW1hZ2VzL1BLAQIUAAoAAAAAAJmgSDo8P+uKKQAAACkAAAAQAAAAAAAAAAAAAAAAAFgAAABpbWFnZXMvc21pbGUuZ2lmUEsFBgAAAAADAAMAqgAAAK8AAAAAAA==\",\n        \"all.zip.base64,stream=true\": \"UEsDBAoACAAAAO+7TToAAAAAAAAAAAAAAAAJAAAASGVsbG8udHh0SGVsbG8gV29ybGQKUEsHCOPllbAMAAAADAAAAFBLAwQKAAAAAAAPalE6AAAAAAAAAAAAAAAABwAAAGltYWdlcy9QSwMECgAIAAAAmaBIOgAAAAAAAAAAAAAAABAAAABpbWFnZXMvc21pbGUuZ2lmR0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADtQSwcIPD/riikAAAApAAAAUEsBAhQACgAIAAAA77tNOuPllbAMAAAADAAAAAkAAAAAAAAAAAAAAAAAAAAAAEhlbGxvLnR4dFBLAQIUAAoAAAAAAA9qUToAAAAAAAAAAAAAAAAHAAAAAAAAAAAAEAAAAEMAAABpbWFnZXMvUEsBAhQACgAIAAAAmaBIOjw/64opAAAAKQAAABAAAAAAAAAAAAAAAAAAaAAAAGltYWdlcy9zbWlsZS5naWZQSwUGAAAAAAMAAwCqAAAAzwAAAAAA\"\n    };\n    JSZipTestUtils.base64encode = function(input) {\n        if (!(input in base64Dict)){\n            throw new Error(\"unknown key '\" + input + \"' in the base64 dictionary\");\n        }\n        return base64Dict[input];\n    };\n\n\n    if (global.JSZip) {\n        throw new Error(\"JSZip is already defined, we can't capture the global state *before* its load\");\n    }\n\n    JSZipTestUtils.oldPromise = global.Promise;\n\n    global.JSZipTestUtils = JSZipTestUtils;\n})(typeof window !== \"undefined\" && window || global);\n"
  },
  {
    "path": "test/index.html",
    "content": "<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n<title>JSZip Testing</title>\n<link media=\"screen\" href=\"../node_modules/qunit/qunit/qunit.css\" type=\"text/css\" rel=\"stylesheet\">\n<script type=\"text/javascript\" src=\"../node_modules/qunit/qunit/qunit.js\"></script>\n<script>\n// no CDN, fallback on the npm version\nif(!window.QUnit) {\n   document.write('<link media=\"screen\" href=\"../node_modules/qunitjs/qunit/qunit.css\" type=\"text/css\" rel=\"stylesheet\">');\n   document.write('<script type=\"text/javascript\" src=\"../node_modules/qunitjs/qunit/qunit.js\"><\\/script>');\n}\n</script>\n\n<script type=\"text/javascript\" src=\"helpers/test-utils.js\"></script>\n<script type=\"text/javascript\" src=\"helpers/browser-test-utils.js\"></script>\n\n<script type=\"text/javascript\" src=\"../dist/jszip.js\"></script>\n\n<script type=\"text/javascript\">\n   QUnit.config.urlConfig.push({\n      id : \"complexfiles\",\n      label : \"Load complex files\",\n      tooltip : \"Loading complex files can be (very) slow but useful to test real-world zip files\"\n   });\n\n   // see https://github.com/axemclion/grunt-saucelabs#test-result-details-with-qunit\n   var log = [];\n   var testName;\n\n   QUnit.done(function (test_results) {\n   var tests = [];\n   for(var i = 0, len = log.length; i < len; i++) {\n      var details = log[i];\n      tests.push({\n         name: details.name,\n         message: details.message,\n         module: details.module,\n         result: details.result,\n         expected: details.expected,\n         actual: details.actual,\n         source: details.source\n      });\n   }\n   test_results.tests = tests;\n\n   window.global_test_results = test_results;\n   });\n\n   QUnit.log(function (details) {\n       if (!details.result) {\n           log.push(details);\n       }\n   });\n</script>\n\n<script type=\"text/javascript\" src=\"//stuk.github.io/jszip-utils/dist/jszip-utils.js\"></script>\n<!--\nMandatory in IE 6, 7, 8 and 9.\n-->\n<!--[if IE]>\n<script type=\"text/javascript\" src=\"//stuk.github.io/jszip-utils/dist/jszip-utils-ie.js\"></script>\n<![endif]-->\n\n<script>\n// no CDN, fallback on the npm version\nif(!window.JSZipUtils) {\n   document.write('<script type=\"text/javascript\" src=\"../node_modules/jszip-utils/dist/jszip-utils.js\"><\\/script>');\n   document.write('<!--[if IE]><script type=\"text/javascript\" src=\"../node_modules/jszip-utils/dist/jszip-utils-ie.js\"><\\/script><![endif]-->');\n}\n</script>\n\n<script type=\"text/javascript\" src=\"asserts/constructor.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/version.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/delete.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/deprecated.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/external.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/file.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/filter.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/foreach.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/generate.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/load.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/permissions.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/stream.js\"></script>\n<script type=\"text/javascript\" src=\"asserts/unicode.js\"></script>\n\n\n\n</head>\n<body>\n   <div id=\"qunit\"></div>\n   <div id=\"qunit-fixture\"></div>\n</body>\n</html>\n"
  },
  {
    "path": "test/run.js",
    "content": "\"use strict\";\n\nconst path = require(\"path\");\nconst playwright = require(\"playwright\");\nconst createServer = require(\"http-server\").createServer;\n\n/** @typedef {{\n      name: string,\n      message: string,\n      module: string,\n      result: boolean,\n      expected: unknown,\n      actual: unknown,\n      source: string\n    }} Failure\n*/\n\n/**\n * @typedef {{ passed: number, failed: number, total: number, runtime: number, tests: Failure[] }} Results\n */\n\n/**\n * @param {string} browserType\n * @returns {Promise<[string, Results]>}\n */\nasync function runBrowser(browserType, waitFor, file) {\n    console.log(\"Starting\", browserType);\n    const browser = await playwright[browserType].launch();\n    const context = await browser.newContext();\n    const page = await context.newPage();\n\n    await page.goto(`http://127.0.0.1:8080/test/${file}`);\n    const result = await waitFor(page);\n\n    console.log(\"Closing\", browserType);\n    await browser.close();\n\n    return [browserType, result];\n}\n\nasync function runBrowsers(waitFor, file) {\n    const browsersTypes = [\"chromium\", \"firefox\", \"webkit\"];\n\n    const server = createServer({root: path.join(__dirname, \"..\")});\n    await new Promise(resolve => server.listen(8080, \"127.0.0.1\", resolve));\n    console.log(\"Server started\");\n\n    try {\n        const results = await Promise.all(browsersTypes.map(b => runBrowser(b, waitFor, file)));\n        return results;\n    } finally {\n        server.close();\n    }\n}\n\nasync function waitForTests(page) {\n    let result;\n    do {\n        result = await page.evaluate(() => {\n            return window.global_test_results;\n        });\n    } while (!result);\n    return result;\n}\n\nasync function runTests() {\n    const results = await runBrowsers(waitForTests, \"index.html?hidepassed\");\n\n    let failures = false;\n    for (const result of results) {\n        console.log(...result);\n        failures = failures || result[1].failed > 0;\n    }\n\n    if (failures) {\n        console.log(\"Tests failed\");\n        process.exit(1);\n    } else {\n        console.log(\"Tests passed!\");\n    }\n}\n\nasync function waitForBenchmark(page) {\n    return new Promise(resolve => {\n        const logs = [];\n\n        page.on(\"console\", async message => {\n            if (message.text() === \"Benchmark complete\") {\n                resolve(logs);\n            } else {\n                logs.push(message.text());\n            }\n        });\n    });\n}\n\nasync function runBenchmark() {\n    const results = await runBrowsers(waitForBenchmark, \"benchmark/index.html\");\n\n    for (const [browser, logs] of results) {\n        for (const log of logs) {\n            console.log(browser, log);\n        }\n    }\n}\n\nswitch (process.argv[2]) {\ncase \"--test\":\n    runTests();\n    break;\ncase \"--benchmark\":\n    runBenchmark();\n    break;\ndefault:\n    throw new Error(`Unknown argument: ${process.argv[2]}`);\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    /* Visit https://aka.ms/tsconfig.json to read more about this file */\n\n    /* Projects */\n    // \"incremental\": true,                              /* Enable incremental compilation */\n    // \"composite\": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */\n    // \"tsBuildInfoFile\": \"./\",                          /* Specify the folder for .tsbuildinfo incremental compilation files. */\n    // \"disableSourceOfProjectReferenceRedirect\": true,  /* Disable preferring source files instead of declaration files when referencing composite projects */\n    // \"disableSolutionSearching\": true,                 /* Opt a project out of multi-project reference checking when editing. */\n    // \"disableReferencedProjectLoad\": true,             /* Reduce the number of projects loaded automatically by TypeScript. */\n\n    /* Language and Environment */\n    \"target\": \"es2016\",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */\n    // \"lib\": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */\n    // \"jsx\": \"preserve\",                                /* Specify what JSX code is generated. */\n    // \"experimentalDecorators\": true,                   /* Enable experimental support for TC39 stage 2 draft decorators. */\n    // \"emitDecoratorMetadata\": true,                    /* Emit design-type metadata for decorated declarations in source files. */\n    // \"jsxFactory\": \"\",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */\n    // \"jsxFragmentFactory\": \"\",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */\n    // \"jsxImportSource\": \"\",                            /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */\n    // \"reactNamespace\": \"\",                             /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */\n    // \"noLib\": true,                                    /* Disable including any library files, including the default lib.d.ts. */\n    // \"useDefineForClassFields\": true,                  /* Emit ECMAScript-standard-compliant class fields. */\n\n    /* Modules */\n    \"module\": \"commonjs\",                                /* Specify what module code is generated. */\n    // \"rootDir\": \"./\",                                  /* Specify the root folder within your source files. */\n    // \"moduleResolution\": \"node\",                       /* Specify how TypeScript looks up a file from a given module specifier. */\n    // \"baseUrl\": \"./\",                                  /* Specify the base directory to resolve non-relative module names. */\n    // \"paths\": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */\n    // \"rootDirs\": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */\n    // \"typeRoots\": [],                                  /* Specify multiple folders that act like `./node_modules/@types`. */\n    // \"types\": [],                                      /* Specify type package names to be included without being referenced in a source file. */\n    // \"allowUmdGlobalAccess\": true,                     /* Allow accessing UMD globals from modules. */\n    // \"resolveJsonModule\": true,                        /* Enable importing .json files */\n    // \"noResolve\": true,                                /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */\n\n    /* JavaScript Support */\n    // \"allowJs\": true,                                  /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */\n    // \"checkJs\": true,                                  /* Enable error reporting in type-checked JavaScript files. */\n    // \"maxNodeModuleJsDepth\": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */\n\n    /* Emit */\n    // \"declaration\": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */\n    // \"declarationMap\": true,                           /* Create sourcemaps for d.ts files. */\n    // \"emitDeclarationOnly\": true,                      /* Only output d.ts files and not JavaScript files. */\n    // \"sourceMap\": true,                                /* Create source map files for emitted JavaScript files. */\n    // \"outFile\": \"./\",                                  /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */\n    // \"outDir\": \"./\",                                   /* Specify an output folder for all emitted files. */\n    // \"removeComments\": true,                           /* Disable emitting comments. */\n    \"noEmit\": true,                                   /* Disable emitting files from a compilation. */\n    // \"importHelpers\": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */\n    // \"importsNotUsedAsValues\": \"remove\",               /* Specify emit/checking behavior for imports that are only used for types */\n    // \"downlevelIteration\": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */\n    // \"sourceRoot\": \"\",                                 /* Specify the root path for debuggers to find the reference source code. */\n    // \"mapRoot\": \"\",                                    /* Specify the location where debugger should locate map files instead of generated locations. */\n    // \"inlineSourceMap\": true,                          /* Include sourcemap files inside the emitted JavaScript. */\n    // \"inlineSources\": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */\n    // \"emitBOM\": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */\n    // \"newLine\": \"crlf\",                                /* Set the newline character for emitting files. */\n    // \"stripInternal\": true,                            /* Disable emitting declarations that have `@internal` in their JSDoc comments. */\n    // \"noEmitHelpers\": true,                            /* Disable generating custom helper functions like `__extends` in compiled output. */\n    // \"noEmitOnError\": true,                            /* Disable emitting files if any type checking errors are reported. */\n    // \"preserveConstEnums\": true,                       /* Disable erasing `const enum` declarations in generated code. */\n    // \"declarationDir\": \"./\",                           /* Specify the output directory for generated declaration files. */\n    // \"preserveValueImports\": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */\n\n    /* Interop Constraints */\n    // \"isolatedModules\": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */\n    // \"allowSyntheticDefaultImports\": true,             /* Allow 'import x from y' when a module doesn't have a default export. */\n    \"esModuleInterop\": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */\n    // \"preserveSymlinks\": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */\n    \"forceConsistentCasingInFileNames\": true,            /* Ensure that casing is correct in imports. */\n\n    /* Type Checking */\n    \"strict\": true,                                      /* Enable all strict type-checking options. */\n    // \"noImplicitAny\": true,                            /* Enable error reporting for expressions and declarations with an implied `any` type.. */\n    // \"strictNullChecks\": true,                         /* When type checking, take into account `null` and `undefined`. */\n    // \"strictFunctionTypes\": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */\n    // \"strictBindCallApply\": true,                      /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */\n    // \"strictPropertyInitialization\": true,             /* Check for class properties that are declared but not set in the constructor. */\n    // \"noImplicitThis\": true,                           /* Enable error reporting when `this` is given the type `any`. */\n    // \"useUnknownInCatchVariables\": true,               /* Type catch clause variables as 'unknown' instead of 'any'. */\n    // \"alwaysStrict\": true,                             /* Ensure 'use strict' is always emitted. */\n    // \"noUnusedLocals\": true,                           /* Enable error reporting when a local variables aren't read. */\n    // \"noUnusedParameters\": true,                       /* Raise an error when a function parameter isn't read */\n    // \"exactOptionalPropertyTypes\": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */\n    // \"noImplicitReturns\": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */\n    // \"noFallthroughCasesInSwitch\": true,               /* Enable error reporting for fallthrough cases in switch statements. */\n    // \"noUncheckedIndexedAccess\": true,                 /* Include 'undefined' in index signature results */\n    // \"noImplicitOverride\": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */\n    // \"noPropertyAccessFromIndexSignature\": true,       /* Enforces using indexed accessors for keys declared using an indexed type */\n    // \"allowUnusedLabels\": true,                        /* Disable error reporting for unused labels. */\n    // \"allowUnreachableCode\": true,                     /* Disable error reporting for unreachable code. */\n\n    /* Completeness */\n    // \"skipDefaultLibCheck\": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */\n    // \"skipLibCheck\": true                                 /* Skip type checking all .d.ts files. */\n  }\n}\n"
  },
  {
    "path": "vendor/FileSaver.js",
    "content": "/*! FileSaver.js\n *  A saveAs() FileSaver implementation.\n *  2014-01-24\n *\n *  By Eli Grey, http://eligrey.com\n *  License: X11/MIT\n *    See LICENSE.md\n */\n\n/*global self */\n/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */\n\n/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/main/FileSaver.js */\n\nvar saveAs = saveAs\n  // IE 10+ (native saveAs)\n  || (typeof navigator !== \"undefined\" &&\n      navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))\n  // Everyone else\n  || (function(view) {\n\t\"use strict\";\n\t// IE <10 is explicitly unsupported\n\tif (typeof navigator !== \"undefined\" &&\n\t    /MSIE [1-9]\\./.test(navigator.userAgent)) {\n\t\treturn;\n\t}\n\tvar\n\t\t  doc = view.document\n\t\t  // only get URL when necessary in case BlobBuilder.js hasn't overridden it yet\n\t\t, get_URL = function() {\n\t\t\treturn view.URL || view.webkitURL || view;\n\t\t}\n\t\t, URL = view.URL || view.webkitURL || view\n\t\t, save_link = doc.createElementNS(\"http://www.w3.org/1999/xhtml\", \"a\")\n\t\t, can_use_save_link = !view.externalHost && \"download\" in save_link\n\t\t, click = function(node) {\n\t\t\tvar event = doc.createEvent(\"MouseEvents\");\n\t\t\tevent.initMouseEvent(\n\t\t\t\t\"click\", true, false, view, 0, 0, 0, 0, 0\n\t\t\t\t, false, false, false, false, 0, null\n\t\t\t);\n\t\t\tnode.dispatchEvent(event);\n\t\t}\n\t\t, webkit_req_fs = view.webkitRequestFileSystem\n\t\t, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem\n\t\t, throw_outside = function(ex) {\n\t\t\t(view.setImmediate || view.setTimeout)(function() {\n\t\t\t\tthrow ex;\n\t\t\t}, 0);\n\t\t}\n\t\t, force_saveable_type = \"application/octet-stream\"\n\t\t, fs_min_size = 0\n\t\t, deletion_queue = []\n\t\t, process_deletion_queue = function() {\n\t\t\tvar i = deletion_queue.length;\n\t\t\twhile (i--) {\n\t\t\t\tvar file = deletion_queue[i];\n\t\t\t\tif (typeof file === \"string\") { // file is an object URL\n\t\t\t\t\tURL.revokeObjectURL(file);\n\t\t\t\t} else { // file is a File\n\t\t\t\t\tfile.remove();\n\t\t\t\t}\n\t\t\t}\n\t\t\tdeletion_queue.length = 0; // clear queue\n\t\t}\n\t\t, dispatch = function(filesaver, event_types, event) {\n\t\t\tevent_types = [].concat(event_types);\n\t\t\tvar i = event_types.length;\n\t\t\twhile (i--) {\n\t\t\t\tvar listener = filesaver[\"on\" + event_types[i]];\n\t\t\t\tif (typeof listener === \"function\") {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlistener.call(filesaver, event || filesaver);\n\t\t\t\t\t} catch (ex) {\n\t\t\t\t\t\tthrow_outside(ex);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t, FileSaver = function(blob, name) {\n\t\t\t// First try a.download, then web filesystem, then object URLs\n\t\t\tvar\n\t\t\t\t  filesaver = this\n\t\t\t\t, type = blob.type\n\t\t\t\t, blob_changed = false\n\t\t\t\t, object_url\n\t\t\t\t, target_view\n\t\t\t\t, get_object_url = function() {\n\t\t\t\t\tvar object_url = get_URL().createObjectURL(blob);\n\t\t\t\t\tdeletion_queue.push(object_url);\n\t\t\t\t\treturn object_url;\n\t\t\t\t}\n\t\t\t\t, dispatch_all = function() {\n\t\t\t\t\tdispatch(filesaver, \"writestart progress write writeend\".split(\" \"));\n\t\t\t\t}\n\t\t\t\t// on any filesys errors revert to saving with object URLs\n\t\t\t\t, fs_error = function() {\n\t\t\t\t\t// don't create more object URLs than needed\n\t\t\t\t\tif (blob_changed || !object_url) {\n\t\t\t\t\t\tobject_url = get_object_url(blob);\n\t\t\t\t\t}\n\t\t\t\t\tif (target_view) {\n\t\t\t\t\t\ttarget_view.location.href = object_url;\n\t\t\t\t\t} else {\n\t\t\t\t\t\twindow.open(object_url, \"_blank\");\n\t\t\t\t\t}\n\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\tdispatch_all();\n\t\t\t\t}\n\t\t\t\t, abortable = function(func) {\n\t\t\t\t\treturn function() {\n\t\t\t\t\t\tif (filesaver.readyState !== filesaver.DONE) {\n\t\t\t\t\t\t\treturn func.apply(this, arguments);\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t, create_if_not_found = {create: true, exclusive: false}\n\t\t\t\t, slice\n\t\t\t;\n\t\t\tfilesaver.readyState = filesaver.INIT;\n\t\t\tif (!name) {\n\t\t\t\tname = \"download\";\n\t\t\t}\n\t\t\tif (can_use_save_link) {\n\t\t\t\tobject_url = get_object_url(blob);\n\t\t\t\t// FF for Android has a nasty garbage collection mechanism\n\t\t\t\t// that turns all objects that are not pure javascript into 'deadObject'\n\t\t\t\t// this means `doc` and `save_link` are unusable and need to be recreated\n\t\t\t\t// `view` is usable though:\n\t\t\t\tdoc = view.document;\n\t\t\t\tsave_link = doc.createElementNS(\"http://www.w3.org/1999/xhtml\", \"a\");\n\t\t\t\tsave_link.href = object_url;\n\t\t\t\tsave_link.download = name;\n\t\t\t\tvar event = doc.createEvent(\"MouseEvents\");\n\t\t\t\tevent.initMouseEvent(\n\t\t\t\t\t\"click\", true, false, view, 0, 0, 0, 0, 0\n\t\t\t\t\t, false, false, false, false, 0, null\n\t\t\t\t);\n\t\t\t\tsave_link.dispatchEvent(event);\n\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\tdispatch_all();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Object and web filesystem URLs have a problem saving in Google Chrome when\n\t\t\t// viewed in a tab, so I force save with application/octet-stream\n\t\t\t// http://code.google.com/p/chromium/issues/detail?id=91158\n\t\t\tif (view.chrome && type && type !== force_saveable_type) {\n\t\t\t\tslice = blob.slice || blob.webkitSlice;\n\t\t\t\tblob = slice.call(blob, 0, blob.size, force_saveable_type);\n\t\t\t\tblob_changed = true;\n\t\t\t}\n\t\t\t// Since I can't be sure that the guessed media type will trigger a download\n\t\t\t// in WebKit, I append .download to the filename.\n\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=65440\n\t\t\tif (webkit_req_fs && name !== \"download\") {\n\t\t\t\tname += \".download\";\n\t\t\t}\n\t\t\tif (type === force_saveable_type || webkit_req_fs) {\n\t\t\t\ttarget_view = view;\n\t\t\t}\n\t\t\tif (!req_fs) {\n\t\t\t\tfs_error();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfs_min_size += blob.size;\n\t\t\treq_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {\n\t\t\t\tfs.root.getDirectory(\"saved\", create_if_not_found, abortable(function(dir) {\n\t\t\t\t\tvar save = function() {\n\t\t\t\t\t\tdir.getFile(name, create_if_not_found, abortable(function(file) {\n\t\t\t\t\t\t\tfile.createWriter(abortable(function(writer) {\n\t\t\t\t\t\t\t\twriter.onwriteend = function(event) {\n\t\t\t\t\t\t\t\t\ttarget_view.location.href = file.toURL();\n\t\t\t\t\t\t\t\t\tdeletion_queue.push(file);\n\t\t\t\t\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\t\t\t\t\tdispatch(filesaver, \"writeend\", event);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\twriter.onerror = function() {\n\t\t\t\t\t\t\t\t\tvar error = writer.error;\n\t\t\t\t\t\t\t\t\tif (error.code !== error.ABORT_ERR) {\n\t\t\t\t\t\t\t\t\t\tfs_error();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\"writestart progress write abort\".split(\" \").forEach(function(event) {\n\t\t\t\t\t\t\t\t\twriter[\"on\" + event] = filesaver[\"on\" + event];\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\twriter.write(blob);\n\t\t\t\t\t\t\t\tfilesaver.abort = function() {\n\t\t\t\t\t\t\t\t\twriter.abort();\n\t\t\t\t\t\t\t\t\tfilesaver.readyState = filesaver.DONE;\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tfilesaver.readyState = filesaver.WRITING;\n\t\t\t\t\t\t\t}), fs_error);\n\t\t\t\t\t\t}), fs_error);\n\t\t\t\t\t};\n\t\t\t\t\tdir.getFile(name, {create: false}, abortable(function(file) {\n\t\t\t\t\t\t// delete file if it already exists\n\t\t\t\t\t\tfile.remove();\n\t\t\t\t\t\tsave();\n\t\t\t\t\t}), abortable(function(ex) {\n\t\t\t\t\t\tif (ex.code === ex.NOT_FOUND_ERR) {\n\t\t\t\t\t\t\tsave();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfs_error();\n\t\t\t\t\t\t}\n\t\t\t\t\t}));\n\t\t\t\t}), fs_error);\n\t\t\t}), fs_error);\n\t\t}\n\t\t, FS_proto = FileSaver.prototype\n\t\t, saveAs = function(blob, name) {\n\t\t\treturn new FileSaver(blob, name);\n\t\t}\n\t;\n\tFS_proto.abort = function() {\n\t\tvar filesaver = this;\n\t\tfilesaver.readyState = filesaver.DONE;\n\t\tdispatch(filesaver, \"abort\");\n\t};\n\tFS_proto.readyState = FS_proto.INIT = 0;\n\tFS_proto.WRITING = 1;\n\tFS_proto.DONE = 2;\n\n\tFS_proto.error =\n\tFS_proto.onwritestart =\n\tFS_proto.onprogress =\n\tFS_proto.onwrite =\n\tFS_proto.onabort =\n\tFS_proto.onerror =\n\tFS_proto.onwriteend =\n\t\tnull;\n\n\tview.addEventListener(\"unload\", process_deletion_queue, false);\n\tsaveAs.unload = function() {\n\t\tprocess_deletion_queue();\n\t\tview.removeEventListener(\"unload\", process_deletion_queue, false);\n\t};\n\treturn saveAs;\n}(\n\t   typeof self !== \"undefined\" && self\n\t|| typeof window !== \"undefined\" && window\n\t|| this.content\n));\n// `self` is undefined in Firefox for Android content script context\n// while `this` is nsIContentFrameMessageManager\n// with an attribute `content` that corresponds to the window\n\nif (typeof module !== \"undefined\") module.exports = saveAs;\n"
  }
]