@scayle/unstorage-compression-driver
Version:
Compression driver for unstorage
196 lines (103 loc) • 5.99 kB
Markdown
# @scayle/unstorage-compression-driver
## 1.5.0
### Minor Changes
- Added optional `params` field on `CompressionDriverOptions`, plus a third `params` argument on the exported `compress` and `decompress` functions. The value is passed verbatim as the second argument to Node's `zlib.brotliCompress` / `zlib.brotliDecompress` / `zlib.gzip` / `zlib.deflate`. Omitting `params` for non-brotli encodings preserves the previous behaviour byte-for-byte.
```ts
import zlib from "node:zlib";
compressionDriver({
encoding: "brotli",
params: { params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 11 } },
passthroughDriver,
});
```
**Behavior change for brotli encoding:** when `params` is omitted, the driver now defaults to brotli quality 6 (matches Node's newer `zlib.compressBrotli` API and is the recommended setting for streaming workloads). The previous default . set indirectly through Node's legacy `zlib.brotliCompress` API . was quality 11, which targets offline/build-time compression and is ~300x slower to encode for negligible storage benefit on JSON-shaped payloads.
This is a runtime behavior change but not a contract change: decompression of pre-existing brotli-encoded entries (cached at quality 11) still works . brotli is self-describing on the decoder side, and quality is encode-only. Callers who relied on byte-exact brotli output will see different bytes; pass `params: { params: { [BROTLI_PARAM_QUALITY]: 11 } }` to restore the prior output.
## 1.4.1
### Patch Changes
- Migrate build toolchain from unbuild to obuild.
## 1.4.0
### Minor Changes
- All packages now require Node.js 22 or later, in line with the current Node.js LTS release schedule. See the [Node.js release schedule](https://nodejs.org/en/about/previous-releases#release-schedule) for details.
If your project is still running an older Node.js version, now is a good time to upgrade to Node.js 22 at minimum, or ideally Node.js 24, for the latest security patches and stability improvements.
## 1.3.0
### Minor Changes
- Fixed an issue where the compression driver would return `undefined` when an item was not found. The driver now correctly returns `null` when the key does not exist, as required by the unstorage driver specification. See: https://unstorage.unjs.io/guide#getitemkey-opts
## 1.2.5
### Patch Changes
- Updated dependency `@opentelemetry/api@^1.9.0` to `@opentelemetry/api@catalog:`
- Updated dependency `unstorage@1.17.3` to `unstorage@catalog:`
- This is an internal change only. The packages now use the PNPM catalog feature to ensure dependencies use the identical version across packages.
## 1.2.4
### Patch Changes
- Updated dependency `unstorage@1.17.2` to `unstorage@1.17.3`
## 1.2.3
### Patch Changes
- Updated dependency `unstorage@1.17.1` to `unstorage@1.17.2`
## 1.2.2
### Patch Changes
- Cleaned up README.md and added CONTRIBUTING.md. No functional changes.
## 1.2.1
### Patch Changes
- Updated dependency `unstorage@1.17.0` to `unstorage@1.17.1`
## 1.2.0
### Minor Changes
- Added optional OpenTelemetry tracing around compression and decompression events. To enable this feature, add the buildtime environment variable `UNSTORAGE_COMPRESSION_OTEL_TRACE=true`.
### Patch Changes
- Added dependency `@opentelemetry/api@^1.9.0`
## 1.1.0
### Minor Changes
- Removed `destr` as dependency and and replaced its usage with `JSON.parse` for string to object parsing.
Depending on the payload size, this should have marginal positive impact on the overall parsing performance.
This is an internal refactoring and does not affect usage.
### Patch Changes
- Removed dependency `destr@2.0.5`
## 1.0.2
### Patch Changes
- Updated dependency `unstorage@1.16.1` to `unstorage@1.17.0`
## 1.0.1
### Patch Changes
- Updated dependency `unstorage@1.16.0` to `unstorage@1.16.1`
## 1.0.0
### Major Changes
- Drop CommonJS support. The package is now ESM-only. If you are using this package in a Nuxt 3 context, you should have no issues.
## 0.2.7
### Patch Changes
- Updated dependency `unstorage@1.15.0` to `unstorage@1.16.0`
## 0.2.6
### Patch Changes
- Updated dependency `destr@2.0.3` to `destr@2.0.5`
## 0.2.5
### Patch Changes
- Updated dependency `destr@2.0.3` to `destr@2.0.5`
## 0.2.4
### Patch Changes
- Updated dependency `unstorage@1.14.4` to `unstorage@1.15.0`
## 0.2.3
### Patch Changes
- Updated dependency `unstorage@1.14.0` to `unstorage@1.14.4`
## 0.2.2
### Patch Changes
- Updated dependency `unstorage@1.13.1` to `unstorage@1.14.0`
## 0.2.1
### Patch Changes
- Fix publishing error which caused some files to be missing
## 0.2.0
### Minor Changes
- Resolved warnings with the types and exports configuration reported by `AreTheTypesWrong`[https://github.com/arethetypeswrong/arethetypeswrong.github.io]. This was done as a preventative measure to protect against potential ESM or TypeScript issues.
Additionally, we now build the library with `unbuild` rather than `tsc`.
This is essentially an internal refactor and should have no user-visible changes. However, as part of this change, the `compression` and `types` export configurations were removed from `package.json`. The exports were unused, but are mentioned here as it could possibly result in a breaking change.
## 0.1.5
### Patch Changes
- Updated dependency `unstorage@1.12.0` to `unstorage@1.13.1`
## 0.1.4
### Patch Changes
- Updated dependency `unstorage@1.10.2` to `unstorage@1.12.0`
## 0.1.3
### Patch Changes
- Format code with dprint
## 0.1.2
### Patch Changes
- Removed unnecessary warning message that indicated that no cache value has been available
## 0.1.1
### Patch Changes
- Introduce `@scayle/unstorage-compression-driver` package as custom [unstorage](https://unstorage.unjs.io/) driver. It allows to compress values with `deflate`, `gzip` or `brotli` using `node:zlib` while passing the data source handling to a generic supported driver like `redis` or `Vercel KV`.