This document provides a specification of a low level interface definition representing RDF data
independent of a serialized format in a JavaScript environment. The task force which defines
this interface was formed by RDF JavaScript library developers with the wish to make existing
and future libraries interoperable. This definition strives to provide the minimal necessary
interface to enable interoperability of libraries such as serializers, parsers and higher level
accessors and manipulators.

Data interfaces

Term interface

termType contains a value that identifies the concrete interface of the term, since
Term itself is not directly instantiated. Possible values include "NamedNode",
"BlankNode", "Literal", "Variable" and
"DefaultGraph".

value is refined by each interface which extends Term.

equals() returns true if and only if other has the same
termType and the same contents (as defined by concrete subclasses).

BlankNode interface

value blank node name as a string, without any serialization specific prefixes,
e.g. when parsing, if the data was sourced from Turtle, remove "_:", if it was
sourced from RDF/XML, do not change the blank node name (example: "blank3")

equals() returns true if and only if other has
termType"BlankNode" and the same value.

language the language as lowercase BCP-47 [[!BCP47]] string (examples:
"en", "en-gb") or an empty string if the literal has no language.

datatype a NamedNode whose IRI represents the datatype of the literal.

If the literal has a language, its datatype has the IRI
"http://www.w3.org/1999/02/22-rdf-syntax-ns#langString". Otherwise, if no
datatype is explicitly specified, the datatype has the IRI
"http://www.w3.org/2001/XMLSchema#string".

equals() returns true if and only if other has
termType"Literal" and the same value,
language, and datatype.

Source interface

A Source is an object that emits quads. It can contain quads but also generate them on the
fly. For example, parsers and transformations which generate quads can implement the Source
interface.

match() Returns a stream that processes all quads matching the pattern.

Sink interface

interface Sink {
EventEmitter import(Stream stream);
};

A Sink is an object that consumes data from different kinds of streams. It can store the
content of the stream or do some further processing. For example parsers, serializers,
transformations and stores can implement the Sink interface.

import() Consumes the given stream. The end and error
events are used like described in the Stream interface. Depending on the use
case, subtypes of EventEmitter or Stream are used.

A Store is an object that usually used to persist quads. The interface allows removing quads,
beside read and write access. The quads can be stored locally or remotely. Access to stores
LDP or SPARQL endpoints can be implemented with a Store inteface.

remove() Removes all streamed quads. The end and error
events are used like described in the Stream interface.

removeMatches() All quads matching the pattern will be removed. The
end and error events are used like described in the
Stream interface.

deleteGraph() Deletes the given named graph. The end and
error events are used like described in the Stream interface.