huffman-simple
v0.0.2
Published
Very simple, readable huffman encoding example
Downloads
5
Readme
Huffman-simple
Simple huffman coding implementation in Node.js Uses 281 code as escape char
Available at https://www.npmjs.com/package/huffman-simple
Usage
npm install huffman-simple
To encode a string:
const huffman = require('huffman-simple');
// convert to an array of ints
const arr = [...'<your string>'].map(char=>char.charCodeAt(0));
const encoded = huffman.encode(arr);
const decoded = huffman.decode(encoded);
const str = String.fromCharCode(...decoded);
Bugs
breaks for many cases: '9-qf;l1g4asr' 'qqqqqqqqqq'