Skip to content

scayle/unstorage-compression-driver

Repository files navigation

@scayle/unstorage-compression-driver

npm version npm downloads License

Compression driver for unstorage.

Installation

# Using pnpm
pnpm add @scayle/unstorage-compression-driver

# Using yarn
yarn add @scayle/unstorage-compression-driver

# Using npm
npm install @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.

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!

Deflate

Using zlib.deflate and zlib.unzip.

GZip

Using zlib.gzip and zlib.unzip.

Brotli

Using zlib.brotliCompress and zlib.brotliDecompress.

License

Licensed under the MIT License

About

Compression driver for unstorage

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •