This project is part of the @thi.ng/umbrella monorepo.
Range encoder / decoder for binary data, based on Java implementation by Joe Halliwell.
yarn add @thi.ng/range-coder
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);
- Karsten Schmidt
© 2017 Karsten Schmidt // Apache Software License 2.0