https://github.com/fabiospampinato/huffy
A tiny compression library based on Huffman coding.
https://github.com/fabiospampinato/huffy
coding compression decompression huffman tiny
Last synced: 11 months ago
JSON representation
A tiny compression library based on Huffman coding.
- Host: GitHub
- URL: https://github.com/fabiospampinato/huffy
- Owner: fabiospampinato
- License: mit
- Created: 2022-12-31T17:24:10.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-09-24T16:38:36.000Z (over 2 years ago)
- Last Synced: 2024-11-29T21:45:31.913Z (over 1 year ago)
- Topics: coding, compression, decompression, huffman, tiny
- Language: TypeScript
- Homepage:
- Size: 21.5 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Huffy
A tiny compression library based on Huffman coding.
## Install
```sh
npm install huffy
```
## Usage
```ts
import {compress, decompress} from 'huffy';
// Let's make some data to compress
const str = 'some string to compress, it works better with longer things'.repeat ( 10 );
const buffer = new TextEncoder ().encode ( str );
// Let's compress and decompress it
const compressed = compress ( buffer );
const decompressed = decompress ( compressed );
// Let's print the compression ratio
console.log ( 'Compression ratio:', compressed.length / buffer.length );
```
## License
MIT © Fabio Spampinato