
Product
Introducing Immutable Scans
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.
stream-write
Advanced tools
Write to streams, respecting backpressure.
Write random numbers to an http response until it ends:
import write from 'stream-write'
import http from 'node:http'
http.createServer((req, res) => {
(async () => {
while (true) {
const isOpen = await write(res, String(Math.random()))
if (!isOpen) break
}
})().catch(console.error)
}).listen(8000)
Write chunk to stream and returns a Promise that is resolved once stream is writable again, or rejects if an error happened.
The promise's resolved value is false when stream ended and you should stop writing to it.
When an HTTP request ended, the HTTP response stays writable, only it's
underlying socket closes. To stay consistent with other streams' behavior,
in that case write() will throw an error itself.
$ npm install stream-write
MIT
FAQs
Write to a stream promise style
The npm package stream-write receives a total of 85 weekly downloads. As such, stream-write popularity was classified as not popular.
We found that stream-write 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.

Product
Scan results now load faster and remain consistent over time, with stable URLs and on-demand rescans for fresh security data.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.