mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-14 16:25:16 +00:00
17 lines
394 B
TypeScript
17 lines
394 B
TypeScript
import { Stream } from "stream";
|
|
|
|
export function streamToBuffer(stream: Stream): Promise<Buffer> {
|
|
let buffArr: any[] = [];
|
|
return new Promise((resolve, reject) => {
|
|
stream.on("data", (data) => {
|
|
buffArr.push(data);
|
|
});
|
|
stream.on("end", async () => {
|
|
resolve(Buffer.concat(buffArr));
|
|
});
|
|
stream.on("error", (error) => {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|