Numeric array compressor Compression quality is ~ 2 times better than the original separator-separated sequence of numbers
Important! The algorithm works correctly when the range of numbers in the array is from 0 to 1000.
Implementation of the "universal" algorithm (Needs some improvement) https://github.com/DjonnyX/numeric-sequence-compressor/tree/universal
Install
npm i numeric-sequence-compressor
Import dependency to Your project:
const { serialize, deserialize } = require('numeric-sequence-compressor');
Serialization (Compression):
const arr = [0, 100, 25, 7, 47, 666];
const compressed = serialize(arr);
console.log(compressed); // "0-34P7-1fkq"
Deserialization (Decompression):
const compressed = "0-34P7-1fkq";
const arr = deserialize(compressed);
console.log(arr); // "[0, 100, 25, 7, 47, 666]"
To run the benchmark with tests, run the command:
npm start
or
npm run test