Skip to content

Instantly share code, notes, and snippets.

@JanMalch
Created January 9, 2023 21:57
Show Gist options
  • Save JanMalch/a08816038ac59bcea7c7fe0a2b836d48 to your computer and use it in GitHub Desktop.
Save JanMalch/a08816038ac59bcea7c7fe0a2b836d48 to your computer and use it in GitHub Desktop.
Node.JS async stream
import { promisify } from 'node:util';
import { pipeline } from 'node:stream';
export const asyncStream = promisify(pipeline);
await asyncStream(
Readable.fromWeb(request.body as ReadableStream),
createWriteStream(dest, { flags: 'a+', }),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment