Skip to content

Instantly share code, notes, and snippets.

@BruJu
Created Apr 15, 2021
Embed
What would you like to do?
Unblanknode
const N3 = require('n3');
/**
* Return the description of the `term`.
*
* The description is:
* - the term itself if it is not a blank node
* - if it is a blank node, a list of every [predicate, object] for which
* there exists a (term, predicate, object) quad in the default graph of the
* store
*
* @param {N3.Store} store The store
* @param {*} term The term
* @returns An array with the informations about the term
*/
function readInfo(store, term) {
if (term.termType == "BlankNode") {
const quads = store.getQuads(term, null, null, N3.DataFactory.defaultGraph());
return quads.map(quad => [quad.predicate, readInfo(store, quad.object)]);
} else {
return term;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment