1. read-only-stream
wrap a readable/writable stream to be read-only
read-only-stream
Package: read-only-stream
Created by: substack
Last modified: Tue, 08 Nov 2022 10:40:25 GMT
Version: 2.0.0
License: MIT
Downloads: 4,037,354
Repository: https://github.com/substack/read-only-stream

Install

npm install read-only-stream
yarn add read-only-stream

read-only-stream

wrap a readable/writable stream to be read-only
to prevent mucking up the input side

build status

example

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);

methods

 var readonly = require('read-only-stream')

var ro = readonly(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.

install

With npm do:

npm install read-only-stream

license

MIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin