{"id":13344176,"url":"https://github.com/magnetardev/archive","last_synced_at":"2025-03-12T07:31:56.193Z","repository":{"id":45235882,"uuid":"378515340","full_name":"magnetardev/archive","owner":"magnetardev","description":"A port of libarchive to WebAssembly, with a simple JS wrapper.","archived":false,"fork":false,"pushed_at":"2022-08-16T04:53:16.000Z","size":1248,"stargazers_count":7,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-24T18:33:05.353Z","etag":null,"topics":["7zip","compression","decompression","javascript","libarchive","typescript","webassembly","zip"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magnetardev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-19T22:27:57.000Z","updated_at":"2024-09-10T23:12:45.000Z","dependencies_parsed_at":"2022-08-04T13:00:28.513Z","dependency_job_id":null,"html_url":"https://github.com/magnetardev/archive","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetardev%2Farchive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetardev%2Farchive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetardev%2Farchive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magnetardev%2Farchive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magnetardev","download_url":"https://codeload.github.com/magnetardev/archive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243178184,"owners_count":20249057,"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":["7zip","compression","decompression","javascript","libarchive","typescript","webassembly","zip"],"created_at":"2024-07-29T19:32:28.216Z","updated_at":"2025-03-12T07:31:55.817Z","avatar_url":"https://github.com/magnetardev.png","language":"TypeScript","readme":"# Archive\n\nA port of libarchive to WebAssembly, with a simple JS wrapper.\n\n**It is _highly_ recommended that you offload reading and writing to a Worker.** For the browser or deno, that'd be through `Worker` and for node that would be through the `worker_threads` module. There isn't an official worker wrapper yet, but using a library like [Comlink](https://github.com/GoogleChromeLabs/comlink) can get you up and running with one in minutes.\n\n### Install\n\n```shell\n# if you use yarn:\nyarn add @magnetardev/archive\n\n# if you use npm:\nnpm install @magnetardev/archive\n```\n\n### Why?\n\nAren't there a few of these ports? Well, yes. In fact, this uses the exact same Dockerfile from [libarchivejs](https://github.com/nika-begiashvili/libarchivejs). However, libarchivejs does not support Node and forces you to use a Worker. I also haven't found one that supports creating archives. Finally, the APIs most of the ports offer are not as simple as they can be, which is a shame. So, I made this.\n\n## Examples\n\n### Reading an archive\n\n```js\nimport * as archive from '@magnetardev/archive';\n\nconst buffer = ...; // Obtain a Uint8Array version of your archive.\nconst reader = await archive.createReader(buffer);\nfor (const entry of reader) {\n  console.log(entry.path, entry.extract());\n}\nreader.close();\n```\n\n### Creating an archive\n\n```js\nimport * as archive from \"@magnetardev/archive\";\n\n// Create a writer.\nconst writer = await archive.createWriter();\n\n// Add a file\nconst contents = new TextEncoder().encode(\"hello, world!\");\nwriter.add(\"hello.txt\", contents);\n\n// Finalize the archive and get a Uint8Array version.\nconst zip = writer.close();\nconsole.log(zip);\n```\n\n## Building\n\nBuilding is kind of a mess, but is quite easy with Docker. If you choose to do so without Docker, you need to compile OpenSSL, LZMA, and libarchive with `emcc`. This short guide covers the Docker build process:\n\n1. Run `yarn build:wasm`. This can take quite a while the first time, but consecutive builds will be much faster. This builds just the WebAssembly port and the Emscripten wrapper.\n2. Run `yarn build`. This builds the JS wrapper.\n3. Done.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetardev%2Farchive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagnetardev%2Farchive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagnetardev%2Farchive/lists"}