You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <p align="center">
  2. <a href="http://gulpjs.com">
  3. <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
  4. </a>
  5. </p>
  6. # to-through
  7. [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
  8. Wrap a ReadableStream in a TransformStream.
  9. ## Usage
  10. ```js
  11. var from = require('from2');
  12. var concat = require('concat-stream');
  13. var toThrough = require('to-through');
  14. var readable = from([' ', 'hello', ' ', 'world']);
  15. // Can be used as a Readable or Transform
  16. var maybeTransform = toThrough(readable);
  17. from(['hi', ' ', 'there', ','])
  18. .pipe(maybeTransform)
  19. .pipe(concat(function(result) {
  20. // result.toString() === 'hi there, hello world'
  21. }));
  22. ```
  23. ## API
  24. ### `toThrough(readableStream)`
  25. Takes a `readableStream` as the only argument and returns a `through2` stream. If the returned stream is piped before `nextTick`, the wrapped `readableStream` will not flow until the upstream is flushed. If the stream is not piped before `nextTick`, it is ended and flushed (acting as a proper readable).
  26. ## License
  27. MIT
  28. [downloads-image]: http://img.shields.io/npm/dm/to-through.svg
  29. [npm-url]: https://npmjs.com/package/to-through
  30. [npm-image]: http://img.shields.io/npm/v/to-through.svg
  31. [travis-url]: https://travis-ci.org/gulpjs/to-through
  32. [travis-image]: http://img.shields.io/travis/gulpjs/to-through.svg?label=travis-ci
  33. [appveyor-url]: https://ci.appveyor.com/project/gulpjs/to-through
  34. [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/to-through.svg?label=appveyor
  35. [coveralls-url]: https://coveralls.io/r/gulpjs/to-through
  36. [coveralls-image]: http://img.shields.io/coveralls/gulpjs/to-through/master.svg
  37. [gitter-url]: https://gitter.im/gulpjs/gulp
  38. [gitter-image]: https://badges.gitter.im/gulpjs/gulp.png