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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user