@rdf-esm/formats-common
TypeScript icon, indicating that this package has built-in type declarations

0.5.6 • Public • Published

@rdfjs/formats-common

npm version

This module bundles parsers and serializers for the most common RDF formats. Instances of SinkMap are used to handle different media types.

Fork alert

This package is an ES Modules fork of @rdfjs/formats-common.

It uses a lazy version of SinkMap to dynamically load the sinks.

This way bundlers like webpack will create chunks for them and only load them when they are first needed.

Usage

The formats object has a parsers and serializers property. Each of it is an instance of SinkMap with the most common RDF media types as key.

Example

const formats = require('@rdfjs/formats-common')
const Readable = require('stream').Readable

const input = new Readable({
  read: () => {
    input.push(`
      PREFIX s: <http://schema.org/>

      [] a s:Person ;
        s:jobTitle "Professor" ;
        s:name "Jane Doe" ;
        s:telephone "(425) 123-4567" ;
        s:url <http://www.janedoe.com> .
    `)
    input.push(null)
  }
})

const output = formats.parsers.import('text/turtle', input)

output.on('data', quad => {
  console.log(`quad: ${quad.subject.value} - ${quad.predicate.value} - ${quad.object.value}`)
})

output.on('prefix', (prefix, ns) => {
  console.log(`prefix: ${prefix} ${ns.value}`)
})

/@rdf-esm/formats-common/

    Package Sidebar

    Install

    npm i @rdf-esm/formats-common

    Weekly Downloads

    753

    Version

    0.5.6

    License

    MIT

    Unpacked Size

    13.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • tpluscode