UNPKG

@tak-ps/node-tak

Version:

Lightweight JavaScript library for communicating with TAK Server

11 lines (9 loc) 425 B
import { Stream } from 'node:stream'; export default async function stream2buffer(stream: Stream): Promise<Buffer> { return new Promise<Buffer>((resolve, reject) => { const _buf = Array<Buffer>(); stream.on("data", chunk => _buf.push(chunk)); stream.on("end", () => resolve(Buffer.concat(_buf))); stream.on("error", (err: Error) => reject(`error converting stream - ${err}`)); }); }