https://github.com/gulpjs/to-through
Wrap a Readable stream in a Transform stream.
https://github.com/gulpjs/to-through
stream through transform
Last synced: 8 months ago
JSON representation
Wrap a Readable stream in a Transform stream.
- Host: GitHub
- URL: https://github.com/gulpjs/to-through
- Owner: gulpjs
- License: mit
- Created: 2017-05-02T20:35:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-04-06T00:42:27.000Z (about 3 years ago)
- Last Synced: 2025-10-12T03:21:35.635Z (9 months ago)
- Topics: stream, through, transform
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 10
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# to-through
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Wrap a `Readable` stream in a `Transform` stream.
## Usage
```js
var { Readable } = require('streamx');
var concat = require('concat-stream');
var toThrough = require('to-through');
var readable = Readable.from([' ', 'hello', ' ', 'world']);
// Can be used as a Readable or Transform
var maybeTransform = toThrough(readable);
Readable.from(['hi', ' ', 'there', ','])
.pipe(maybeTransform)
.pipe(
concat(function (result) {
// result === 'hi there, hello world'
})
);
```
## API
### `toThrough(readableStream)`
Takes a `Readable` stream as the only argument and returns a `Transform` stream wrapper. Any data
piped into the `Transform` stream is piped passed along before any data from the wrapped `Readable` is injected into the stream.
## License
MIT
[downloads-image]: https://img.shields.io/npm/dm/to-through.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/to-through
[npm-image]: https://img.shields.io/npm/v/to-through.svg?style=flat-square
[ci-url]: https://github.com/gulpjs/to-through/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/to-through/dev.yml?branch=master&style=flat-square
[coveralls-url]: https://coveralls.io/r/gulpjs/to-through
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/to-through/master.svg?style=flat-square