aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/port-stream.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-09-08 12:17:49 +0800
committerkumavis <aaron@kumavis.me>2017-09-08 12:17:49 +0800
commit57e4805c621155cd86169064f4aaba34b73644c6 (patch)
tree8743a9621d2f4596c42df1ede748fa1b69aa8691 /app/scripts/lib/port-stream.js
parent440a42bbc38ed53b64dc017fd56bd3281355df33 (diff)
downloadtangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.gz
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.bz2
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.lz
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.xz
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.tar.zst
tangerine-wallet-browser-57e4805c621155cd86169064f4aaba34b73644c6.zip
streams - use pump and published obj-multiplex
Diffstat (limited to 'app/scripts/lib/port-stream.js')
-rw-r--r--app/scripts/lib/port-stream.js16
1 files changed, 2 insertions, 14 deletions
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index 607a9c9ed..648d88087 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -1,5 +1,6 @@
const Duplex = require('readable-stream').Duplex
const inherits = require('util').inherits
+const noop = function(){}
module.exports = PortDuplexStream
@@ -20,20 +21,14 @@ PortDuplexStream.prototype._onMessage = function (msg) {
if (Buffer.isBuffer(msg)) {
delete msg._isBuffer
var data = new Buffer(msg)
- // console.log('PortDuplexStream - saw message as buffer', data)
this.push(data)
} else {
- // console.log('PortDuplexStream - saw message', msg)
this.push(msg)
}
}
PortDuplexStream.prototype._onDisconnect = function () {
- try {
- this.push(null)
- } catch (err) {
- this.emit('error', err)
- }
+ this.destroy()
}
// stream plumbing
@@ -45,19 +40,12 @@ PortDuplexStream.prototype._write = function (msg, encoding, cb) {
if (Buffer.isBuffer(msg)) {
var data = msg.toJSON()
data._isBuffer = true
- // console.log('PortDuplexStream - sent message as buffer', data)
this._port.postMessage(data)
} else {
- // console.log('PortDuplexStream - sent message', msg)
this._port.postMessage(msg)
}
} catch (err) {
- // console.error(err)
return cb(new Error('PortDuplexStream - disconnected'))
}
cb()
}
-
-// util
-
-function noop () {}