New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

plexy

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

plexy

Create multiple duplex object streams that read and write through a single text stream.

latest
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

plexy

Create multiple duplex object streams that read and write through a single text stream.

NPM

API

var Plexy = require('plexy')

Plexy(carrierStream, channelName)

Returns a duplex object stream.

Example

Server:

function CarrierStream(){ // allow streaming from and to multiple sources
  var stream = Through(function(data){
    this.outgoing.queue(data)  
  })

  stream.incoming = Through()
  stream.outgoing = Through()

  stream.incoming.on('data', function(data){
    stream.queue(data)
  })

  return stream
}

var carrierStream = CarrierStream()

var main = Plexy(carrierStream, 'main')
var sub = Plexy(carrierStream, 'sub')

// log any messages recieved from clients to console
main.on('data', function(data){
  console.write('main:', data)
})
sub.on('data', function(data){
  console.write('sub:', data)
})

var sock = shoe(function (stream) {
  carrierStream.outgoing.pipe(stream).pipe(carrierStream.incoming)
  stream.on('end', function () {
    carrierStream.outgoing.unpipe(stream)
    stream.unpipe(carrierStream.incoming)
  })
})

// send a message every 4 seconds to all connected clients on 'main' channel
setInterval(function(){
  main.write('hello all!')
}, 4000)

sock.install(server, '/stream')

Client:

var socket = Shoe('/stream')

var main = Plexy(socket, 'main')
var sub = Plexy(socket, 'sub')

// send some data to write on server console:
main.write('Some text')
main.write({message: 'an object'})

// log any messages recieved from server
main.on('data', function(data){
  console.write('main:', data)
})

sub.on('data', function(data){
  console.write('sub:', data)
})

Keywords

multiplex

FAQs

Package last updated on 08 Jan 2014

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