@confuzzle/move-to-front
v1.0.0
Published
naive Move-to-front transform
Downloads
8
Maintainers
Readme
@confuzzle/move-to-front
This package contains a naive, inefficient implementation of the Move-to-front transform.
For details of how this can be used together with the Burrows-Wheeler transform to improve compression, see this excellent blog post by Tommy Reddad.
See also
- @confuzzle/burrows-wheeler - naive Burrows-Wheeler transform implementation
- @thi.ng/range-coder - useful for compressing the transformed result
Functionality
This package provides two functions:
forward(s)
, which runsBuffer.from(s)
and performs the forward transform on the resultinverse(x)
, which runsBuffer.from(x)
performs the inverse transform on the result Both functions return aBuffer
object.
Example Usage
const mtf = require('@confuzzle/move-to-front');
const s = 'abracadabra';
const t = mtf.forward(s);
const inv = mtf.inverse(t).toString();
console.log(inv) // abracadabra