tiny-huffman.js - huffman compression codec for tinyJS

tiny-huffman.js packs a Huffman (de)compression-Codec into the Object t.huffman, containing the Methods .enc(ode) and .dec(ode).

Download

tiny-huffman.js [3169b] - tiny-huffman-min.js.gz [693b]

Hint

The t.huffman-Codec requires only tiny.js. Other scripts are not necessary.

Usage

The Methods .enc and .dec take a string as argument and return the Huffman en- re decoded string.

Example

(function() {
    function test() {
        var data=t('#testinput').v(), to=t.huffman.enc(data), l=data.length, L=l+1, i=0;
        t('#to').h(to+' &#160; <b>'+((to.length*100/data.length)|0)+'%</b>');
        t('#re').h(t.huffman.dec(to));
    }
    t('#test').e('mousedown', test);
})();