Skip to main content
Module

x/ldkit/rdf.ts>RDF.Dataset

LDkit - Linked Data query toolkit for TypeScript developers
Go to Latest
interface RDF.Dataset
implements DatasetCore<OutQuad, InQuad>
import { type RDF } from "https://deno.land/x/ldkit@v0.5.1/rdf.ts";
const { Dataset } = RDF;

Type Parameters

optional
OutQuad extends BaseQuad = Quad
optional
InQuad extends BaseQuad = OutQuad

Methods

addAll(quads: Dataset<InQuad> | InQuad[]): this

Imports the quads into this dataset.

This method differs from Dataset.union in that it adds all quads to the current instance, rather than combining quads and the current instance to create a new instance.

contains(other: Dataset<InQuad>): boolean

Returns true if the current instance is a superset of the given dataset; differently put: if the given dataset is a subset of, is contained in the current dataset.

Blank Nodes will be normalized.

deleteMatches(
subject?: Term,
predicate?: Term,
object?: Term,
graph?: Term,
): this

This method removes the quads in the current instance that match the given arguments.

The logic described in Quad Matching is applied for each quad in this dataset to select the quads which will be deleted.

difference(other: Dataset<InQuad>): Dataset<OutQuad, InQuad>

Returns a new dataset that contains all quads from the current dataset, not included in the given dataset.

equals(other: Dataset<InQuad>): boolean

Returns true if the current instance contains the same graph structure as the given dataset.

Blank Nodes will be normalized.

every(iteratee: (quad: OutQuad, dataset: this) => boolean): boolean

Universal quantification method, tests whether every quad in the dataset passes the test implemented by the provided iteratee.

This method immediately returns boolean false once a quad that does not pass the test is found.

This method always returns boolean true on an empty dataset.

This method is aligned with Array.prototype.every() in ECMAScript-262.

filter(iteratee: (quad: OutQuad, dataset: this) => boolean): Dataset<OutQuad, InQuad>

Creates a new dataset with all the quads that pass the test implemented by the provided iteratee.

This method is aligned with Array.prototype.filter() in ECMAScript-262.

forEach(callback: (quad: OutQuad, dataset: this) => void): void

Executes the provided iteratee once on each quad in the dataset.

This method is aligned with Array.prototype.forEach() in ECMAScript-262.

import(stream: Stream<InQuad>): Promise<this>

Imports all quads from the given stream into the dataset.

The stream events end and error are wrapped in a Promise.

intersection(other: Dataset<InQuad>): Dataset<OutQuad, InQuad>

Returns a new dataset containing alls quads from the current dataset that are also included in the given dataset.

map(iteratee: (quad: OutQuad, dataset: Dataset<OutQuad>) => OutQuad): Dataset<OutQuad, InQuad>

Returns a new dataset containing all quads returned by applying iteratee to each quad in the current dataset.

reduce<A = any>(callback: (
accumulator: A,
quad: OutQuad,
dataset: this,
) => A
, initialValue?: A
): A

This method calls the iteratee on each quad of the Dataset. The first time the iteratee is called, the accumulator value is the initialValue or, if not given, equals to the first quad of the Dataset. The return value of the iteratee is used as accumulator value for the next calls.

This method returns the return value of the last iteratee call.

This method is aligned with Array.prototype.reduce() in ECMAScript-262.

some(iteratee: (quad: OutQuad, dataset: this) => boolean): boolean

Existential quantification method, tests whether some quads in the dataset pass the test implemented by the provided iteratee.

This method immediately returns boolean true once a quad that passes the test is found.

This method is aligned with Array.prototype.some() in ECMAScript-262.

toArray(): OutQuad[]

Returns the set of quads within the dataset as a host language native sequence, for example an Array in ECMAScript-262.

Since a Dataset is an unordered set, the order of the quads within the returned sequence is arbitrary.

toCanonical(): string

Returns an N-Quads string representation of the dataset, preprocessed with RDF Dataset Normalization algorithm.

toStream(): Stream<OutQuad>

Returns a stream that contains all quads of the dataset.

toString(): string

Returns an N-Quads string representation of the dataset.

No prior normalization is required, therefore the results for the same quads may vary depending on the Dataset implementation.

union(quads: Dataset<InQuad>): Dataset<OutQuad, InQuad>

Returns a new Dataset that is a concatenation of this dataset and the quads given as an argument.

match(
subject?: Term | null,
predicate?: Term | null,
object?: Term | null,
graph?: Term | null,
): Dataset<OutQuad, InQuad>