1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-11 20:27:12 +01:00
metamask-extension/app/scripts/lib/stream-utils.js

18 lines
451 B
JavaScript
Raw Normal View History

import ObjectMultiplex from 'obj-multiplex';
import pump from 'pump';
2016-04-08 23:24:10 +02:00
/**
* Sets up stream multiplexing for the given stream
* @param {any} connectionStream - the stream to mux
* @returns {stream.Stream} the multiplexed stream
*/
2020-11-03 00:41:28 +01:00
export function setupMultiplex(connectionStream) {
const mux = new ObjectMultiplex();
2020-11-03 00:41:28 +01:00
pump(connectionStream, mux, connectionStream, (err) => {
if (err) {
console.error(err);
2020-11-03 00:41:28 +01:00
}
});
return mux;
2016-06-21 22:18:32 +02:00
}