1.2.0 • Published 1 year ago

rdf-transform v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

RDF Transform

Easily transform between RDF syntaxes

GitHub license npm version build Dependabot semantic-release

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.