fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
27 lines (26 loc) • 746 B
JavaScript
import fs from 'fs';
import { Transform } from 'stream';
import oo from 'on-one';
let PathToData = class PathToData extends Transform {
_transform(chunk, _encoding, callback) {
const self = this;
const fullPath = typeof chunk === 'string' ? chunk : chunk.toString();
const stream = fs.createReadStream(fullPath);
stream.on('data', function data(chunk) {
self.push(chunk, 'buffer');
});
oo(stream, [
'error',
'end',
'close',
'finish'
], (err)=>{
!err || self.push(null);
callback(err);
});
}
constructor(options){
super(options || {});
}
};
export { PathToData as default };