{"id":21655250,"url":"https://github.com/pseitz/lz4-wasm","last_synced_at":"2025-04-11T21:20:18.866Z","repository":{"id":66217865,"uuid":"338416969","full_name":"PSeitz/lz4-wasm","owner":"PSeitz","description":"https://pseitz.github.io/lz4-wasm/","archived":false,"fork":false,"pushed_at":"2023-06-24T13:35:02.000Z","size":4382,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T17:15:13.335Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSeitz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_APACHE","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}},"created_at":"2021-02-12T19:45:11.000Z","updated_at":"2025-03-21T03:34:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"0aad36e6-2695-4c07-a423-359581c31841","html_url":"https://github.com/PSeitz/lz4-wasm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Flz4-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Flz4-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Flz4-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSeitz%2Flz4-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSeitz","download_url":"https://codeload.github.com/PSeitz/lz4-wasm/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480422,"owners_count":21110939,"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":[],"created_at":"2024-11-25T08:31:01.346Z","updated_at":"2025-04-11T21:20:18.844Z","avatar_url":"https://github.com/PSeitz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003cdiv align=\"center\"\u003e\n\n  \u003ch1\u003e\u003ccode\u003elz4-wasm\u003c/code\u003e and \u003ccode\u003elz4-wasm-nodejs\u003c/code\u003e \u003c/h1\u003e\n\n  \u003cstrong\u003eExtremely fast compression(200MB/s Firefox, 350Mb/s Chrome) and decompression(600MB/s Firefox, 1400Mb/s Chrome) in the browser or nodejs using wasm.\u003c/strong\u003e\n\n\u003c/div\u003e\n\n## Benchmarks\n\nTest it yourself here:\nhttps://pseitz.github.io/lz4-wasm/\n\nInput | Lib | Compression | Decrompression | Ratio \n| ---    | ---    | ---       | ---       | ---  \n66k_JSON|\tlz4 wasm|\t292.43MB/s|\t687.37MB/s|\t0.23\n66k_JSON|\tlz4 js|\t101.48MB/s|\t27.06MB/s|\t0.24\n66k_JSON|\tfflate|\t24.21MB/s|\t117.80MB/s|\t0.17\n65k Text|\tlz4 wasm|\t146.10MB/s|\t610.59MB/s|\t0.55\n65k Text|\tlz4 js|\t73.55MB/s|\t28.15MB/s|\t0.56\n65k Text|\tfflate|\t15.40MB/s|\t63.83MB/s|\t0.41\n34k Text|\tlz4 wasm|\t159.57MB/s|\t562.43MB/s|\t0.57\n34k Text|\tlz4 js|\t59.77MB/s|\t28.10MB/s|\t0.58\n34k Text|\tfflate|\t15.53MB/s|\t55.79MB/s|\t0.41\n1k Text|\tlz4 wasm|\t181.25MB/s|\t362.50MB/s|\t0.78\n1k Text|\tlz4 js|\t2.18MB/s|\t45.31MB/s|\t0.77\n1k Text|\tfflate|\t5.49MB/s|\t3.64MB/s|\t0.53\n\n## 🚴 Usage\n\nThere are two npm packages:\n* nodejs `lz4-wasm-nodejs` \n* browser `lz4-wasm`\n\nSee usage examples in this repo for [browser](https://github.com/PSeitz/lz4-wasm/tree/main/example_project) and [nodejs](https://github.com/PSeitz/lz4-wasm/tree/main/example_project_nodejs)\n\nThe wasm module exposes two function compress and decompress.\nBoth accept and return UInt8Array. \nInternally the lz4 block api is used, the length of the original input is prepended in 32-bit little endian.\nThe wasm code is based on [lz4_flex](https://github.com/pseitz/lz4_flex)\n\n```\n\nimport * as wasm from \"lz4-wasm\";\n\n// use TextEncoder to get bytes (UInt8Array) from string\nvar enc = new TextEncoder();\nconst compressed = wasm.compress(enc.encode(\"compress this text, compress this text pls. thx. thx. thx. thx. thx\"));\nconst original = wasm.decompress(compressed);\n\nvar dec = new TextDecoder(\"utf-8\");\nalert(dec.decode(original))\n\n```\n\n\n\n\n\n## Making New Releases\n\n### Release for bundler\n\nBuild. This will optimize usage for inside a bundler like webpack.\n```\nRUST_LOG=info wasm-pack build --release\n```\n\nDue to a long standing bug in wasm-pack 0.9.1, _manually_ add these files to pkg/package.json.\n\n```\n    \"lz4_wasm_bg.wasm.d.ts\",\n```\n\n```\nRUST_LOG=info wasm-pack publish\n```\n\n\n### Release for nodejs\n\nset name in Cargo toml to\n```\nname = \"lz4-wasm-nodejs\"\n```\n\nBuild for nodejs\n```\nRUST_LOG=info wasm-pack build --release -t nodejs\n```\n\n```\nRUST_LOG=info wasm-pack publish\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Flz4-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpseitz%2Flz4-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpseitz%2Flz4-wasm/lists"}