Closed tobiasschweizer closed 3 years ago
yes please!
ok, will do :-)
@ktk I opened #75
Since I work with JSON-LD data, I added the following method for convenience (dep: jsonld):
const jsonld = require('jsonld')
async function loadRDFFromJSONLD(filePath) {
const doc = fs.readFileSync(filePath);
const jsonldDoc = JSON.parse(doc);
const dataRDF = await jsonld.toRDF(jsonldDoc, {format: 'application/n-quads'});
const input = new Readable({
read: () => {
input.push(dataRDF)
input.push(null)
}
})
const parser = new ParserN3({ factory })
return factory.dataset().import(parser.import(input))
}
If you think that's useful, I'd be glad to contribute that too.
The code snippet in the README throws an error:
This can easily be solved by putting the code in an async function (e.g., main) and calling it right after.
I could submit a small PR. What do you think?