Rdf-ext datastore - blank node counter - resetting to zero


I am using the full http://rdf-ext.bergnet.org/ in the browser.

I create a datastore from a turtle file by creating a Readable() stream, importing it into an N3Parser() and then adding the quads to a datastore.

I can then select blank nodes, but each time I do the number increments. Although I can see the N3Parser._resetBlankNodeIds in the file it is a private method. Is there any way to access this function and reset the counter?


Not sure, but maybe you can access the index using an existing instance of a blank node like this: blankNode.constructor.nextId = 0

Why do you want to reset the counter? It should not matter which blank node ID is used, as long as the mapping in the parser works.


I need it because I’m making diagrams and so it helps to have a consistent numbering. Consequently, I would ideally like to reset the counter before creating another datastore, but at the moment creating another doesn’t reset the counter. I need to reload my web page in order to do that.

However, thanks for the suggestion. I can try it out


Thanks… Worked. Perhaps needs making a little more efficient, so suggestions welcome


If you go in the direction of using webpack, like recommended in the other thread, you could use @rdfjs/term-map with the blank node as the key and a counter value as the value.