-
Notifications
You must be signed in to change notification settings - Fork 12
Streams Examples
elf Pavlik edited this page May 17, 2016
·
4 revisions
Parse triples from file card.ttl and forward them to the graph.
var parser = new TurtleParser(fs.createReadStream('card.ttl'))
var graph = new Graph()
var stream = parser.match()
stream.once('end', function () {
console.log('done')
})
graph.import(stream)
Parse triples from file card.ttl and forward only the triples matching the s p
pattern to the graph.
var parser = new TurtleParser(fs.createReadStream('card.ttl'))
var graph = new Graph()
var stream = parser.match(
rdf.iri('http://example.org/subject'),
rdf.iri('http://example.org/predicate'))
stream.once('end', function () {
console.log('done')
})
graph.import(stream)
Write triples to card.ttl file
var serializer = new TurtleSerializer(fs.createWriteStream('card.ttl'))
var graph = new Graph(/* quads .... */)
serializer.import(graph.match())