An experimental blend of rdflib.js and rdf-ext.
ext-rdflib.js decorates rdf-ext to be somehow compatible with rdflib.js. The goal is not full compatibility (this would defeat the goal of getting rid of some rdflib.js peculiarities) but to make using rdf-ext easier expecially to those who know rdflib.js.
Also I add features as I need them and you're invited to do the same. The design principle is to add features that are compatible with the rdflib.js API without breaking the rdf-ext API.
With node.js:
const $rdf = require("ext-rdflib");
In the browser:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsonld/1.0.0/jsonld.min.js"></script>
<script type="text/javascript" src="https://retog.github.io/ext-rdflib/latest/rdf.js"></script>
The first line is optional and only required if JSON-LD support is required. The ext-rdflib URI always points to the latest version, replace latest
with a specific version number to avoid potentially breaking updates, e.g. https://retog.github.io/ext-rdflib/0.5.0/rdf.js
The $rdf
variable will provide all method of rdf-ext plus some methods to mimick the rdflib.js API.
Parsing in all formats supported by rdflib.js is supported. However the parse
method must be called asynchronously:
parse(content, store, base, mediaType, (error, store) => {
//do something
})
Note that support for RDFa and RDF/XML have has not been added to rdf-ext as it should be done, they are only supported when calling the rdflib.js-style method as this code has been taken from rdflib.js virtually without modification.
The browser-distribution of ext-rdflib.js that inludes rdf-ext and the required parsers is currently 592 KB which is significantly smaller than rdflib.js which is 1.64 MB. Obviously the size will grow as more features are added.