LinkedDataFragments / Client.js

[DEPRECATED] A JavaScript client for Triple Pattern Fragments interfaces.
http://linkeddatafragments.org/
Other
92 stars 35 forks source link

How to use the client as a Node.js library? #6

Closed ameensol closed 10 years ago

ameensol commented 10 years ago

It wasn't really clear from the docs if/how this module can be used from a node.js script, though I imagine it is possible.

Can it be used with require?

RubenVerborgh commented 10 years ago

Hi @ameensol, sure, and you can see an example of that in bin/ldf-client.

Below is a minimal example:

var SparqlIterator = require('ldf-client').SparqlIterator,
    FragmentsClient = require('ldf-client').FragmentsClient;

var config = {};
config.fragmentsClient = new FragmentsClient("http://data.linkeddatafragments.org/");

var sparqlIterator = new SparqlIterator("SELECT * WHERE { ?s ?p ?o } LIMIT 100", config);
sparqlIterator.on('data', console.log);

Should you have any further issues, don't hesitate to tell us about them!