1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 10:30:04 +01:00
metamask-extension/app/scripts/lib/stream-utils.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

18 lines
451 B
JavaScript

import ObjectMultiplex from 'obj-multiplex';
import pump from 'pump';
/**
* Sets up stream multiplexing for the given stream
* @param {any} connectionStream - the stream to mux
* @returns {stream.Stream} the multiplexed stream
*/
export function setupMultiplex(connectionStream) {
const mux = new ObjectMultiplex();
pump(connectionStream, mux, connectionStream, (err) => {
if (err) {
console.error(err);
}
});
return mux;
}