N3.js icon indicating copy to clipboard operation
N3.js copied to clipboard

Web Streams API support?

Open rybesh opened this issue 1 year ago • 4 comments

Are there any plans to implement Web Streams API support (rather than Node streams)?

rybesh avatar Jul 07 '23 18:07 rybesh

There are no plans at the moment.

What's your use case?

jeswr avatar Jul 08 '23 01:07 jeswr

The Fetch API returns a Response object, the body of which is a Streams API ReadableStream, not a Node ReadableStream. It would be nice to be able to pipe that stream to an N3.StreamParser, rather than fiddling with converting it to a Node stream first (since I'm bundling for the browser, not Node).

rybesh avatar Jul 11 '23 02:07 rybesh

Have you come across rdf-dereference? It uses N3 under the hood for parsing and also handles all of this stream fetching stuff https://www.npmjs.com/package/rdf-dereference.

It is built using Comunica so this is how it is going between Web and Node streams under the hood https://github.com/comunica/comunica/blob/b86d55278c455b56f9fd003254fd56616f9e7087/packages/actor-dereference-http/lib/ActorDereferenceHttpBase.ts#L106.

jeswr avatar Jul 11 '23 03:07 jeswr

Thanks, it looks like toNodeReadable has an example of what I needed. rdf-dereference looks useful as well.

rybesh avatar Jul 11 '23 15:07 rybesh