mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-13 07:26:26 +00:00
6ea0d5d6fb
Co-authored-by: Michael Kriese <michael.kriese@visualon.de> Co-authored-by: Sergei Zharinov <zharinov@users.noreply.github.com> Co-authored-by: Rhys Arkins <rhys@arkins.net>
14 lines
481 B
TypeScript
14 lines
481 B
TypeScript
import { Readable } from 'stream';
|
|
|
|
export async function streamToString(
|
|
stream: NodeJS.ReadableStream
|
|
): Promise<string> {
|
|
const readable = Readable.from(stream);
|
|
const chunks: Uint8Array[] = [];
|
|
const p = await new Promise<string>((resolve, reject) => {
|
|
readable.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
readable.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
readable.on('error', (err) => reject(err));
|
|
});
|
|
return p;
|
|
}
|