{"id":19794181,"url":"https://github.com/openzim/node-libzim","last_synced_at":"2025-04-09T13:03:50.824Z","repository":{"id":11805706,"uuid":"61616827","full_name":"openzim/node-libzim","owner":"openzim","description":"Libzim binding for Node.js: read/write ZIM files in Javascript","archived":false,"fork":false,"pushed_at":"2024-12-22T17:44:10.000Z","size":1046,"stargazers_count":27,"open_issues_count":10,"forks_count":11,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-04T16:50:30.449Z","etag":null,"topics":["binding","cpp","library","nodejs","offline","openzim","webscraping","zim"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@openzim/libzim","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openzim.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"kiwix","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-06-21T08:36:02.000Z","updated_at":"2024-12-22T15:32:45.000Z","dependencies_parsed_at":"2023-02-18T17:46:08.764Z","dependency_job_id":"a955314a-3fb4-47e1-b457-ab34031053c7","html_url":"https://github.com/openzim/node-libzim","commit_stats":{"total_commits":416,"total_committers":15,"mean_commits":"27.733333333333334","dds":0.7307692307692308,"last_synced_commit":"f838455bf19a7df7a71ca52da6867c253f408179"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzim%2Fnode-libzim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzim%2Fnode-libzim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzim%2Fnode-libzim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openzim%2Fnode-libzim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openzim","download_url":"https://codeload.github.com/openzim/node-libzim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"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":["binding","cpp","library","nodejs","offline","openzim","webscraping","zim"],"created_at":"2024-11-12T07:12:25.796Z","updated_at":"2025-04-09T13:03:50.799Z","avatar_url":"https://github.com/openzim.png","language":"C++","readme":"node-libzim\n===========\n\nThis is the Node.js binding to the\n[libzim](https://github.com/openzim/libzim/). Read and write\n[ZIM](https://openzim.org) files easily in Javascript.\n\n[![npm](https://img.shields.io/npm/v/@openzim/libzim.svg)](https://www.npmjs.com/package/@openzim/libzim)\n[![Build Status](https://github.com/openzim/node-libzim/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/openzim/node-libzim/actions/workflows/ci.yml?query=branch%3Amain)\n[![codecov](https://codecov.io/gh/openzim/node-libzim/branch/main/graph/badge.svg)](https://codecov.io/gh/openzim/node-libzim)\n[![CodeFactor](https://www.codefactor.io/repository/github/openzim/node-libzim/badge)](https://www.codefactor.io/repository/github/openzim/node-libzim)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Join Slack](https://img.shields.io/badge/Join%20us%20on%20Slack%20%23mwoffliner-2EB67D)](https://slack.kiwix.org)\n\n## Dependencies\n\nThis package relies on [node-addon-api](https://github.com/nodejs/node-addon-api) / n-api.\n\nOn GNU/Linux \u0026 macOS, the package will download a `libzim` binary. On\nother OSes you will need to install `libzim` separately ([see\nhere](https://github.com/openzim/libzim/)).\n\n## Usage\n\n```bash\nnpm i @openzim/libzim\n```\n\n### Writing a ZIM file\n```javascript\n// write.js\nimport { Creator, StringItem } from \"@openzim/libzim\";\n\n(async () =\u003e {\n    console.info('Starting');\n    const outFile = \"./test.zim\";\n    const creator = new Creator()\n        .configNbWorkers(1)\n        .configIndexing(true, \"en\")\n        .configClusterSize(2048)\n        .startZimCreation(outFile);\n\n    for (let i = 0; i \u003c 100; i++) {\n        const item = new StringItem(\n            `file${i}`,                       // path url\n            \"text/plain\",                     // content-type\n            `Title ${i}`,                     // title\n            {FRONT_ARTICLE: 1, COMPRESS: 1},  // hint option flags\n            `\u003ch1\u003eContent / Data ${i}\u003c/h1\u003e`    // content\n        );\n        await creator.addItem(item);\n    }\n\n    creator.setMainPath(\"file0\");\n    await creator.finishZimCreation();\n\n    console.log('Done Writing');\n})();\n```\n\n### Reading a ZIM file\n```javascript\n// read.js\nimport { Archive, SuggestionSearcher, Searcher } from \"@openzim/libzim\";\n\n(async () =\u003e {\n    const outFile = \"./test.zim\";\n    const archive = new Archive(outFile);\n    console.log(`Archive opened: main entry path - ${archive.mainEntry.path}`);\n\n    for (const entry of archive.iterByPath()) {\n        console.log(`entry: ${entry.path} - ${entry.title}`);\n    }\n\n    const suggestionSearcher = new SuggestionSearcher(archive);\n    const suggestion = suggestionSearcher.suggest('laborum');\n    let results = suggestion.getResults(0, 10);\n    console.log(\"Suggestion results:\");\n    for(const entry of results) {\n        console.log(`\\t- ${entry.path} - ${entry.title}`);\n    }\n\n    const searcher = new Searcher(archive);\n    const search = searcher.search(new Query('rem'));\n    results = search.getResults(0, 10);\n    console.log(\"Search results:\");\n    for(const entry of results) {\n        console.log(`\\t- ${entry.path} - ${entry.title}`);\n    }\n\n\n    const entry = await archive.getEntryByPath(\"A/laborum\");\n    const item = entry.item;\n    const blob = item.data;\n    console.info(`Entry by url (laborum):`, blob.data);\n    delete archive;\n})();\n\n```\n\n## License\n\n[GPLv3](https://www.gnu.org/licenses/gpl-3.0) or later, see\n[LICENSE](LICENSE) for more details.\n","funding_links":["https://github.com/sponsors/kiwix"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzim%2Fnode-libzim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenzim%2Fnode-libzim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenzim%2Fnode-libzim/lists"}