Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
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.
read-only-stream
Advanced tools
wrap a readable/writable stream to be read-only to prevent mucking up the input side
Suppose you have a module that uses a readable/writable stream internally but want to expose just the readable part of that internal stream. This is common if you use the writable side internally and expose the readable side as the interface.
Now we can write some code like this with a through
stream internally for
convenience:
var through = require('through2');
var readonly = require('read-only-stream');
module.exports = function () {
var stream = through();
stream.end('wooooo\n');
return readonly(stream);
};
but consumers won't be able to write to the input side and break the api:
var wrap = require('./wrap.js');
var ro = wrap(); // can't write to `ro` and muck up internal state
ro.pipe(process.stdout);
var readonly = require('read-only-stream')
Return a readable stream ro
that wraps the readable/writable stream
argument
given to only expose the readable side.
stream
can be a streams1 or streams2 stream.
With npm do:
npm install read-only-stream
MIT
FAQs
wrap a readable/writable stream to be read-only
We found that read-only-stream 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
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.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.