@scayle/unstorage-compression-driver
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@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.

...

Readme

Keywords

none

Package Sidebar

Install

npm i @scayle/unstorage-compression-driver

Weekly Downloads

1,170

Version

0.1.3

License

MIT

Unpacked Size

11.4 kB

Total Files

12

Last publish

Collaborators

  • scayle-automation
  • hector_gonzalez_ay
  • ay-henribeck
  • cloud-panel-ay
  • kyosifov
  • marcel-domke-ay
  • louisa_schmidt_ay
  • connor-pearson-ay