aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-08-03 05:25:28 +0800
committerkumavis <aaron@kumavis.me>2017-08-03 05:25:28 +0800
commitaea5735b29c87d0a9aad3bfa86d854ed9b20bdf7 (patch)
treec38b94307bfbc2a237a86c157513014673952f43 /app
parent9eb13aee0046405bb304a2e31dbf7712e8b1da21 (diff)
downloadtangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar.gz
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar.bz2
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar.lz
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar.xz
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.tar.zst
tangerine-wallet-browser-aea5735b29c87d0a9aad3bfa86d854ed9b20bdf7.zip
obj-multiplex - missing name error + prefer const over var
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/obj-multiplex.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/scripts/lib/obj-multiplex.js b/app/scripts/lib/obj-multiplex.js
index bd114c394..0034febe0 100644
--- a/app/scripts/lib/obj-multiplex.js
+++ b/app/scripts/lib/obj-multiplex.js
@@ -5,12 +5,16 @@ module.exports = ObjectMultiplex
function ObjectMultiplex (opts) {
opts = opts || {}
// create multiplexer
- var mx = through.obj(function (chunk, enc, cb) {
- var name = chunk.name
- var data = chunk.data
- var substream = mx.streams[name]
+ 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(`orphaned data for stream "${name}"`)
+ console.warn(`ObjectMultiplex - orphaned data for stream "${name}"`)
} else {
if (substream.push) substream.push(data)
}
@@ -19,7 +23,7 @@ function ObjectMultiplex (opts) {
mx.streams = {}
// create substreams
mx.createStream = function (name) {
- var substream = mx.streams[name] = through.obj(function (chunk, enc, cb) {
+ const substream = mx.streams[name] = through.obj(function (chunk, enc, cb) {
mx.push({
name: name,
data: chunk,