Tiny JS compression/decompression library using `CompressionStream`s
npm install @shgysk8zer0/squishTiny JS compression/decompression library using CompressionStream

!Node CI
!Lint Code Base





!node-current
!npm bundle size gzipped


!GitHub forks
!GitHub stars


- - -
- Code of Conduct
- Contributing
Squish is a tiny JavaScript library that provides functionalities for efficient data compression and decompression. It supports various input and output formats, making it a versatile tool for optimizing data transmission and storage.
* Highly Compressed: The library itself is minified and compressed to an exceptionally small size, minimizing its footprint in your project.
* Versatile Input: Accepts a wide range of input data types, including ReadableStream, ArrayBuffer, Uint8Array, Blob, Response, Request, and even strings.
* Compression Algorithms: Supports both gzip and deflate compression algorithms, providing flexibility for different use cases.
* Decompression: Decompresses data compressed with gzip and deflate algorithms.
* Rich Output Formats: Offers a variety of output formats, including blob, stream, response, buffer, bytes, hex, base64, base64url, url, and text.
You can install the library using npm or by importing from a CDN such as unpkg.com:
``bash@shgysk8zer0/squish
npm install `
or with a
`
The library provides several functions for compression and decompression:
- compress(data, options): Compresses the given data using the specified options.decompress(data, options)
- : Decompresses the given data using the specified options.gzip(data, options)
- : Compresses the data using the gzip algorithm.gunzip(data, options)
- : Decompresses the data compressed with gzip.deflate(data, options)
- : Compresses the data using the deflate algorithm.inflate(data, options)
- : Decompresses the data compressed with deflate.
`js
import { gzip, gunzip } from '@shgysk8zer0/squish';
const compressed = await gzip('Hello, World!');
const decompressed = await gunzip(compressed, { output: 'text' });
`
`js
const { inflate } = require('@shgysk8zer0/squish');
const { readFile } = require('node:js');
async function sendFile(file) {
const buffer = readFile(file);
const compressed = await inflate(buffer);
return new Response(compressed);
}
`
This library requires many new features that are not yet wideley supported. A polyfill is provided in node,
but you may want to proved your own for certain usages in browsers.
- CompressionStream
- DecompressionStream
- Unit8Array.prototype.toBase64
- Uint8Array.prototype.toHex
- Response.prototype.bytes`