rdf-transform
v1.2.1
Published
Easily transform between RDF syntaxes
Downloads
174
Maintainers
Readme
RDF Transform
Easily transform between RDF syntaxes
Usage
We can transform between two content types as follows
import { transform } from 'rdf-transform';
const textStream = require('streamify-string')(`
<http://ex.org/s> <http://ex.org/p> <http://ex.org/o1>, <http://ex.org/o2>.
`);
transform(textStream, { from: { contentType: 'text/turtle' }, to: { contentType: 'application/ld+json' }, baseIRI: 'http://example.org' })
.on('data', (str) => console.log(str))
.on('error', (error) => console.error(error))
.on('end', () => console.log('All done!'));
Sometimes we wish to dynamically discover which content types we support transforming to; this can be done as follows
import { allowedDestinations } from 'rdf-transform';
// ['text/turtle', 'text/n3', ..., 'application/ld+json']
const destinations = await allowedDestinations('text/turtle');
License
©2023–present Jesse Wright, MIT License.