Node.js · Middle · Question 14 of 75
Why is stream.pipeline() preferred over chaining .pipe()?
- 1
.pipe()is deprecated and removed - 2
pipelinemakes the data move faster - ✓Correct answer: It forwards errors from any stream and destroys all streams on failure, so nothing leaks
Explanation
With .pipe() an error in one stream doesn't close the others. await pipeline(src, transform, dest) from node:stream/promises also works with async/await.