hypercore
hypercore copied to clipboard
pipe hypercore.replicate from webReadableStream to webWritableStream
First of all , It is the most amazing project I have ever come across.
I was wondering how can I pipe the hypercore.replicate stream which is a duplex Node.js stream to a webReabable and a webWritable streams in the browser.
I have two distinct streams . A webReadable and a webWritable . Since there is no duplex stream for web does anyone know how to do it or at least point me to the right direction.
Thank you in advance.
In node I have accomplished as shown below:
const { ReadableStream, WritableStream } = require('node:stream/web');
const streamNode = require('node:stream');
session.ReadableStream = ReadableStream;
session.WritableStream = WritableStream;
let duplex = streamNode.Duplex.fromWeb({
readable: session.getReadableStream(),
writable: session.getWritableStream(),
});
const repStream = core.replicate(true,{ keepAlive: false})
duplex.pipe(repStream).pipe(duplex)