{"id":24568701,"url":"https://github.com/biw/lzma-web","last_synced_at":"2025-04-22T17:22:17.342Z","repository":{"id":43358079,"uuid":"466299818","full_name":"biw/lzma-web","owner":"biw","description":"A JavaScript implementation of the Lempel-Ziv-Markov (LZMA) chain compression algorithm ","archived":false,"fork":false,"pushed_at":"2022-03-05T23:44:07.000Z","size":13630,"stargazers_count":9,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T14:26:12.284Z","etag":null,"topics":["compression","compression-algorithm","decompression","decompression-library","lzma"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/biw.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-04T23:36:03.000Z","updated_at":"2024-11-26T20:04:37.000Z","dependencies_parsed_at":"2022-09-07T06:21:12.200Z","dependency_job_id":null,"html_url":"https://github.com/biw/lzma-web","commit_stats":null,"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Flzma-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Flzma-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Flzma-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/biw%2Flzma-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/biw","download_url":"https://codeload.github.com/biw/lzma-web/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235300327,"owners_count":18967738,"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":["compression","compression-algorithm","decompression","decompression-library","lzma"],"created_at":"2025-01-23T14:55:05.969Z","updated_at":"2025-01-23T14:55:06.510Z","avatar_url":"https://github.com/biw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lzma-web\n\n[![Build Status][build-badge]][build]\n[![version][version-badge]][package]\n[![bundlephobia][bundlephobia-badge]][bundlephobia]\n[![MIT License][license-badge]][license]\n\n`lzma-web` is a JavaScript implementation of the Lempel-Ziv-Markov (LZMA) chain compression algorithm.\n\n**The codebase is a fork of [LZMA-JS](https://github.com/nmrugg/LZMA-JS) written by [Nathan Rugg](https://github.com/nmrugg).**\n\n## Install\n\n```sh\nyarn add lzma-web\n```\n\n## Usage\n\n```js\nimport LZMA from 'lzma-web'\nconst lzma = new LZMA()\n\nconst str = \"Hello World\"\n\nconst compressed = await lzma.compress(str)\n\nconst decompressed = await lzma.decompress(compressed)\n\nconsole.log(str === decompressed) // -\u003e true\n```\n\nYou can also set the compression level on `compress` via an optional second parameter:\n\n```js\n// value ranges from `1` (fastest) to `9` best\nconst compressed = await lzma.compress(\"Hello World\", 1)\n```\n\nFinally, lzma-web also supports compression progress via callbacks (for large payloads):\n\n```js\nconst str = \"Hello World\"\n\nlmza.cb.compress(\n  str, \n  9, // compression level must be set when using callback\n  (result, error) =\u003e { // when the compression finishes or errors\n    if (error) throw error\n    console.log(results)\n  },\n  (progressPercentage) =\u003e {\n    console.log('the current percentage is', progressPercentage)\n  },\n)\n```\n\nand decompression progress via callbacks:\n\n```js\nconst byteArray = [/* \u003carray of bytes\u003e */]\n\nlzma.cb.decompress(\n  byteArray,\n  (result, error) =\u003e {\n    if (error) throw error\n    console.log(results)\n  },\n  // If the decompression progress is unable to be calculated, the \n  // `on_progress()` function will be triggered once with the value `-1`.\n  (progressPercentage) =\u003e {\n    console.log('the current percentage is', progressPercentage)\n  }\n)\n```\n\n## Typescript\n\nThe repo has typescript support. You can view the types in [`index.d.ts`](https://github.com/biw/lzma-web/blob/main/index.d.ts).\n\n## Web Workers\n\nIf the current browser supports web workers, `lzma-web` uses them to prevent blocking the main thread.\n\nEach call of `new LZMA()` will create a new web worker.\n\nIn Node.js and unsupported browsers, `lzma-web` is run in the main thread.\n\nAlmost all modern browsers support web workers: [https://caniuse.com/webworkers](https://caniuse.com/webworkers)\n\n## Demos\n\nLive demos can be found at [http://lzma-js.github.io/LZMA-JS/](http://lzma-js.github.io/LZMA-JS/).\n\n## Compatibility\n\n`lzma-web` is compatible with the reference implementation of LZMA, for example, the `lzma` command.\n\n## License\n\n[MIT](https://github.com/biw/lzma-web/blob/main/LICENSE)\n\n[build-badge]: https://img.shields.io/circleci/build/github/biw/lzma-web.svg?style=flat-square\n[build]: https://app.circleci.com/pipelines/github/biw/lzma-web\n[version-badge]: https://img.shields.io/npm/v/lzma-web.svg?style=flat-square\n[package]: https://www.npmjs.com/package/lzma-web\n[license-badge]: https://img.shields.io/npm/l/lzma-web.svg?style=flat-square\n[license]: https://github.com/biw/lzma-web/blob/master/LICENSE\n[bundlephobia]: https://bundlephobia.com/result?p=lzma-web\n[bundlephobia-badge]: https://img.shields.io/bundlephobia/minzip/lzma-web@latest?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiw%2Flzma-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbiw%2Flzma-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbiw%2Flzma-web/lists"}