https://github.com/fabiospampinato/tiny-compressor
A tiny isomorphic compression library that leverages CompressionStream and DecompressionStream.
https://github.com/fabiospampinato/tiny-compressor
compression decompression isomorphic stream tiny
Last synced: 9 months ago
JSON representation
A tiny isomorphic compression library that leverages CompressionStream and DecompressionStream.
- Host: GitHub
- URL: https://github.com/fabiospampinato/tiny-compressor
- Owner: fabiospampinato
- License: mit
- Created: 2023-01-20T00:59:04.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-20T01:38:30.000Z (over 1 year ago)
- Last Synced: 2025-04-04T04:34:01.677Z (about 1 year ago)
- Topics: compression, decompression, isomorphic, stream, tiny
- Language: TypeScript
- Homepage:
- Size: 8.79 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Tiny Compressor
A tiny isomorphic compression library that leverages [`CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) and [`DecompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream).
This library exists because compressing and decompressing a `Uint8Array` with `CompressionStream` and `DecompressionStream` directly is _extremely_ inconvenient to write.
## Install
```sh
npm install tiny-compressor
```
## Usage
```ts
import Compressor from 'tiny-compressor';
// Let's compress and decompress a Uint8Array
const buffer = new Uint8Array ([ 1, 2, 3, 4, 5 ]);
const compressed = await Compressor.compress ( buffer, 'gzip' );
const decompressed = await Compressor.decompress ( compressed, 'gzip' );
console.log ( decompressed ); // Uint8Array [ 1, 2, 3, 4, 5 ]
```
## License
MIT © Fabio Spampinato