aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/obj-multiplex.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/obj-multiplex.js
parent1d3cd9768cdd372d02e7e34674dde9d86af536f5 (diff)
parent0687c822baf7dcde8e96afa25ebc84491a061d07 (diff)
downloadtangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.gz
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.bz2
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.lz
tangerine-wallet-browser-693655e2da7cacf5a5326b50bddc37bcece9422e.tar.xz
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/obj-multiplex.js')
-rw-r--r--app/scripts/lib/obj-multiplex.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/app/scripts/lib/obj-multiplex.js b/app/scripts/lib/obj-multiplex.js
deleted file mode 100644
index 0034febe0..000000000
--- a/app/scripts/lib/obj-multiplex.js
+++ /dev/null
@@ -1,48 +0,0 @@
-const through = require('through2')
-
-module.exports = ObjectMultiplex
-
-function ObjectMultiplex (opts) {
- opts = opts || {}
- // create multiplexer
- const mx = through.obj(function (chunk, enc, cb) {
- const name = chunk.name
- const data = chunk.data
- if (!name) {
- console.warn(`ObjectMultiplex - Malformed chunk without name "${chunk}"`)
- return cb()
- }
- const substream = mx.streams[name]
- if (!substream) {
- console.warn(`ObjectMultiplex - orphaned data for stream "${name}"`)
- } else {
- if (substream.push) substream.push(data)
- }
- return cb()
- })
- mx.streams = {}
- // create substreams
- mx.createStream = function (name) {
- const substream = mx.streams[name] = through.obj(function (chunk, enc, cb) {
- mx.push({
- name: name,
- data: chunk,
- })
- return cb()
- })
- mx.on('end', function () {
- return substream.emit('end')
- })
- if (opts.error) {
- mx.on('error', function () {
- return substream.emit('error')
- })
- }
- return substream
- }
- // ignore streams (dont display orphaned data warning)
- mx.ignoreStream = function (name) {
- mx.streams[name] = true
- }
- return mx
-}