@btc-vision/transaction
Version:
OPNet transaction library allows you to create and sign transactions for the OPNet network.
25 lines • 831 B
JavaScript
import zlib, {} from 'zlib';
/** Compressor class for compressing and decompressing data. */
export class Compressor {
static zlibOptions = {
level: 9,
maxOutputLength: 1024 * 1024 * 16, // 16mb, limit it to 16mb.
};
/**
* Compresses the data using gzip.
* @param {Uint8Array} data The data to compress.
* @returns {Uint8Array} The compressed data.
*/
static compress(data) {
return new Uint8Array(zlib.gzipSync(data, Compressor.zlibOptions));
}
/**
* Decompresses the data using gunzip.
* @param {Uint8Array} data The data to decompress.
* @returns {Uint8Array} The decompressed data.
*/
static decompress(data) {
return new Uint8Array(zlib.gunzipSync(data, Compressor.zlibOptions));
}
}
//# sourceMappingURL=Compressor.js.map