Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

invert-stream

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Issues
File Explorer

Advanced tools

invert-stream

Create a pair of streams (A, B) such that `A.write(X) -> B.emit('data', X)` and `B.write(X) -> A.emit('data', X)`

    0.0.1latest
    Github

Version published
Maintainers
1
Weekly downloads
585
decreased by-22.72%

Weekly downloads

Readme

Source

invert-stream

Create a pair of streams (A, B) such that A.write(X) -> B.emit('data', X) and B.write(X) -> A.emit('data', X)

var invert = require('invert-stream') var inverted = invert() in_steam.pipe(inverted.other).pipe(out_stream) inverted.write(data_for_outstream) inverted.on('data', data_from_in_stream) ## why ? this is useful for a couple of things. * testing streams based stuff * making flexible duplex stream apis an `invert-stream` pair is like a tcp connection, but in-process and synchronous. It's way easier to test edge cases related to event order if you stuff works sync. Also, it's useful making duplex streams, or multiple streams into one. ### Example ```js var spawn = require('child_process').spawn var invert = require('invert-stream') var ch = spawn(cmd, args) var inverted = invert() ch.stdout.pipe(inverted.other).pipe(ch.sdin) //now, we have just ONE stream: inverted //write to che ch's stdin inverted.write(data) //read from ch's stdout inverted.on('data', ...)

License

MIT

FAQs

Last updated on 25 Aug 2012

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc