{"_id":"lz4-lite","_rev":"4-91e46181467d65c6f8f28afae5fc03cf","name":"lz4-lite","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"lz4-lite","version":"1.0.0","keywords":["lz4","lz4js","compression","decompression","codec","typescript","frame","block","zero-dependency"],"author":{"name":"Alexander Vukov"},"license":"MIT","_id":"lz4-lite@1.0.0","maintainers":[{"name":"alex-vukov","email":"alexvukov@gmail.com"}],"dist":{"shasum":"a15d20467a90e544994d00dd2da55fd513e26ff6","tarball":"https://registry.npmjs.org/lz4-lite/-/lz4-lite-1.0.0.tgz","fileCount":24,"integrity":"sha512-iK//HccdNVl3apRVtjcIp3kHhSCn4FvI07M+NFEuLhKkZbhlq392PMKMvih3j13AGurGLYACAyReHGcjV0vyvg==","signatures":[{"sig":"MEYCIQDbtas4YEML4VK46a57IxVdBO2MT3tzCvBbq0hGABHXwwIhALjD9l2NS7GGauWR14r9u1BOFqRzRt3/jq76vmLmjY7W","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44761},"main":"./dist/cjs/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=14"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"913d41d1132047a721703e53e9f35e24e208546d","scripts":{"lint":"biome check","test":"npm run build && node --import tsx --test test/*.test.ts","build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/fixup-dual.mjs","clean":"rm -rf dist","format":"biome format --write","lint:fix":"biome check --write","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run lint && npm run build"},"_npmUser":{"name":"alex-vukov","email":"alexvukov@gmail.com"},"_npmVersion":"10.9.8","description":"A lean, optimized, spec-compliant LZ4 (block + frame) codec in TypeScript — zero dependencies.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.0","typescript":"^5.6.0","@types/node":"^22.0.0","@biomejs/biome":"2.5.0"},"_npmOperationalInternal":{"tmp":"tmp/lz4-lite_1.0.0_1781734524058_0.09704352567645746","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"lz4-lite","version":"1.1.0","keywords":["lz4","lz4js","compression","decompression","codec","typescript","frame","block","zero-dependency"],"author":{"name":"Alexander Vukov"},"license":"MIT","_id":"lz4-lite@1.1.0","maintainers":[{"name":"alex-vukov","email":"alexvukov@gmail.com"}],"dist":{"shasum":"447706d9f9abaaa8c8080b38fdfc8d03ee429c69","tarball":"https://registry.npmjs.org/lz4-lite/-/lz4-lite-1.1.0.tgz","fileCount":24,"integrity":"sha512-jiuKRqW1IMWPjqntOWO6wp7FAcLlzP7qcbTRLlx6RIDjT0rVT+kDAsrP2cRzHvbiTZJLU+RwJ6TBkyzv3c5rpw==","signatures":[{"sig":"MEUCIQCPZ3D0uHi8YPRgjxuXTmJqsV+oGODbWqTWXkKdsP6TwQIgVulFNd5NRAnfB0UOaoB9Ux3ohlvqOo/go+PyatpMX1s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":46492},"main":"./dist/cjs/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=14"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"4712555b703f5acf60b38f2ae8010287849a6389","scripts":{"lint":"biome check","test":"npm run build && node --import tsx --test test/*.test.ts","build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/fixup-dual.mjs","clean":"rm -rf dist","format":"biome format --write","lint:fix":"biome check --write","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run lint && npm run build"},"_npmUser":{"name":"alex-vukov","email":"alexvukov@gmail.com"},"_npmVersion":"11.9.0","description":"A lean, optimized, spec-compliant LZ4 (block + frame) codec in TypeScript — zero dependencies.","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.0","typescript":"^5.6.0","@types/node":"^22.0.0","@biomejs/biome":"2.5.0"},"_npmOperationalInternal":{"tmp":"tmp/lz4-lite_1.1.0_1781759863193_0.7589621028426208","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"lz4-lite","version":"1.1.1","keywords":["lz4","lz4js","compression","decompression","codec","typescript","frame","block","zero-dependency"],"author":{"name":"Alexander Vukov"},"license":"MIT","_id":"lz4-lite@1.1.1","maintainers":[{"name":"alex-vukov","email":"alexvukov@gmail.com"}],"homepage":"https://github.com/alex-vukov/lz4-lite#readme","bugs":{"url":"https://github.com/alex-vukov/lz4-lite/issues"},"dist":{"shasum":"891860ef3dc780dd5d03b0aff9687276d55acb44","tarball":"https://registry.npmjs.org/lz4-lite/-/lz4-lite-1.1.1.tgz","fileCount":24,"integrity":"sha512-yPMygYBI/d7s1usPJkwSCCcjDcsffAT0hChihc7SN6J5wLY2FVYf6fiaVwSgcDKU2xJm7OyMFgcBJiOH3cG+Vw==","signatures":[{"sig":"MEUCIQC0sCrRMEC8PAAZ82TNcdJ24/A50jhkSByRTyY89gMYdAIgZc1+sv6PL3omQCtUQvIn7c1aXR5OLaitCVo591/Jdzc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":46729},"main":"./dist/cjs/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/esm/index.js","engines":{"node":">=14"},"exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"gitHead":"77cbfab6004ea6492009e7ba089896ed0677afbe","scripts":{"lint":"biome check","test":"npm run build && node --import tsx --test test/*.test.ts","build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/fixup-dual.mjs","clean":"rm -rf dist","format":"biome format --write","lint:fix":"biome check --write","build:cjs":"tsc -p tsconfig.cjs.json","build:esm":"tsc -p tsconfig.esm.json","build:types":"tsc -p tsconfig.types.json","prepublishOnly":"npm run lint && npm run build"},"_npmUser":{"name":"alex-vukov","email":"alexvukov@gmail.com"},"repository":{"url":"git+https://github.com/alex-vukov/lz4-lite.git","type":"git"},"_npmVersion":"11.9.0","description":"A lean, optimized, spec-compliant LZ4 (block + frame) codec in TypeScript — zero dependencies.","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.0","typescript":"^5.6.0","@types/node":"^22.0.0","@biomejs/biome":"2.5.0"},"_npmOperationalInternal":{"tmp":"tmp/lz4-lite_1.1.1_1781766620016_0.21973240445239273","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"lz4-lite","version":"1.1.2","description":"A lean, optimized, spec-compliant LZ4 (block + frame) codec in TypeScript — zero dependencies.","license":"MIT","author":{"name":"Alexander Vukov"},"keywords":["lz4","lz4js","compression","decompression","codec","typescript","frame","block","zero-dependency"],"type":"module","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","exports":{".":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"engines":{"node":">=14"},"sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/alex-vukov/lz4-lite.git"},"bugs":{"url":"https://github.com/alex-vukov/lz4-lite/issues"},"homepage":"https://github.com/alex-vukov/lz4-lite#readme","scripts":{"clean":"rm -rf dist","build:esm":"tsc -p tsconfig.esm.json","build:cjs":"tsc -p tsconfig.cjs.json","build:types":"tsc -p tsconfig.types.json","build":"npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/fixup-dual.mjs","lint":"biome check","lint:fix":"biome check --write","format":"biome format --write","test":"npm run build && node --import tsx --test test/*.test.ts","prepublishOnly":"npm run lint && npm run build"},"devDependencies":{"@biomejs/biome":"2.5.0","@types/node":"^22.0.0","tsx":"^4.19.0","typescript":"^5.6.0"},"gitHead":"f9591b74b0d6e5359dd9d00a4ada495039f04459","_id":"lz4-lite@1.1.2","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-B04n18eKpt4tH8WGVxwVrBW3eUL7Fj7J1EVbg/FPENTh7wF/95WGOFcbdQunSoidD3QdL59ZCRMGnu6cD8Xf/w==","shasum":"68f1195fb0de1facf24190e62883eef4d6686a0a","tarball":"https://registry.npmjs.org/lz4-lite/-/lz4-lite-1.1.2.tgz","fileCount":24,"unpackedSize":46807,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDhIthCR0mYgZCWVrs/wI3xzzNSr6jLT08PjVlt+vEhiAIgevahYid6kv/2h9IsxJtjmAVepvoTnmVDIekFNc9GItI="}]},"_npmUser":{"name":"alex-vukov","email":"alexvukov@gmail.com"},"directories":{},"maintainers":[{"name":"alex-vukov","email":"alexvukov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lz4-lite_1.1.2_1783106669785_0.7747501173684361"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-17T22:15:23.994Z","modified":"2026-07-03T19:24:30.026Z","1.0.0":"2026-06-17T22:15:24.196Z","1.1.0":"2026-06-18T05:17:43.336Z","1.1.1":"2026-06-18T07:10:20.136Z","1.1.2":"2026-07-03T19:24:29.912Z"},"bugs":{"url":"https://github.com/alex-vukov/lz4-lite/issues"},"author":{"name":"Alexander Vukov"},"license":"MIT","homepage":"https://github.com/alex-vukov/lz4-lite#readme","keywords":["lz4","lz4js","compression","decompression","codec","typescript","frame","block","zero-dependency"],"repository":{"type":"git","url":"git+https://github.com/alex-vukov/lz4-lite.git"},"description":"A lean, optimized, spec-compliant LZ4 (block + frame) codec in TypeScript — zero dependencies.","maintainers":[{"name":"alex-vukov","email":"alexvukov@gmail.com"}],"readme":"# LZ4 Lite\n\nA lean, **spec-compliant** [LZ4](https://lz4.org) codec (block + frame) in\nTypeScript. Zero dependencies, dual **ESM + CommonJS** builds with type\ndeclarations.\n\nInspired by [`lz4js`](https://github.com/Benzinga/lz4js) — a faster, clean\nreimplementation that fixes the bugs which made some `lz4js` output fail to decode\nin the reference LZ4 tools. Fully interoperable with `lz4` / `lz4c` / `liblz4`: they\ndecode the frames it produces, and it decodes theirs.\n\n## Install\n\n```sh\nnpm install lz4-lite\n```\n\n## Usage\n\n```ts\nimport { compress, decompress } from 'lz4-lite';\n\nconst data = new TextEncoder().encode('hello hello hello world');\nconst frame = compress(data);     // Uint8Array — a complete LZ4 frame\nconst back = decompress(frame);   // Uint8Array — === data\n```\n\nCommonJS: `const { compress, decompress } = require('lz4-lite');`\n\n## API\n\n`Uint8Array` in, `Uint8Array` out — no caller-managed buffers or hash tables.\n\n| Function | Description |\n| --- | --- |\n| `compress(src)` | Compress to a complete LZ4 frame. |\n| `decompress(src, maxSize?)` | Decompress a frame (`maxSize` is an optional output-size hint). |\n| `compressBlock(src)` | Compress a single raw block (no frame header). |\n| `decompressBlock(block, size)` | Decompress a raw block into `size` bytes. |\n| `compressBound(n)` / `decompressBound(src)` | Size bounds. |\n\nLow-level zero-allocation `*Into` primitives and `makeBuffer` are also exported for\nadvanced use.\n\n## Benchmark\n\nThroughput vs `lz4js` (tinybench harness, Node 24; ±10–15% run-to-run).\n\n| data | compress | decompress |\n| --- | --- | --- |\n| text / JSON / source | 1.5–1.9× | ~1× |\n| repetitive / incompressible | 2.0–3.0× | 5–6× |\n\n`lz4-lite` compresses faster across the board; decompression is on par for\ntext/JSON and several times faster on repetitive or incompressible data.\n\n## Migrating from `lz4js`\n\n**Frame functions** keep the same call shape — just drop the `lz4.` prefix:\n`compress`, `decompress`, `compressBound`, `decompressBound`, `makeBuffer`.\n\n**Block functions** are simpler — `lz4-lite` drops the caller-managed buffer,\noffsets, and hash table; each call returns its result:\n\n| `lz4js` | `lz4-lite` |\n| --- | --- |\n| `n = lz4.compressBlock(src, dst, 0, src.length, hashTable)` | `block = compressBlock(src)` |\n| `lz4.decompressBlock(src, out, 0, src.length, 0)` | `out = decompressBlock(block, size)` |\n\nNote `decompressBlock`'s second argument is the decompressed **output size**, not a\nsource length. Also, `compressBlock` always emits a valid block — even for inputs\nunder 13 bytes, where `lz4js` returned an empty result.\n\n## Format notes\n\n- Emits version-01 frames with **independent** 4 MiB blocks and only the header\n  checksum (xxHash32).\n- The decoder is lenient: it reads content/block checksums and linked-block frames\n  when present.\n- Fast compression only — no HC mode, dictionaries, or streaming.\n\n## License\n\nMIT © 2026 Alex Vukov. Clean implementation from the published LZ4 specifications;\nno third-party source was copied. See [LICENSE](./LICENSE) and [NOTICE](./NOTICE).\n","readmeFilename":"README.md"}