libp2p
Version:
JavaScript implementation of libp2p, a modular peer to peer network stack
25 lines • 750 B
JavaScript
export function redirect(channelA, channelB) {
channelA.addEventListener('message', (evt) => {
const sendMore = channelB.send(evt.data);
if (sendMore === false) {
channelA.pause();
channelA.addEventListener('drain', () => {
channelA.resume();
}, {
once: true
});
}
});
channelB.addEventListener('message', (evt) => {
const sendMore = channelA.send(evt.data);
if (sendMore === false) {
channelB.pause();
channelB.addEventListener('drain', () => {
channelB.resume();
}, {
once: true
});
}
});
}
//# sourceMappingURL=utils.js.map