Skip to content

A tiny compression library based on Huffman coding.

License

Notifications You must be signed in to change notification settings

fabiospampinato/huffy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Huffy

A tiny compression library based on Huffman coding.

Install

npm install huffy

Usage

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