duplex-emitter

2.1.2 • Public • Published

duplex-emitter

Build Status

browser support

Turns a duplex stream into an event emitter.

Create

var s = net.connect(...);
 
var duplexEmitter = require('duplex-emitter');
var emitter = duplexEmitter(s);

Emit

You can emit events. They will be serialized (to JSON) and piped to the stream.

emitter.emit('event1', arg1, arg2); // Send event to the other side

Receive

You can listen for events from the peer:

// Got event from the peer
emitter.on('event2', function(arg1, arg2){
  //...
})

Readme

Keywords

none

Package Sidebar

Install

npm i duplex-emitter

Weekly Downloads

523

Version

2.1.2

License

MIT

Last publish

Collaborators

  • pgte