RunKit + npm:

node v14.20.1
endpointsharetweet
const $rdf = require('rdf-ext@1.3.5') const N3 = require('n3') const ex = require('@rdfjs/namespace@1.0.0')('http://example.com/') const getStream = require('get-stream@5.0.0') const dataBefore = ` @prefix : <http://example.com/>. graph :G { :elephant :color "Yellow" }` const changes = ` @prefix : <http://example.com/>. graph :G { [ :add << :elephant :color "Grey" >> ; :remove << :elephant :color "Yellow" >> ; ] . }` const parser = new N3.Parser() const dataset = $rdf.dataset(parser.parse(dataBefore)) for(const mod of parser.parse(changes)) { if (mod.predicate.equals(ex.add)) { dataset.add(mod.object) } else { dataset.remove(mod.object) } } await getStream(dataset.toStream().pipe(new N3.StreamWriter({ prefixes: { '': 'http://example.com/' } })))
Created from: https://npm.runkit.com/
Loading…