read-only-stream

WebJar for read-only-stream

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

read-only-stream
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

read-only-stream
WebJar for read-only-stream
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/substack/read-only-stream

Download read-only-stream

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/read-only-stream/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>read-only-stream</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/read-only-stream/
implementation 'org.webjars.npm:read-only-stream:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/read-only-stream/
implementation ("org.webjars.npm:read-only-stream:2.0.0")
'org.webjars.npm:read-only-stream:jar:2.0.0'
<dependency org="org.webjars.npm" name="read-only-stream" rev="2.0.0">
  <artifact name="read-only-stream" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='read-only-stream', version='2.0.0')
)
libraryDependencies += "org.webjars.npm" % "read-only-stream" % "2.0.0"
[org.webjars.npm/read-only-stream "2.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : readable-stream jar [2.0.2,3)

Project Modules

There are no modules declared in this project.

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

Versions

Version
2.0.0
1.1.1