aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/port-stream.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/port-stream.js')
-rw-r--r--app/scripts/lib/port-stream.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index 2644741fc..1889e3c04 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -3,10 +3,9 @@ const inherits = require('util').inherits
module.exports = PortDuplexStream
-
inherits(PortDuplexStream, Duplex)
-function PortDuplexStream(port){
+function PortDuplexStream (port) {
Duplex.call(this, {
objectMode: true,
})
@@ -17,7 +16,7 @@ function PortDuplexStream(port){
// private
-PortDuplexStream.prototype._onMessage = function(msg){
+PortDuplexStream.prototype._onMessage = function (msg) {
if (Buffer.isBuffer(msg)) {
delete msg._isBuffer
var data = new Buffer(msg)
@@ -29,11 +28,11 @@ PortDuplexStream.prototype._onMessage = function(msg){
}
}
-PortDuplexStream.prototype._onDisconnect = function(){
+PortDuplexStream.prototype._onDisconnect = function () {
try {
// this.end()
this.emit('close')
- } catch(err){
+ } catch (err) {
this.emit('error', err)
}
}
@@ -42,7 +41,7 @@ PortDuplexStream.prototype._onDisconnect = function(){
PortDuplexStream.prototype._read = noop
-PortDuplexStream.prototype._write = function(msg, encoding, cb){
+PortDuplexStream.prototype._write = function (msg, encoding, cb) {
try {
if (Buffer.isBuffer(msg)) {
var data = msg.toJSON()
@@ -54,7 +53,7 @@ PortDuplexStream.prototype._write = function(msg, encoding, cb){
this._port.postMessage(msg)
}
cb()
- } catch(err){
+ } catch (err) {
console.error(err)
// this.emit('error', err)
cb(new Error('PortDuplexStream - disconnected'))
@@ -63,4 +62,4 @@ PortDuplexStream.prototype._write = function(msg, encoding, cb){
// util
-function noop(){} \ No newline at end of file
+function noop () {}