Needlessly Postulating Minds

    @thi.ng/range-coder
    TypeScript icon, indicating that this package has built-in type declarations

    2.1.17 • Public • Published

    range-coder

    npm version npm downloads Twitter Follow

    This project is part of the @thi.ng/umbrella monorepo.

    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

    ES module import:

    <script type="module" src="https://cdn.skypack.dev/@thi.ng/range-coder"></script>

    Skypack documentation

    For Node.js REPL:

    # with flag only for < v16
    node --experimental-repl-await
    
    > const rangeCoder = await import("@thi.ng/range-coder");
    

    Package sizes (brotli'd, pre-treeshake): ESM: 618 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

    Karsten Schmidt

    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 - 2022 Karsten Schmidt // Apache Software License 2.0

    Install

    npm i @thi.ng/range-coder

    DownloadsWeekly Downloads

    38

    Version

    2.1.17

    License

    Apache-2.0

    Unpacked Size

    11.8 kB

    Total Files

    5

    Last publish

    Collaborators

    • thi.ng