https://github.com/commenthol/streamss-readonly
Make streams2 readonly
https://github.com/commenthol/streamss-readonly
readonly stream2
Last synced: 3 months ago
JSON representation
Make streams2 readonly
- Host: GitHub
- URL: https://github.com/commenthol/streamss-readonly
- Owner: commenthol
- License: mit
- Created: 2015-01-08T22:05:03.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-10-10T05:37:56.000Z (almost 4 years ago)
- Last Synced: 2025-06-29T23:38:06.258Z (3 months ago)
- Topics: readonly, stream2
- Language: JavaScript
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# streamss-readonly
> Make streams2 read-only
[](https://www.npmjs.com/package/streamss-readonly/)
[](https://travis-ci.org/commenthol/streamss-readonly)Wraps any kind of stream to behave like a [Readable][] Stream. This is a pure Stream2 implementation which respects `highWaterMark` and saturation of piped streams.
Works with node v0.8.x and greater.
For node v0.8.x the user-land copy [readable-stream][] is used.
For all other node versions greater v0.8.x the built-in `stream` module is used.Credits go to [read-only-stream][].
### Example
``` javascript
let through = require('streamss').Through
let readonly = require('streamss-readonly')let th = through()
let ro = readonly(th)ro.pipe(process.stdout)
th.write('hello world')// ro.write('this throws')
```## Methods
### readonly(stream)
> Converts any stream into a read-only stream
**Parameters:**
- `{Readable | Transform | Duplex} stream` - A stream which shall behave as a Readable only stream.
**Return:**
`{Readable}` - A read-only readable stream
**Throws:**
- `{Error}` "not a readable stream" - if stream does not implement a Readable component this error is thrown
## Contribution and License Agreement
If you contribute code to this project, you are implicitly allowing your
code to be distributed under the MIT license. You are also implicitly
verifying that all code is your original work or correctly attributed
with the source of its origin and licence.### npm scripts
* `npm test` - Run tests
* `npm run cover` - Run istanbul code coverage (shows code coverage; open ./coverage/lcov-report/index.html after run)
* `npm run lint` - Linting the source
* `npm run doc` - Generate documentation from source (open ./doc/index.html after run)## License
Copyright (c) 2015- commenthol (MIT License)
See [LICENSE][] for more info.
[LICENSE]: ./LICENSE
[read-only-stream]: https://github.com/substack/read-only-stream
[Readable]: http://nodejs.org/api/stream.html#stream_class_stream_readable
[readable-stream]: https://github.com/isaacs/readable-stream