Socket
Book a DemoInstallSign in
Socket

stream-disconnect

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-disconnect

disconnect all listeners for a given stream without closing

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

disconnect-stream

given a source stream, disconnect it from all of its downstream listeners (without closing the source or dest streams!)

var through = require('through')
  , disconnect = require('disconnect-stream')
  , source = through()
  , dest = through()

source.pipe(dest)

dest.on('data', function() {
  console.log('got data')
})

source.write('data') // "got data"

disconnect(source) // returns `true` since there were dest pipes

source.write('data')

source.readable && source.writable // true
dest.readable && dest.writable // true

api

disconnect(source stream) -> Boolean

non-destructively disconnect all downstream destinations of source. returns true if any destinations were disconnected, or false if there were no downstream listeners.

license

MIT

Keywords

stream

FAQs

Package last updated on 05 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts