Compression driver for unstorage
npm install @scayle/unstorage-compression-driver[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
Compression driver for unstorage.
``bashUsing pnpm
pnpm add @scayle/unstorage-compression-driver
Usage
This is a special driver that handles (de)compression of values.
All write operations happen within a dedicated passthrough driver, that handles all storage functionality.
In the example below, we create an
redis passthrough driver and select brotli as encoding / compression algorithm.`ts
import { createStorage } from "unstorage";
import compressionDriver from "@scayle/unstorage-compression-driver";
import redisDriver from "unstorage/drivers/redis";const storage = createStorage({
driver: overlay({
encoding: 'brotli'
passthroughDriver: redisDriver({
host: 'localhost',
port: '6379'
}),
}),
});
`> NOTE: As this is the first iteration of the compression driver,
> it currently does not support passing encoding options to the selected encoding method!
Supported Compression Algorithms
The
@scayle/unstorage-compression-driver currently supports deflate, gzip and brotli as compression algorithms.> NOTE: If this driver will be used outside of a Node.js-based runtime,
> it needs to be checked if the desired runtime supports or polyfills
node:zlib,
> as the compression implementation is depending on node:zlib`!Using zlib.deflate
and zlib.unzip.
Using zlib.gzip
and zlib.unzip.
Using zlib.brotliCompress
and zlib.brotliDecompress.
Licensed under the MIT License