1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/app/scripts/lib/stream-utils.js
2019-12-12 15:07:18 -03:30

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
}