continued dep injectiong
This commit is contained in:
@@ -1,27 +1,10 @@
|
||||
const streamToBuffer = (stream: any, allStreamsToErrorCatch: any[]) => {
|
||||
|
||||
const chunks: any[] = []
|
||||
const streamToBuffer = (stream: any) => {
|
||||
return new Promise<Buffer>((resolve, reject) => {
|
||||
const chunks: any[] = [];
|
||||
stream.on("data", (chunk: any) => chunks.push(chunk));
|
||||
stream.on("error", reject);
|
||||
stream.on("end", () => resolve(Buffer.concat(chunks)));
|
||||
});
|
||||
};
|
||||
|
||||
allStreamsToErrorCatch.forEach((currentStream) => {
|
||||
|
||||
currentStream.on("error", (e: Error) => {
|
||||
|
||||
console.log("Stream To Buffer Error", e);
|
||||
reject({
|
||||
message: "stream to buffer error",
|
||||
code: 500,
|
||||
error: e
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
stream.on('data', (chunk: any) => chunks.push(chunk));
|
||||
stream.on('error', reject);
|
||||
stream.on('end', () => resolve(Buffer.concat(chunks)));
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
export default streamToBuffer;
|
||||
export default streamToBuffer;
|
||||
|
||||
Reference in New Issue
Block a user