fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
1 lines • 2.8 kB
Source Map (JSON)
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/fast-extract/src/streams/transforms/WriteFile.mjs"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { Transform } from 'stream';\nimport mkdirp from 'mkdirp-classic';\nimport tempSuffix from 'temp-suffix';\n\nexport default class WriteFileTransform extends Transform {\n constructor(dest, options) {\n options = options ? { ...options, objectMode: true } : { objectMode: true };\n super(options);\n this.tempPath = tempSuffix(dest);\n options._tempPaths.push(this.tempPath);\n }\n\n _transform(chunk, encoding, callback) {\n if (this.stream)\n return this.stream.write(chunk, encoding, () => {\n callback();\n });\n mkdirp(path.dirname(this.tempPath), (err) => {\n if (err) return callback(err);\n this.stream = fs.createWriteStream(this.tempPath, { flags: 'w' });\n this.stream.write(chunk, encoding, () => {\n callback();\n });\n });\n }\n\n _flush(callback) {\n if (!this.stream) return callback();\n this.stream.end(() => {\n this.stream = null;\n this.push(this.tempPath);\n this.push(null);\n callback();\n });\n }\n\n destroy(err) {\n if (this.stream) {\n this.stream.end(err);\n this.stream = null;\n }\n }\n}\n"],"names":["WriteFileTransform","dest","options","objectMode","tempPath","tempSuffix","_tempPaths","push","_transform","chunk","encoding","callback","stream","write","mkdirp","path","dirname","err","fs","createWriteStream","flags","_flush","end","destroy","Transform"],"mappings":";;;;;;;eAMqBA;;;yDANN;2DACE;sBACS;oEACP;iEACI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAER,IAAA,AAAMA,mCAAN;;cAAMA;aAAAA,mBACPC,IAAI,EAAEC,OAAO;gCADNF;;QAEjBE,UAAUA,UAAU,wCAAKA;YAASC,YAAY;aAAS;YAAEA,YAAY;QAAK;gBAC1E,kBAHiBH;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