Skip to content

Latest commit

 

History

History
 
 

range-coder

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

@thi.ng/range-coder

npm version npm downloads Mastodon Follow

Note

This is one of 199 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Binary range encoder / decoder, based on Java implementation by Joe Halliwell.

Status

STABLE - used in production

Search or submit any issues for this package

Related packages

  • @thi.ng/bitstream - ES6 iterator based read/write bit streams with support for variable word widths
  • @thi.ng/rle-pack - Binary run-length encoding packer w/ flexible repeat bit widths

Installation

yarn add @thi.ng/range-coder

ESM import:

import * as rc from "@thi.ng/range-coder";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/range-coder"></script>

JSDelivr documentation

For Node.js REPL:

const rc = await import("@thi.ng/range-coder");

Package sizes (brotli'd, pre-treeshake): ESM: 622 bytes

Dependencies

API

Generated API 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);

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-range-coder,
  title = "@thi.ng/range-coder",
  author = "Karsten Schmidt",
  note = "https://thi.ng/range-coder",
  year = 2017
}

License

© 2017 - 2024 Karsten Schmidt // Apache License 2.0