import type { SmartArchive } from './classes.smartarchive.js'; import * as plugins from './plugins.js'; export class TarTools { smartArchiveRef: SmartArchive; constructor(smartArchiveRefArg: SmartArchive) { this.smartArchiveRef = smartArchiveRefArg; } // packing public addFileToPack(pack: plugins.tarStream.Pack, fileName: string, content: string | Buffer) { return new Promise((resolve, reject) => { const entry = pack.entry({ name: fileName, size: content.length }, (err: Error) => { if (err) { reject(err); } else { resolve(); } }); entry.write(content); entry.end(); }); } public async getPackStream() { const pack = plugins.tarStream.pack(); return pack; } // extracting getDecompressionStream() { return plugins.tarStream.extract(); } }