Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve) => {
createReadStream(filePath, {
flags: 'r',
// This is important because you don't want to encode the
// bytes if you are doing a binary check.
encoding: null,
autoClose: true,
}).pipe(
new FirstChunkStream({ chunkLength }, (_, enc) => {
resolve(enc);
})
);
});
}
zipfile.openReadStream(this.files[path], (err, readStream) => {
if (err) {
reject(err);
return;
}
readStream.pipe(
new FirstChunkStream({ chunkLength }, (_, enc) => {
resolve(enc);
})
);
});
});