fix(ziptools,gziptools): Use fflate synchronous APIs for ZIP and GZIP operations for Deno compatibility; add TEntryFilter type and small docs/tests cleanup

This commit is contained in:
2025-11-25 13:37:27 +00:00
parent 5cc030d433
commit 11bbddc763
12 changed files with 1300 additions and 795 deletions

View File

@@ -118,26 +118,21 @@ export class GzipTools {
/**
* Compress data asynchronously
* Note: Uses sync version for Deno compatibility (fflate async uses Web Workers
* which have issues in Deno)
*/
public async compress(data: Buffer, level?: TCompressionLevel): Promise<Buffer> {
return new Promise((resolve, reject) => {
const options = level !== undefined ? { level } : undefined;
plugins.fflate.gzip(data, options as plugins.fflate.AsyncGzipOptions, (err, result) => {
if (err) reject(err);
else resolve(Buffer.from(result));
});
});
// Use sync version wrapped in Promise for cross-runtime compatibility
return this.compressSync(data, level);
}
/**
* Decompress data asynchronously
* Note: Uses sync version for Deno compatibility (fflate async uses Web Workers
* which have issues in Deno)
*/
public async decompress(data: Buffer): Promise<Buffer> {
return new Promise((resolve, reject) => {
plugins.fflate.gunzip(data, (err, result) => {
if (err) reject(err);
else resolve(Buffer.from(result));
});
});
// Use sync version wrapped in Promise for cross-runtime compatibility
return this.decompressSync(data);
}
}