Binary range encoder / decoder, based on Java implementation by Joe Halliwell.
{{meta.status}}
{{repo.supportPackages}}
{{repo.relatedPackages}}
{{meta.blogPosts}}
{{pkg.install}}
{{pkg.size}}
{{pkg.deps}}
{{repo.examples}}
{{pkg.docs}}
import * as rc "@thi.ng/range-coder";
// prepare dummy data
src = new Uint8Array(1024);
src.set([1,1,1,1,1,2,2,2,2,3,3,3,4,4,5,4,4,3,3,3,2,2,2,2,1,1,1,1,1], 512);
// pack data
packed = rc.encodeBytes(src);
packed.length
// 146
packed.length/src.length
// 0.142578125
// unpack
dest = rc.decodeBytes(packed);