{"id":13396783,"url":"https://github.com/archiverjs/node-archiver","last_synced_at":"2025-05-12T05:32:57.481Z","repository":{"id":4977694,"uuid":"6135596","full_name":"archiverjs/node-archiver","owner":"archiverjs","description":"a streaming interface for archive generation","archived":false,"fork":false,"pushed_at":"2025-05-01T17:29:39.000Z","size":1228,"stargazers_count":2873,"open_issues_count":151,"forks_count":226,"subscribers_count":28,"default_branch":"master","last_synced_at":"2025-05-12T04:12:37.541Z","etag":null,"topics":["archiver","javascript","nodejs","tar","zip"],"latest_commit_sha":null,"homepage":"https://www.archiverjs.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mruegenberg/Delaunay","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/archiverjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2012-10-09T05:00:56.000Z","updated_at":"2025-05-12T03:42:48.000Z","dependencies_parsed_at":"2023-02-13T18:20:15.030Z","dependency_job_id":"ec5c400b-ac12-4c4c-87d3-a13c40b93d4f","html_url":"https://github.com/archiverjs/node-archiver","commit_stats":{"total_commits":906,"total_committers":43,"mean_commits":"21.069767441860463","dds":"0.21412803532008828","last_synced_commit":"a10059fda3f6235afdd8e612fc64fc3e82639fb0"},"previous_names":[],"tags_count":77,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archiverjs%2Fnode-archiver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archiverjs%2Fnode-archiver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archiverjs%2Fnode-archiver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/archiverjs%2Fnode-archiver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/archiverjs","download_url":"https://codeload.github.com/archiverjs/node-archiver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253683060,"owners_count":21947062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archiver","javascript","nodejs","tar","zip"],"created_at":"2024-07-30T18:01:03.051Z","updated_at":"2025-05-12T05:32:57.440Z","avatar_url":"https://github.com/archiverjs.png","language":"JavaScript","readme":"# Archiver\n\nA streaming interface for archive generation\n\nVisit the [API documentation](https://www.archiverjs.com/) for a list of all methods available.\n\n## Install\n\n```bash\nnpm install archiver --save\n```\n\n## Quick Start\n\n```js\nimport fs from \"fs\";\nimport { ZipArchive } from \"archiver\";\n\n// create a file to stream archive data to.\nconst output = fs.createWriteStream(__dirname + \"/example.zip\");\nconst archive = new ZipArchive({\n  zlib: { level: 9 }, // Sets the compression level.\n});\n\n// listen for all archive data to be written\n// 'close' event is fired only when a file descriptor is involved\noutput.on(\"close\", function () {\n  console.log(archive.pointer() + \" total bytes\");\n  console.log(\n    \"archiver has been finalized and the output file descriptor has closed.\",\n  );\n});\n\n// This event is fired when the data source is drained no matter what was the data source.\n// It is not part of this library but rather from the NodeJS Stream API.\n// @see: https://nodejs.org/api/stream.html#stream_event_end\noutput.on(\"end\", function () {\n  console.log(\"Data has been drained\");\n});\n\n// good practice to catch warnings (ie stat failures and other non-blocking errors)\narchive.on(\"warning\", function (err) {\n  if (err.code === \"ENOENT\") {\n    // log warning\n  } else {\n    // throw error\n    throw err;\n  }\n});\n\n// good practice to catch this error explicitly\narchive.on(\"error\", function (err) {\n  throw err;\n});\n\n// pipe archive data to the file\narchive.pipe(output);\n\n// append a file from stream\nconst file1 = __dirname + \"/file1.txt\";\narchive.append(fs.createReadStream(file1), { name: \"file1.txt\" });\n\n// append a file from string\narchive.append(\"string cheese!\", { name: \"file2.txt\" });\n\n// append a file from buffer\nconst buffer3 = Buffer.from(\"buff it!\");\narchive.append(buffer3, { name: \"file3.txt\" });\n\n// append a file\narchive.file(\"file1.txt\", { name: \"file4.txt\" });\n\n// append files from a sub-directory and naming it `new-subdir` within the archive\narchive.directory(\"subdir/\", \"new-subdir\");\n\n// append files from a sub-directory, putting its contents at the root of archive\narchive.directory(\"subdir/\", false);\n\n// append files from a glob pattern\narchive.glob(\"file*.txt\", { cwd: __dirname });\n\n// finalize the archive (ie we are done appending files but streams have to finish yet)\n// 'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand\narchive.finalize();\n```\n\n## Formats\n\nArchiver ships with out of the box support for TAR and ZIP archives.\n","funding_links":[],"categories":["压缩","Packages","JavaScript","GIT 仓库","包","javascript","Compression","nodejs","目录","Number","Uncategorized"],"sub_categories":["Compression","压缩解压","压缩","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchiverjs%2Fnode-archiver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farchiverjs%2Fnode-archiver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farchiverjs%2Fnode-archiver/lists"}