🚀 Launch Week Day 3:Introducing Supply Chain Attack Campaigns Tracking.Learn More →
Socket
Book a DemoInstallSign in
Socket

cross-pipe

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cross-pipe

Create two streams that are cross piped

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

cross-pipe

Create two streams that are cross piped.

npm install cross-pipe

Useful if you have an API that accepts a stream but want to return a stream that represents that pipeline as well

Usage

const crossPipe = require('cross-pipe')

const [ a, b ] = crossPipe()

a.write('hi')

b.on('data', function (data) {
  console.log('b: ' + data) // prints hi
  b.write('hey')
  a.on('data', function (data) {
    console.log('a: ' + data) // prints hey
  })
})

If you are using something like noise-peer that accepts the underlying socket in the constructor but you want to return a generic stream in a pipeline you do it with a cross pipe like so

function replicate () {
  const [ a, b ] = crossPipe()

  const stream = noise(b)

  // do stuff with stream

  // a reprensents the pipeline now
  return a
}

License

MIT

FAQs

Package last updated on 12 Oct 2018

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