rdfjs / N3.js

Lightning fast, spec-compatible, streaming RDF for JavaScript
http://rdf.js.org/N3.js/
Other
676 stars 127 forks source link

Web Streams API support? #359

Open rybesh opened 1 year ago

rybesh commented 1 year ago

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

jeswr commented 1 year ago

There are no plans at the moment.

What's your use case?

rybesh commented 12 months ago

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).

jeswr commented 12 months ago

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.

rybesh commented 12 months ago

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