Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipe hypercore.replicate from webReadableStream to webWritableStream #329

Open
sce9sc opened this issue Nov 4, 2022 · 1 comment
Open

Comments

@sce9sc
Copy link

sce9sc commented Nov 4, 2022

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.

@sce9sc
Copy link
Author

sce9sc commented Nov 4, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant