aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/stream-utils.js
diff options
context:
space:
mode:
authorDan Finlay <flyswatter@users.noreply.github.com>2017-09-15 10:40:00 +0800
committerGitHub <noreply@github.com>2017-09-15 10:40:00 +0800
commit693655e2da7cacf5a5326b50bddc37bcece9422e (patch)
treef5f6c429649af579d97eaa5940cab94dbc365a29 /app/scripts/lib/stream-utils.js
parent1d3cd9768cdd372d02e7e34674dde9d86af536f5 (diff)
parent0687c822baf7dcde8e96afa25ebc84491a061d07 (diff)
downloadtangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.gz
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.zst
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.zip
Merge pull request #2070 from MetaMask/filter-leak-fix3
Memory leak fixes - stream and filter life cycles
Diffstat (limited to 'app/scripts/lib/stream-utils.js')
-rw-r--r--app/scripts/lib/stream-utils.js24
1 files changed, 12 insertions, 12 deletions
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js
index ba79990cc..8bb0b4f3c 100644
--- a/app/scripts/lib/stream-utils.js
+++ b/app/scripts/lib/stream-utils.js
@@ -1,6 +1,6 @@
const Through = require('through2')
-const endOfStream = require('end-of-stream')
-const ObjectMultiplex = require('./obj-multiplex')
+const ObjectMultiplex = require('obj-multiplex')
+const pump = require('pump')
module.exports = {
jsonParseStream: jsonParseStream,
@@ -23,14 +23,14 @@ function jsonStringifyStream () {
}
function setupMultiplex (connectionStream) {
- var mx = ObjectMultiplex()
- connectionStream.pipe(mx).pipe(connectionStream)
- endOfStream(mx, function (err) {
- if (err) console.error(err)
- })
- endOfStream(connectionStream, function (err) {
- if (err) console.error(err)
- mx.destroy()
- })
- return mx
+ const mux = new ObjectMultiplex()
+ pump(
+ connectionStream,
+ mux,
+ connectionStream,
+ (err) => {
+ if (err) console.error(err)
+ }
+ )
+ return mux
}