{"name":"node-stream-zip","version":"1.11.4","description":"node.js library for reading and extraction of ZIP archives","keywords":["zip","archive","unzip","stream"],"homepage":"https://github.com/antelle/node-stream-zip","author":{"name":"Antelle","email":"antelle.net@gmail.com","url":"https://github.com/antelle"},"bugs":{"url":"https://github.com/antelle/node-stream-zip/issues","email":"antelle.net@gmail.com"},"license":"MIT","scripts":{"test":"nodeunit test/tests.js"},"main":"node_stream_zip.js","types":"node_stream_zip.d.ts","repository":{"type":"git","url":"git+https://github.com/antelle/node-stream-zip.git"},"engines":{"node":">=0.10.0"},"devDependencies":{"nodeunit":"^0.11.3"},"gitHead":"4e73b6d5595fde2741f222b526d6e2eb0cbfd268","_id":"node-stream-zip@1.11.4","_nodeVersion":"14.6.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-Mnl/AOz64eJlfMpMb7cvk31OWtMbfHzwTLg87C5JhePALzVGn3Fp52dqNdb3e2p+7PvA1chGriHSm90Ikf+HJQ==","shasum":"4a06cf8640fa6d605348bc08e8662ea3c728f451","tarball":"http://registry-npm.ywwl.com/node-stream-zip/download/node-stream-zip-1.11.4.tgz","fileCount":5,"unpackedSize":47294,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfnVvqCRA9TVsSAnZWagAAkYYP/RzbLyH8hwVusIG9AgSl\nxb6YnV0GS5aHvm2h8QjZZaMt4m496ZhtYS5BMVxg7lF2X2EHDEv+Kfm9+fFt\niL9+W8/t2ssCWNdy9rOsxnjK0R+wvAVjhQTjUg/JE01iymDde6AxktHj1AoW\ntcBqYMoO1nd6HngvHn9P0/qKOBeyAEqQecLTLkdbSZsSpG0tFpRukCWXARn6\nzwe/T53hMN55OzpuKyadanFPUi7mkM0V0Qcec+7IxrEYfz7tTX6iT44WOEsX\n1EQ2J1veT1RoPDfn5ccVGthCRsl/I2SeyjA4J4jXzZZcA8VcCkgmT3xqCg8L\ngODiLCA+Ic3HUe0Wrh7oKSnTtBG8WZFYR3pj/G58dIjGiJDSHCQlB5zc5zJy\nkk0082isqywabkF0CwiTjzhQe13H2JN1Znjl4EiWR8AezS9OHDIwtuCl4UxP\nJjya6dLcI4zCjanXlZNJMzOOb4GC7VrejVuNVlID91JXUy4e7TSUyQ+6xhoJ\n3lDyJrxaX4HPBN0AQ+hMYU4RhEunhOx6qaf7Q17EkkKDv9RIR7yHypyqIUmB\nL8S0e6kuu0cPv8FsDcdf8O8RjaW2hSI+d3eeJfs4Z6K8Enlwef3exluylfoy\n1aCuHpSLuFxUT0YxelEtPjM6sp6O0tw3V2NpZVIW6IiGhnbLzgZWZzfCiP1J\nW9fu\r\n=udiQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBCCDYWgxz5wIkFcaT4/0woCcJcaulwQPjHtkxuupJhHAiEAoyqQ9o5hnoEz11MegY0BksxpTu4M6Nw088j4RO61cmA="}],"size":11349,"noattachment":false,"key":"/node-stream-zip/-/node-stream-zip-1.11.4.tgz"},"maintainers":[{"name":"antelle","email":"antelle.net@gmail.com"}],"_npmUser":{"name":"antelle","email":"antelle.net@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-stream-zip_1.11.4_1604148202206_0.004235805165098139"},"_hasShrinkwrap":false,"readme":"# node-stream-zip ![CI Checks](https://github.com/antelle/node-stream-zip/workflows/CI%20Checks/badge.svg)\n\nnode.js library for reading and extraction of ZIP archives.  \nFeatures:\n\n- it never loads entire archive into memory, everything is read by chunks\n- large archives support\n- all operations are non-blocking, no sync i/o\n- fast initialization\n- no dependencies, no binary addons\n- decompression with built-in zlib module\n- deflate, sfx, macosx/windows built-in archives\n- ZIP64 support\n\n## Installation\n\n```sh\nnpm i node-stream-zip\n```\n\n## Usage\n\nThere are two APIs provided:\n1. [promise-based / async](#async-api) \n2. [callbacks](#callback-api)\n\nIt's recommended to use the new, promise API, however the legacy callback API \nmay be more flexible for certain operations.\n\n### Async API\n\nOpen a zip file\n```javascript\nconst StreamZip = require('node-stream-zip');\nconst zip = new StreamZip.async({ file: 'archive.zip' });\n```\n\nStream one entry to stdout\n```javascript\nconst stm = await zip.stream('path/inside/zip.txt');\nstm.pipe(process.stdout);\nstm.on('end', () => zip.close());\n```\n\nRead a file as buffer\n```javascript\nconst data = await zip.entryData('path/inside/zip.txt');\nawait zip.close();\n```\n\nExtract one file to disk\n```javascript\nawait zip.extract('path/inside/zip.txt', './extracted.txt');\nawait zip.close();\n```\n\nList entries\n```javascript\nconst entriesCount = await zip.entriesCount;\nconsole.log(`Entries read: ${entriesCount}`);\n\nconst entries = await zip.entries();\nfor (const entry of Object.values(entries)) {\n    const desc = entry.isDirectory ? 'directory' : `${entry.size} bytes`;\n    console.log(`Entry ${entry.name}: ${desc}`);\n}\n\n// Do not forget to close the file once you're done\nawait zip.close();\n```\n\nExtract a folder from archive to disk\n```javascript\nfs.mkdirSync('extracted');\nawait zip.extract('path/inside/zip/', './extracted');\nawait zip.close();\n```\n\nExtract everything\n```javascript\nfs.mkdirSync('extracted');\nconst count = await zip.extract(null, './extracted');\nconsole.log(`Extracted ${count} entries`);\nawait zip.close();\n```\n\nWhen extracting a folder, you can listen to `extract` event\n```javascript\nzip.on('extract', (entry, file) => {\n    console.log(`Extracted ${entry.name} to ${file}`);\n});\n```\n\n`entry` event is generated for every entry during loading\n```javascript\nzip.on('entry', entry => {\n    // you can already stream this entry,\n    // without waiting until all entry descriptions are read (suitable for very large archives)\n    console.log(`Read entry ${entry.name}`);\n});\n```\n\n### Callback API\n\nOpen a zip file\n```javascript\nconst StreamZip = require('node-stream-zip');\nconst zip = new StreamZip({ file: 'archive.zip' });\n\n// Handle errors\nzip.on('error', err => { /*...*/ });\n```\n\nList entries\n```javascript\nzip.on('ready', () => {\n    console.log('Entries read: ' + zip.entriesCount);\n    for (const entry of Object.values(zip.entries())) {\n        const desc = entry.isDirectory ? 'directory' : `${entry.size} bytes`;\n        console.log(`Entry ${entry.name}: ${desc}`);\n    }\n    // Do not forget to close the file once you're done\n    zip.close();\n});\n```\n\nStream one entry to stdout\n```javascript\nzip.on('ready', () => {\n    zip.stream('path/inside/zip.txt', (err, stm) => {\n        stm.pipe(process.stdout);\n        stm.on('end', () => zip.close());\n    });\n});\n```\n\nExtract one file to disk\n```javascript\nzip.on('ready', () => {\n    zip.extract('path/inside/zip.txt', './extracted.txt', err => {\n        console.log(err ? 'Extract error' : 'Extracted');\n        zip.close();\n    });\n});\n```\n\nExtract a folder from archive to disk\n```javascript\nzip.on('ready', () => {\n    fs.mkdirSync('extracted');\n    zip.extract('path/inside/zip/', './extracted', err => {\n        console.log(err ? 'Extract error' : 'Extracted');\n        zip.close();\n    });\n});\n```\n\nExtract everything\n```javascript\nzip.on('ready', () => {\n    fs.mkdirSync('extracted');\n    zip.extract(null, './extracted', (err, count) => {\n        console.log(err ? 'Extract error' : `Extracted ${count} entries`);\n        zip.close();\n    });\n});\n```\n\nRead a file as buffer in sync way\n```javascript\nzip.on('ready', () => {\n    const data = zip.entryDataSync('path/inside/zip.txt');\n    zip.close();\n});\n```\n\nWhen extracting a folder, you can listen to `extract` event\n```javascript\nzip.on('extract', (entry, file) => {\n    console.log(`Extracted ${entry.name} to ${file}`);\n});\n```\n\n`entry` event is generated for every entry during loading\n```javascript\nzip.on('entry', entry => {\n    // you can already stream this entry,\n    // without waiting until all entry descriptions are read (suitable for very large archives)\n    console.log(`Read entry ${entry.name}`);\n});\n```\n\n## Options\n\nYou can pass these options to the constructor\n- `storeEntries: true` - you will be able to work with entries inside zip archive, otherwise the only way to access them is `entry` event\n- `skipEntryNameValidation: true` - by default, entry name is checked for malicious characters, like `../` or `c:\\123`, pass this flag to disable validation errors\n\n## Methods\n\n- `zip.entries()` - get all entries description\n- `zip.entry(name)` - get entry description by name\n- `zip.stream(entry, function(err, stm) { })` - get entry data reader stream\n- `zip.entryDataSync(entry)` - get entry data in sync way\n- `zip.close()` - cleanup after all entries have been read, streamed, extracted, and you don't need the archive\n\n## Building\n\nThe project doesn't require building. To run unit tests with [nodeunit](https://github.com/caolan/nodeunit):  \n```sh\nnpm test\n```\n\n## Known issues\n\n- [utf8](https://github.com/rubyzip/rubyzip/wiki/Files-with-non-ascii-filenames) file names\n\n## Out of scope\n\n- AES encrypted files: the library will throw an error if you try to open it\n\n## Contributors\n\nZIP parsing code has been partially forked from [cthackers/adm-zip](https://github.com/cthackers/adm-zip) (MIT license).\n","publish_time":1604148202364,"_cnpm_publish_time":1604148202364,"dist-tags":{"latest":"1.16.0"}}