rdf-js: remove triples (#43914)

* remove triples

Triples are not specified in the RDF/JS standards.

* bump major version

* expand the argument type of `Quad.equals`
This commit is contained in:
Lars Hupel 2020-04-26 18:18:44 +02:00 committed by GitHub
parent 16a56ae606
commit 72ccd00994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 37 deletions

2
types/n3/index.d.ts vendored
View File

@ -100,7 +100,7 @@ export class Quad extends BaseQuad implements RDF.Quad {
toJSON(): string;
}
export class Triple extends Quad implements RDF.Triple {}
export class Triple extends Quad implements RDF.Quad {}
export namespace DataFactory {
function namedNode(value: string): NamedNode;

View File

@ -178,7 +178,7 @@ function static_Triple_fromBaseTerms(): Quad {
const predicate: NamedNode = <any> {};
const object: NamedNode = <any> {};
return rdf.triple(subject, predicate, object);
return rdf.quad(subject, predicate, object);
}
function instance_Quad_fromBaseTerms(): Quad {
@ -197,7 +197,7 @@ function instance_Triple_fromBaseTerms(): Quad {
const predicate: NamedNode = <any> {};
const object: NamedNode = <any> {};
return factory.triple(subject, predicate, object);
return factory.quad(subject, predicate, object);
}
function Quad_toJSON(): boolean {

View File

@ -1,4 +1,4 @@
// Type definitions for the RDFJS specification 2.0
// Type definitions for the RDFJS specification 3.0
// Project: https://github.com/rdfjs/representation-task-force
// Definitions by: Ruben Taelman <https://github.com/rubensworks>
// Laurens Rietveld <https://github.com/LaurensRietveld>
@ -200,7 +200,7 @@ export interface BaseQuad {
* @param other The term to compare with.
* @return True if and only if the argument is a) of the same type b) has all components equal.
*/
equals(other: BaseQuad): boolean;
equals(other: BaseQuad | null | undefined): boolean;
}
/**
@ -232,19 +232,11 @@ export interface Quad extends BaseQuad {
* @param other The term to compare with.
* @return True if and only if the argument is a) of the same type b) has all components equal.
*/
equals(other: BaseQuad): boolean;
equals(other: BaseQuad | null | undefined): boolean;
}
/**
* An RDF triple, containing the subject, predicate, object terms.
*
* Triple is an alias of Quad.
*/
// tslint:disable-next-line no-empty-interface
export interface Triple extends Quad {}
/**
* A factory for instantiating RDF terms, triples and quads.
* A factory for instantiating RDF terms and quads.
*/
export interface DataFactory<OutQuad extends BaseQuad = Quad, InQuad extends BaseQuad = OutQuad> {
/**
@ -288,17 +280,6 @@ export interface DataFactory<OutQuad extends BaseQuad = Quad, InQuad extends Bas
*/
defaultGraph(): DefaultGraph;
/**
* @param subject The triple subject term.
* @param predicate The triple predicate term.
* @param object The triple object term.
* @return A new instance of Quad with `Quad.graph` set to DefaultGraph.
* @see Quad
* @see Triple
* @see DefaultGraph
*/
triple(subject: InQuad['subject'], predicate: InQuad['predicate'], object: InQuad['object']): InQuad;
/**
* @param subject The quad subject term.
* @param predicate The quad predicate term.

View File

@ -1,5 +1,5 @@
import { BlankNode, DataFactory, Dataset, DatasetCore, DatasetCoreFactory, DatasetFactory, DefaultGraph, Literal,
NamedNode, Quad, BaseQuad, Sink, Source, Store, Stream, Triple, Term, Variable, Quad_Graph } from "rdf-js";
NamedNode, Quad, BaseQuad, Sink, Source, Store, Stream, Term, Variable, Quad_Graph } from "rdf-js";
import { EventEmitter } from "events";
function test_terms() {
@ -55,14 +55,6 @@ function test_quads() {
const o1: Term = quad.object;
const g1: Term = quad.graph;
quad.equals(quad);
const triple: Triple = quad;
const s2: Term = triple.subject;
const p2: Term = triple.predicate;
const o2: Term = triple.object;
const g2: Term = triple.graph;
triple.equals(quad);
quad.equals(triple);
}
function test_datafactory() {
@ -80,7 +72,6 @@ function test_datafactory() {
const variable: Variable = dataFactory.variable ? dataFactory.variable('v1') : <any> {};
const term: NamedNode = <any> {};
const triple: Quad = dataFactory.triple(term, term, term);
interface QuadBnode extends BaseQuad {
subject: Term;
predicate: Term;

View File

@ -8,5 +8,5 @@ const variable: RDF.Variable = rdf.variable('foo');
const graph: RDF.DefaultGraph = rdf.defaultGraph();
const defaultGraph: RDF.DefaultGraph = rdf.defaultGraphInstance;
const namedNode: RDF.NamedNode = rdf.namedNode('foo');
const triple: RDF.Triple = rdf.triple(namedNode, variable, literal);
const triple: RDF.Quad = rdf.quad(namedNode, variable, literal);
const quad: RDF.Quad = rdf.quad(namedNode, variable, literal, graph);