UNPKG

@alinex/datastore

Version:

Read, work and write data structures from and to differents locations and formats.

31 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.compress = exports.uncompress = void 0; const path_1 = require("path"); const debug_1 = require("debug"); const zlib = require("zlib"); const debug = debug_1.default("datastore:compression:deflate"); exports.uncompress = async function (parsedUri, buffer, options) { debug(`uncompressing ${path_1.basename(parsedUri.pathname)}`); return new Promise((resolve, reject) => { zlib.inflate(buffer, {}, function (error, result) { if (!error) resolve(result); else reject(error); }); }); }; exports.compress = async function (parsedUri, buffer, options) { debug(`compressing ${path_1.basename(parsedUri.pathname)}`); return new Promise((resolve, reject) => { zlib.deflate(buffer, { level: (options && options.compressionLevel) || 9 }, function (error, result) { debug("xxxxx", result, error); if (!error) resolve(result); else reject(error); }); }); }; //# sourceMappingURL=deflate.js.map