Files: cfba6fdcb78b4019f623639fbd7dfecaacb4ab1c / port.js
353 bytesRaw
1 | const EventEmitter = require('events') |
2 | |
3 | module.exports = class Port extends EventEmitter { |
4 | constructor () { |
5 | super() |
6 | } |
7 | |
8 | connect (destPort) { |
9 | this.destPort = destPort |
10 | destPort.destPort = this |
11 | } |
12 | |
13 | async send (message) { |
14 | return this.destPort.recieve(message) |
15 | } |
16 | |
17 | async recieve (message) { |
18 | this.emit('message', message) |
19 | } |
20 | } |
21 |
Built with git-ssb-web