mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
obj-multiplex - missing name error + prefer const over var
This commit is contained in:
parent
9eb13aee00
commit
aea5735b29
@ -5,12 +5,16 @@ module.exports = ObjectMultiplex
|
|||||||
function ObjectMultiplex (opts) {
|
function ObjectMultiplex (opts) {
|
||||||
opts = opts || {}
|
opts = opts || {}
|
||||||
// create multiplexer
|
// create multiplexer
|
||||||
var mx = through.obj(function (chunk, enc, cb) {
|
const mx = through.obj(function (chunk, enc, cb) {
|
||||||
var name = chunk.name
|
const name = chunk.name
|
||||||
var data = chunk.data
|
const data = chunk.data
|
||||||
var substream = mx.streams[name]
|
if (!name) {
|
||||||
|
console.warn(`ObjectMultiplex - Malformed chunk without name "${chunk}"`)
|
||||||
|
return cb()
|
||||||
|
}
|
||||||
|
const substream = mx.streams[name]
|
||||||
if (!substream) {
|
if (!substream) {
|
||||||
console.warn(`orphaned data for stream "${name}"`)
|
console.warn(`ObjectMultiplex - orphaned data for stream "${name}"`)
|
||||||
} else {
|
} else {
|
||||||
if (substream.push) substream.push(data)
|
if (substream.push) substream.push(data)
|
||||||
}
|
}
|
||||||
@ -19,7 +23,7 @@ function ObjectMultiplex (opts) {
|
|||||||
mx.streams = {}
|
mx.streams = {}
|
||||||
// create substreams
|
// create substreams
|
||||||
mx.createStream = function (name) {
|
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({
|
mx.push({
|
||||||
name: name,
|
name: name,
|
||||||
data: chunk,
|
data: chunk,
|
||||||
|
Loading…
Reference in New Issue
Block a user