mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
27 lines
532 B
JavaScript
27 lines
532 B
JavaScript
const ObjectMultiplex = require('obj-multiplex')
|
|
const pump = require('pump')
|
|
|
|
module.exports = {
|
|
setupMultiplex: setupMultiplex,
|
|
}
|
|
|
|
/**
|
|
* Sets up stream multiplexing for the given stream
|
|
* @param {any} connectionStream - the stream to mux
|
|
* @return {stream.Stream} the multiplexed stream
|
|
*/
|
|
function setupMultiplex (connectionStream) {
|
|
const mux = new ObjectMultiplex()
|
|
pump(
|
|
connectionStream,
|
|
mux,
|
|
connectionStream,
|
|
(err) => {
|
|
if (err) {
|
|
console.error(err)
|
|
}
|
|
}
|
|
)
|
|
return mux
|
|
}
|