Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
stream-promise
Advanced tools
So it can be consumed both as a promise and as a stream
npm install stream-promise
Stream must be either readable or writable.
In case of readable streams, promise resolves with concatenated output, in case of writable streams resolve with undefined
To achieve expected result stream should be converted immediately after initialization.
const streamPromise = require("stream-promise");
streamPromise(someReadableStream);
someReadableStream.then(result => { console.log("Concatenated stream output", result); });
streamPromise(someWritabletream);
someReadableStream.then(result => { console.log("Cumulated stream output", result); });
Already emitted data is accessible at emittedData
property
Sepearate promise (without touching stream object) can be created with to-promise
util:
const streamToPromise = require("stream-promise/to-promise");
const someReadableStreamPromise = streamPromiseTo(someReadableStream);
someReadableStreamPromise.then(result => { console.log("Concatenated stream output", result); });
boolean
(default: false
)Applicable to readable streams. Set to true, if it's not intended to gather stream result and resolve with it.
Then the only purpose of promise would be to indicate a moment when data stream is finalized
npm test
FAQs
Promise that shares Node.js Stream interface
The npm package stream-promise receives a total of 722,004 weekly downloads. As such, stream-promise popularity was classified as popular.
We found that stream-promise demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.