Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 33x 33x 6x 10x 10x 3x 3x 3x 3x 3x 7x 7x 7x | import { createReadStream } from 'fs' import { Collection } from '..' import { TarStream } from './tar' export async function writeTar(collection: Collection, tarStream: TarStream) { for (const item of collection) { tarStream.beginFile(item.path, item.size) if (item.fsPath) { const stream = createReadStream(item.fsPath) for await (const chunk of stream) { await tarStream.appendFile(chunk) } await tarStream.endFile() stream.close() } else if (item.file) { await tarStream.appendFile(new Uint8Array(await item.file.arrayBuffer())) await tarStream.endFile() } else E{ throw new Error('Invalid collection item') } } } |