Skip to content

A tiny (150 bytes) binary run-length encoding (RLE) packer/unpacker

License

Notifications You must be signed in to change notification settings

shevchenkonik/rle-data

Repository files navigation

Run-length encoding

A tiny (150 bytes) binary run-length encoding (RLE) packer/unpacker

CircleCI codecov GitHub

The article about Run Length Algorithm is here. My usecase of rle-data is create binary matrix for image segmentation (Canvas) to reduce data size.

Encoding format

Incoming data

[0, 0, 0, 0, 0, 1, 1, 0, 0];

Outgoing data

[5, 0, 2, 1, 2, 0];

Decoding format

Incoming data

[4, 0, 4, 1, 3, 0];

Outgoing data

[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0];

Installation

npm i rle-data

API

let rle = require("rle-data");

rle.encode([0, 0, 0, 0, 0, 1, 1, 0, 0]);
rle.decode([4, 0, 4, 1, 3, 0]);

Roadmap

  • Add other formats to compression
  • Use smart data compression
  • R&D best practices of RLE

About

A tiny (150 bytes) binary run-length encoding (RLE) packer/unpacker

Resources

License

Stars

Watchers

Forks

Packages

No packages published