{"name":"node-stream-zip","version":"1.11.0","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":"4edf18fdfe986a10288042d9f7afc36b3d1007e4","_id":"node-stream-zip@1.11.0","_nodeVersion":"13.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-IFO3dCRehnC/C57Gpk7tzhJnw3HL1AN4OdQMwUH5d1h2x6OPz3QI0gxWERURmHToujLUz/d8rHhbTpBJ9aa91Q==","shasum":"7e72a29a26d528e8dea0dcd32d1b88939b590dbe","tarball":"http://registry-npm.ywwl.com/node-stream-zip/download/node-stream-zip-1.11.0.tgz","fileCount":5,"unpackedSize":46649,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJevB4wCRA9TVsSAnZWagAAex4P/RIv1LWYr/5hmJAmI6FZ\nZcb1v3choRD3kUZpgIfrlbOtwlZhAhBuARdhXjRX+B72fRfyKT2XZXmH/b8u\nhwN95djD84kr9BrBUe4ocenHESoUeiaJSr9fGndk9xv0g6Ve7BfRxbIZo4AS\n5NgSJtfX68J2xrlp0OxD8/VX/HbnEM6mCFS6SmkMcyJtvnZ8ePHMWM/0Odot\nKNk6w1/gbWmJnTDJJOmJfM1t4IA/04eztHMFWR6St2nLSN7UkhLrcF5xUnmi\np+CbTzX2dEbsrWZz1tgxaCKSQXUN1k7IHTKbSbYTqXiDs7EfFiLGwztp+spn\nevbZqbU0thtfUXO1PWCFA9KosZB1lyJzHGtAJRjph5BGvb8v87dwZYPb/0Sg\n4nVjrxAiIabURf/qXu5wF3b14QgpmkJvNo1NpYkCc6bKIqVToKobwaOgNBiz\nZ+XgVoVgtL1wga+1TPPJNa3OOMD9nHTCd+Cj7yItpJWkj+UN6LwSXaGu6Fkc\ncDjPsBgBmDJA+m4Sbs6L9tRH0D9dbBcqg/miP3LY5AIhfDLVkMHy9V3lEmwi\nzSMnMWz5chKCb9i7G0tT74h33yT10FTeruiZfH0f06GDAQkQHbPAwnIyubXI\nn1JLtTszZuipIHqY9oT9wx360qKVZYME2/tdHZTkB1u/G4QI+2XKk7kzgfXL\nGL7X\r\n=4wOj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDIm2W1VHRug44cyEMxuAtlxyLlGngI9HbsthxwlLOVnAIgD9S/lU9oO4+AjCebaRLV9TjCw4GsU/zGvcuDF5X8S7c="}],"size":11283,"noattachment":false,"key":"/node-stream-zip/-/node-stream-zip-1.11.0.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.0_1589386799582_0.6131990014546083"},"_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":1589386799793,"_cnpm_publish_time":1589386799793,"dist-tags":{"latest":"1.16.0"}}