diff options
wiring - trusted-untrusted features + remote-store
Diffstat (limited to 'app/scripts/lib/stream-utils.js')
-rw-r--r-- | app/scripts/lib/stream-utils.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js index 12560ffd8..fd4417d94 100644 --- a/app/scripts/lib/stream-utils.js +++ b/app/scripts/lib/stream-utils.js @@ -1,9 +1,11 @@ const Through = require('through2') +const ObjectMultiplex = require('./obj-multiplex') module.exports = { jsonParseStream: jsonParseStream, jsonStringifyStream: jsonStringifyStream, + setupMultiplex: setupMultiplex, } function jsonParseStream(){ @@ -19,3 +21,17 @@ function jsonStringifyStream(){ cb() }) } + +function setupMultiplex(connectionStream){ + var mx = ObjectMultiplex() + connectionStream.pipe(mx).pipe(connectionStream) + mx.on('error', function(err) { + console.error(err) + // connectionStream.destroy() + }) + connectionStream.on('error', function(err) { + console.error(err) + mx.destroy() + }) + return mx +}
\ No newline at end of file |