README
Array Compression
Installation
npm install array-compression
Available Methods
Method | Description |
---|---|
create_1d | Creates a 1-Dimensional array |
create_2d | Creates a 2-Dimensional array |
create_3d | Creates a 3-Dimensional array |
compress | Compresses an array along with its metadata (optional) |
uncompress | Uncompresses the array to its original form |
Usage
const array = require("array-compression");
Creating a 1D array
Expected input : Array Size. The value field is optional, it can be an integer, string or list, if not provided an array will be populated with the default value - 0
size = INT
Value = (Optional)
array.create_1d(size, Value)
Creating a 2D array
Expected input : Height (x) and Width (y) of the array. The value field is optional, it can be an integer, string or list, if not provided an array will be populated with the default value - 0
height = INT
width = INT
Value = (Optional)
array.create_2d(height, width, Value)
Creating a 3D array
Expected input : Length (z), height (x) and Width (y) of the array. The value field is optional, it can be an integer, string or list, if not provided an array will be populated with the default value - 0
height = INT
width = INT
Value = (Optional)
array.create_3d(length, height, width, Value)
Compressing an Array
let input = array.create_3d(3, 2, 1);
let metadata = { test: "dummy data" }; // Optional field
array.compress(input, metadata).then(result => {
// returns an Array buffer
});
Uncompressing an Array
input = ARRAYBUFFER generated using the compress method
array.uncompress(input).then(uncompressed_data => {
/* returns
{
data: contains the uncompressed array
metadata: contains the associated metadata
}
*/
});