@ldo/dataset 1.0.0-alpha.3 → 1.0.0-alpha.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/Readme.md +7 -3
  2. package/dist/ExtendedDataset.cjs +276 -0
  3. package/dist/ExtendedDataset.d.cts +170 -0
  4. package/dist/ExtendedDataset.d.cts.map +1 -0
  5. package/dist/ExtendedDataset.d.ts +169 -30
  6. package/dist/ExtendedDataset.d.ts.map +1 -0
  7. package/dist/ExtendedDataset.js +275 -190
  8. package/dist/ExtendedDataset.js.map +1 -1
  9. package/dist/ExtendedDatasetFactory.cjs +18 -0
  10. package/dist/ExtendedDatasetFactory.d.cts +18 -0
  11. package/dist/ExtendedDatasetFactory.d.cts.map +1 -0
  12. package/dist/ExtendedDatasetFactory.d.ts +17 -6
  13. package/dist/ExtendedDatasetFactory.d.ts.map +1 -0
  14. package/dist/ExtendedDatasetFactory.js +17 -14
  15. package/dist/ExtendedDatasetFactory.js.map +1 -1
  16. package/dist/_virtual/rolldown_runtime.cjs +30 -0
  17. package/dist/createDatasetFromSerializedInput.cjs +23 -0
  18. package/dist/createDatasetFromSerializedInput.d.cts +22 -0
  19. package/dist/createDatasetFromSerializedInput.d.cts.map +1 -0
  20. package/dist/createDatasetFromSerializedInput.d.ts +22 -3
  21. package/dist/createDatasetFromSerializedInput.d.ts.map +1 -0
  22. package/dist/createDatasetFromSerializedInput.js +20 -6
  23. package/dist/createDatasetFromSerializedInput.js.map +1 -1
  24. package/dist/createExtendedDataset.cjs +29 -0
  25. package/dist/createExtendedDataset.d.cts +22 -0
  26. package/dist/createExtendedDataset.d.cts.map +1 -0
  27. package/dist/createExtendedDataset.d.ts +22 -5
  28. package/dist/createExtendedDataset.d.ts.map +1 -0
  29. package/dist/createExtendedDataset.js +23 -18
  30. package/dist/createExtendedDataset.js.map +1 -1
  31. package/dist/createExtendedDatasetFromSerializedInput.cjs +22 -0
  32. package/dist/createExtendedDatasetFromSerializedInput.d.cts +22 -0
  33. package/dist/createExtendedDatasetFromSerializedInput.d.cts.map +1 -0
  34. package/dist/createExtendedDatasetFromSerializedInput.d.ts +22 -4
  35. package/dist/createExtendedDatasetFromSerializedInput.d.ts.map +1 -0
  36. package/dist/createExtendedDatasetFromSerializedInput.js +20 -10
  37. package/dist/createExtendedDatasetFromSerializedInput.js.map +1 -1
  38. package/dist/index.cjs +12 -0
  39. package/dist/index.d.cts +6 -0
  40. package/dist/index.d.ts +6 -5
  41. package/dist/index.js +7 -18
  42. package/package.json +30 -14
  43. package/src/createExtendedDataset.ts +6 -1
  44. package/dist/index.js.map +0 -1
package/Readme.md CHANGED
@@ -12,7 +12,9 @@ npm i @ldo/dataset
12
12
 
13
13
  ```typescript
14
14
  import { createDataset } from "@ldo/dataset";
15
- import { quad, namedNode } from "@rdfjs/data-model";
15
+ import { quad, namedNode } from "@ldo/rdf-utils";
16
+
17
+ imports: quad, namedNode as MyNamedNode
16
18
  const dataset = createDataset();
17
19
  dataset.add(
18
20
  quad(
@@ -35,12 +37,14 @@ The extended dataset implements all the [additional methods](https://rdf.js.org/
35
37
  Usage:
36
38
  ```typescript
37
39
  import { createDataset } from "@ldo/dataset";
38
- import { quad, namedNode, literal } from "@rdfjs/data-model";
40
+ import { quad, namedNode, literal } as rdfdm from '@ldo/rdf-utils';
39
41
  // Required for advanced features:
40
- import { dataset as initializeDatasetCore } from "@rdfjs/dataset";
42
+ import * as rdfds from "@rdfjs/dataset";
41
43
  import { ExtendedDatasetFactory } from "@ldo/dataset";
42
44
  import { Dataset, Quad, DatasetCoreFactory, DatasetCore } from "@rdfjs/types";
43
45
 
46
+ const { dataset: initializeDatasetCore } = rdfds;
47
+
44
48
  /**
45
49
  * Create a dataset with default settings
46
50
  */
@@ -0,0 +1,276 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const __ldo_rdf_utils = require_rolldown_runtime.__toESM(require("@ldo/rdf-utils"));
3
+ const readable_stream = require_rolldown_runtime.__toESM(require("readable-stream"));
4
+
5
+ //#region src/ExtendedDataset.ts
6
+ /**
7
+ * A full implementation of the RDF JS Dataset interface.
8
+ */
9
+ var ExtendedDataset = class ExtendedDataset {
10
+ /**
11
+ * The main backing dataset
12
+ */
13
+ dataset;
14
+ /**
15
+ * A factory that generates datasets for the methods
16
+ */
17
+ datasetCoreFactory;
18
+ /**
19
+ * Constructor
20
+ */
21
+ constructor(dataset, datasetFactory) {
22
+ this.dataset = dataset;
23
+ this.datasetCoreFactory = datasetFactory;
24
+ }
25
+ /**
26
+ * Creates a blank dataset using the dataset factory
27
+ */
28
+ createBlankDataset() {
29
+ return new ExtendedDataset(this.datasetCoreFactory.dataset(), this.datasetCoreFactory);
30
+ }
31
+ /**
32
+ * Imports the quads into this dataset.
33
+ * 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.
34
+ * @param quads
35
+ * @returns the dataset instance it was called on.
36
+ */
37
+ addAll(quads) {
38
+ for (const quad of quads) this.add(quad);
39
+ return this;
40
+ }
41
+ /**
42
+ * 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.
43
+ * Blank Nodes will be normalized.
44
+ * @param other
45
+ */
46
+ contains(other) {
47
+ if (other.size > this.size) return false;
48
+ for (const quad of other) if (!this.has(quad)) return false;
49
+ return true;
50
+ }
51
+ /**
52
+ * 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.
53
+ * @param subject
54
+ * @param predicate
55
+ * @param object
56
+ * @param graph
57
+ * @returns the dataset instance it was called on.
58
+ */
59
+ deleteMatches(subject, predicate, object, graph) {
60
+ const matching = this.match(subject, predicate, object, graph);
61
+ for (const quad of matching) this.dataset.delete(quad);
62
+ return this;
63
+ }
64
+ /**
65
+ * Returns a new dataset that contains alls quads from the current dataset, not included in the given dataset.
66
+ * @param other
67
+ */
68
+ difference(other) {
69
+ const dataset = this.createBlankDataset();
70
+ for (const quad of this) if (!other.has(quad)) dataset.add(quad);
71
+ return dataset;
72
+ }
73
+ /**
74
+ * Returns true if the current instance contains the same graph structure as the given dataset.
75
+ * @param other
76
+ */
77
+ equals(other) {
78
+ if (this.size !== other.size) return false;
79
+ for (const quad of this) if (!other.has(quad)) return false;
80
+ return true;
81
+ }
82
+ /**
83
+ * Universal quantification method, tests whether every quad in the dataset passes the test implemented by the provided iteratee.
84
+ * This method immediately returns boolean false once a quad that does not pass the test is found.
85
+ * This method always returns boolean true on an empty dataset.
86
+ * Note: This method is aligned with Array.prototype.every() in ECMAScript-262.
87
+ * @param iteratee
88
+ */
89
+ every(iteratee) {
90
+ for (const quad of this) if (!iteratee(quad, this)) return false;
91
+ return true;
92
+ }
93
+ /**
94
+ * Creates a new dataset with all the quads that pass the test implemented by the provided iteratee.
95
+ * Note: This method is aligned with Array.prototype.filter() in ECMAScript-262.
96
+ * @param iteratee
97
+ */
98
+ filter(iteratee) {
99
+ const dataset = this.createBlankDataset();
100
+ for (const quad of this) if (iteratee(quad, this)) dataset.add(quad);
101
+ return dataset;
102
+ }
103
+ /**
104
+ * Executes the provided iteratee once on each quad in the dataset.
105
+ * Note: This method is aligned with Array.prototype.forEach() in ECMAScript-262.
106
+ * @param iteratee
107
+ */
108
+ forEach(iteratee) {
109
+ for (const quad of this) iteratee(quad, this);
110
+ }
111
+ /**
112
+ * Imports all quads from the given stream into the dataset.
113
+ * The stream events end and error are wrapped in a Promise.
114
+ * @param stream
115
+ */
116
+ import(stream) {
117
+ return new Promise((resolve, reject) => {
118
+ stream.on("data", (quad) => {
119
+ this.add(quad);
120
+ }).on("end", () => {
121
+ resolve(this);
122
+ }).on("error", (err) => reject(err));
123
+ });
124
+ }
125
+ /**
126
+ * Returns a new dataset containing alls quads from the current dataset that are also included in the given dataset.
127
+ * @param other
128
+ */
129
+ intersection(other) {
130
+ const dataset = this.createBlankDataset();
131
+ const iteratingDataset = this.size < other.size ? this : other;
132
+ const comparingDataset = this.size < other.size ? other : this;
133
+ for (const quad of iteratingDataset) if (comparingDataset.has(quad)) dataset.add(quad);
134
+ return dataset;
135
+ }
136
+ /**
137
+ * Returns a new dataset containing all quads returned by applying iteratee to each quad in the current dataset.
138
+ * @param iteratee
139
+ */
140
+ map(iteratee) {
141
+ const dataset = this.createBlankDataset();
142
+ for (const quad of this) dataset.add(iteratee(quad, this));
143
+ return dataset;
144
+ }
145
+ /**
146
+ * This method calls the iteratee on each quad of the DatasetCore. 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.
147
+ * This method returns the return value of the last iteratee call.
148
+ * Note: This method is aligned with Array.prototype.reduce() in ECMAScript-262.
149
+ * @param iteratee
150
+ * @param initialValue
151
+ */
152
+ reduce(iteratee, initialValue) {
153
+ if (this.size === 0 && initialValue == void 0) throw new Error("Cannot reduce an empty Dataset without an initial value.");
154
+ const thisIterator = this[Symbol.iterator]();
155
+ let iteratorResult = thisIterator.next();
156
+ let accumulatedValue = initialValue;
157
+ while (!iteratorResult.done) {
158
+ accumulatedValue = iteratee(accumulatedValue, iteratorResult.value, this);
159
+ iteratorResult = thisIterator.next();
160
+ }
161
+ return accumulatedValue;
162
+ }
163
+ /**
164
+ * Existential quantification method, tests whether some quads in the dataset pass the test implemented by the provided iteratee.
165
+ * Note: This method is aligned with Array.prototype.some() in ECMAScript-262.
166
+ * @param iteratee
167
+ * @returns boolean true once a quad that passes the test is found.
168
+ */
169
+ some(iteratee) {
170
+ for (const quad of this) if (iteratee(quad, this)) return true;
171
+ return false;
172
+ }
173
+ /**
174
+ * Returns the set of quads within the dataset as a host language native sequence, for example an Array in ECMAScript-262.
175
+ * Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.
176
+ */
177
+ toArray() {
178
+ const array = [];
179
+ for (const quad of this) array.push(quad);
180
+ return array;
181
+ }
182
+ /**
183
+ * Returns an N-Quads string representation of the dataset, preprocessed with RDF Dataset Normalization algorithm.
184
+ */
185
+ toCanonical() {
186
+ throw new Error("Method not implemented.");
187
+ }
188
+ /**
189
+ * Returns a stream that contains all quads of the dataset.
190
+ */
191
+ toStream() {
192
+ const iterator = this[Symbol.iterator]();
193
+ let curNext = iterator.next();
194
+ const stream = new readable_stream.Readable({
195
+ objectMode: true,
196
+ read() {
197
+ if (curNext.done || !curNext.value) {
198
+ this.push(null);
199
+ return;
200
+ }
201
+ this.push(curNext.value);
202
+ curNext = iterator.next();
203
+ }
204
+ });
205
+ return stream;
206
+ }
207
+ /**
208
+ * Returns an N-Quads string representation of the dataset.
209
+ * No prior normalization is required, therefore the results for the same quads may vary depending on the Dataset implementation.
210
+ */
211
+ toString() {
212
+ return (0, __ldo_rdf_utils.datasetToString)(this, { format: "N-Triples" });
213
+ }
214
+ /**
215
+ * Returns a new Dataset that is a concatenation of this dataset and the quads given as an argument.
216
+ * @param other
217
+ */
218
+ union(other) {
219
+ const dataset = this.createBlankDataset();
220
+ for (const quad of this) dataset.add(quad);
221
+ for (const quad of other) dataset.add(quad);
222
+ return dataset;
223
+ }
224
+ /**
225
+ * This method returns a new dataset that is comprised of all quads in the current instance matching the given arguments. The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.
226
+ * @param subject
227
+ * @param predicate
228
+ * @param object
229
+ * @param graph
230
+ * @returns a Dataset with matching triples
231
+ */
232
+ match(subject, predicate, object, graph) {
233
+ return new ExtendedDataset(this.dataset.match(subject, predicate, object, graph), this.datasetCoreFactory);
234
+ }
235
+ /**
236
+ * A non-negative integer that specifies the number of quads in the set.
237
+ */
238
+ get size() {
239
+ return this.dataset.size;
240
+ }
241
+ /**
242
+ * Adds the specified quad to the dataset.
243
+ * Existing quads, as defined in Quad.equals, will be ignored.
244
+ * @param quad
245
+ * @returns the dataset instance it was called on.
246
+ */
247
+ add(quad) {
248
+ this.dataset.add(quad);
249
+ return this;
250
+ }
251
+ /**
252
+ * Removes the specified quad from the dataset.
253
+ * This method returns the dataset instance it was called on.
254
+ * @param quad
255
+ */
256
+ delete(quad) {
257
+ this.dataset.delete(quad);
258
+ return this;
259
+ }
260
+ /**
261
+ * Determines whether a dataset includes a certain quad, returning true or false as appropriate.
262
+ * @param quad
263
+ */
264
+ has(quad) {
265
+ return Boolean(this.dataset.has(quad));
266
+ }
267
+ /**
268
+ * Returns an iterator
269
+ */
270
+ [Symbol.iterator]() {
271
+ return this.dataset[Symbol.iterator]();
272
+ }
273
+ };
274
+
275
+ //#endregion
276
+ exports.ExtendedDataset = ExtendedDataset;
@@ -0,0 +1,170 @@
1
+ import { BaseQuad, Dataset, DatasetCore, DatasetCoreFactory, Stream, Term } from "@rdfjs/types";
2
+
3
+ //#region src/ExtendedDataset.d.ts
4
+
5
+ /**
6
+ * A full implementation of the RDF JS Dataset interface.
7
+ */
8
+ declare class ExtendedDataset<InAndOutQuad extends BaseQuad = BaseQuad> implements Dataset<InAndOutQuad, InAndOutQuad> {
9
+ /**
10
+ * The main backing dataset
11
+ */
12
+ protected dataset: DatasetCore<InAndOutQuad, InAndOutQuad>;
13
+ /**
14
+ * A factory that generates datasets for the methods
15
+ */
16
+ protected datasetCoreFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>;
17
+ /**
18
+ * Constructor
19
+ */
20
+ constructor(dataset: DatasetCore<InAndOutQuad, InAndOutQuad>, datasetFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>);
21
+ /**
22
+ * Creates a blank dataset using the dataset factory
23
+ */
24
+ private createBlankDataset;
25
+ /**
26
+ * Imports the quads into this dataset.
27
+ * 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.
28
+ * @param quads
29
+ * @returns the dataset instance it was called on.
30
+ */
31
+ addAll(quads: InAndOutQuad[] | Dataset<InAndOutQuad>): this;
32
+ /**
33
+ * 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.
34
+ * Blank Nodes will be normalized.
35
+ * @param other
36
+ */
37
+ contains(other: Dataset<InAndOutQuad>): boolean;
38
+ /**
39
+ * 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.
40
+ * @param subject
41
+ * @param predicate
42
+ * @param object
43
+ * @param graph
44
+ * @returns the dataset instance it was called on.
45
+ */
46
+ deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
47
+ /**
48
+ * Returns a new dataset that contains alls quads from the current dataset, not included in the given dataset.
49
+ * @param other
50
+ */
51
+ difference(other: DatasetCore<InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
52
+ /**
53
+ * Returns true if the current instance contains the same graph structure as the given dataset.
54
+ * @param other
55
+ */
56
+ equals(other: Dataset<InAndOutQuad, InAndOutQuad>): boolean;
57
+ /**
58
+ * Universal quantification method, tests whether every quad in the dataset passes the test implemented by the provided iteratee.
59
+ * This method immediately returns boolean false once a quad that does not pass the test is found.
60
+ * This method always returns boolean true on an empty dataset.
61
+ * Note: This method is aligned with Array.prototype.every() in ECMAScript-262.
62
+ * @param iteratee
63
+ */
64
+ every(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
65
+ /**
66
+ * Creates a new dataset with all the quads that pass the test implemented by the provided iteratee.
67
+ * Note: This method is aligned with Array.prototype.filter() in ECMAScript-262.
68
+ * @param iteratee
69
+ */
70
+ filter(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): Dataset<InAndOutQuad, InAndOutQuad>;
71
+ /**
72
+ * Executes the provided iteratee once on each quad in the dataset.
73
+ * Note: This method is aligned with Array.prototype.forEach() in ECMAScript-262.
74
+ * @param iteratee
75
+ */
76
+ forEach(iteratee: (quad: InAndOutQuad, dataset: this) => void): void;
77
+ /**
78
+ * Imports all quads from the given stream into the dataset.
79
+ * The stream events end and error are wrapped in a Promise.
80
+ * @param stream
81
+ */
82
+ import(stream: Stream<InAndOutQuad>): Promise<this>;
83
+ /**
84
+ * Returns a new dataset containing alls quads from the current dataset that are also included in the given dataset.
85
+ * @param other
86
+ */
87
+ intersection(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
88
+ /**
89
+ * Returns a new dataset containing all quads returned by applying iteratee to each quad in the current dataset.
90
+ * @param iteratee
91
+ */
92
+ map(iteratee: (quad: InAndOutQuad, dataset: this) => InAndOutQuad): Dataset<InAndOutQuad, InAndOutQuad>;
93
+ /**
94
+ * This method calls the iteratee on each quad of the DatasetCore. 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.
95
+ * This method returns the return value of the last iteratee call.
96
+ * Note: This method is aligned with Array.prototype.reduce() in ECMAScript-262.
97
+ * @param iteratee
98
+ * @param initialValue
99
+ */
100
+ reduce<A = unknown>(iteratee: (accumulator: A, quad: InAndOutQuad, dataset: this) => A, initialValue?: A): A;
101
+ /**
102
+ * Existential quantification method, tests whether some quads in the dataset pass the test implemented by the provided iteratee.
103
+ * Note: This method is aligned with Array.prototype.some() in ECMAScript-262.
104
+ * @param iteratee
105
+ * @returns boolean true once a quad that passes the test is found.
106
+ */
107
+ some(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
108
+ /**
109
+ * Returns the set of quads within the dataset as a host language native sequence, for example an Array in ECMAScript-262.
110
+ * Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.
111
+ */
112
+ toArray(): InAndOutQuad[];
113
+ /**
114
+ * Returns an N-Quads string representation of the dataset, preprocessed with RDF Dataset Normalization algorithm.
115
+ */
116
+ toCanonical(): string;
117
+ /**
118
+ * Returns a stream that contains all quads of the dataset.
119
+ */
120
+ toStream(): Stream<InAndOutQuad>;
121
+ /**
122
+ * Returns an N-Quads string representation of the dataset.
123
+ * No prior normalization is required, therefore the results for the same quads may vary depending on the Dataset implementation.
124
+ */
125
+ toString(): string;
126
+ /**
127
+ * Returns a new Dataset that is a concatenation of this dataset and the quads given as an argument.
128
+ * @param other
129
+ */
130
+ union(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
131
+ /**
132
+ * This method returns a new dataset that is comprised of all quads in the current instance matching the given arguments. The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.
133
+ * @param subject
134
+ * @param predicate
135
+ * @param object
136
+ * @param graph
137
+ * @returns a Dataset with matching triples
138
+ */
139
+ match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset<InAndOutQuad, InAndOutQuad>;
140
+ /**
141
+ * A non-negative integer that specifies the number of quads in the set.
142
+ */
143
+ get size(): number;
144
+ /**
145
+ * Adds the specified quad to the dataset.
146
+ * Existing quads, as defined in Quad.equals, will be ignored.
147
+ * @param quad
148
+ * @returns the dataset instance it was called on.
149
+ */
150
+ add(quad: InAndOutQuad): this;
151
+ /**
152
+ * Removes the specified quad from the dataset.
153
+ * This method returns the dataset instance it was called on.
154
+ * @param quad
155
+ */
156
+ delete(quad: InAndOutQuad): this;
157
+ /**
158
+ * Determines whether a dataset includes a certain quad, returning true or false as appropriate.
159
+ * @param quad
160
+ */
161
+ has(quad: InAndOutQuad): boolean;
162
+ /**
163
+ * Returns an iterator
164
+ */
165
+ [Symbol.iterator](): Iterator<InAndOutQuad, InAndOutQuad, undefined>;
166
+ }
167
+ //# sourceMappingURL=ExtendedDataset.d.ts.map
168
+ //#endregion
169
+ export { ExtendedDataset };
170
+ //# sourceMappingURL=ExtendedDataset.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtendedDataset.d.cts","names":[],"sources":["../../src/ExtendedDataset.ts"],"sourcesContent":[],"mappings":";;;;;;AAQsB;AAOc,cAAf,eAAe,CAAA,qBAAsB,QAAtB,GAAiC,QAAjC,CAAA,YACvB,OADuB,CACf,YADe,EACD,YADC,CAAA,CAAA;EAAA;;;EACH,UAAE,OAAA,EAKd,WALc,CAKF,YALE,EAKY,YALZ,CAAA;EAAY;;;EAKf,UAKmB,kBAAA,EAAnB,kBAAmB,CAAA,YAAA,EAAc,YAAd,CAAA;EAAY;;;EAM1B,WAAE,CAAA,OAAA,EAA1B,WAA0B,CAAd,YAAc,EAAA,YAAA,CAAA,EAAA,cAAA,EACnB,kBADmB,CACA,YADA,EACc,YADd,CAAA;EAAY;;;EACc,QAA7C,kBAAA;EAAkB;;;;;;EAuDpB,MACF,CAAA,KAAA,EAlCA,YAkCA,EAAA,GAlCiB,OAkCjB,CAlCyB,YAkCzB,CAAA,CAAA,EAAA,IAAA;EAAI;;;;;EAiBK,QAAE,CAAA,KAAA,EAvCT,OAuCS,CAvCD,YAuCC,CAAA,CAAA,EAAA,OAAA;EAAY;;;;;;;;EAiDA,aAAlC,CAAA,OAAA,CAAA,EAnES,IAmET,EAAA,SAAA,CAAA,EAlEW,IAkEX,EAAA,MAAA,CAAA,EAjEQ,IAiER,EAAA,KAAA,CAAA,EAhEO,IAgEP,CAAA,EAAA,IAAA;EAAO;;;;EA0BmC,UAkB5B,CAAA,KAAA,EA9FR,WA8FQ,CA9FI,YA8FJ,CAAA,CAAA,EA7Fd,OA6Fc,CA7FN,YA6FM,EA7FQ,YA6FR,CAAA;EAAY;;;;EACQ,MAAlC,CAAA,KAAA,EAhFW,OAgFX,CAhFmB,YAgFnB,EAhFiC,YAgFjC,CAAA,CAAA,EAAA,OAAA;EAAO;;;;;;;EAkCqC,KAAoB,CAAA,QAAA,EAAA,CAAA,IAAA,EA/F5C,YA+F4C,EAAA,OAAA,EAAA,IAAA,EAAA,GAAA,OAAA,CAAA,EAAA,OAAA;EAAC;;;;;EAuDrC,MAAnB,CAAA,QAAA,EAAA,CAAA,IAAA,EAvIO,YAuIP,EAAA,OAAA,EAAA,IAAA,EAAA,GAAA,OAAA,CAAA,EAtIT,OAsIS,CAtID,YAsIC,EAtIa,YAsIb,CAAA;EAAM;;;;;EA+BmB,OAAlC,CAAA,QAAA,EAAA,CAAA,IAAA,EAtJsB,YAsJtB,EAAA,OAAA,EAAA,IAAA,EAAA,GAAA,IAAA,CAAA,EAAA,IAAA;EAAO;;;;;EAwBa,MAAE,CAAA,MAAA,EAnKV,MAmKU,CAnKH,YAmKG,CAAA,CAAA,EAnKa,OAmKb,CAAA,IAAA,CAAA;EAAY;;;;EAuCR,YAOQ,CAAA,KAAA,EA/L5B,OA+L4B,CA/LpB,YA+LoB,EA/LN,YA+LM,CAAA,CAAA,EA9LlC,OA8LkC,CA9L1B,YA8L0B,EA9LZ,YA8LY,CAAA;EAAY;;;;EAtX/B,GAAA,CAAA,QAAA,EAAA,CAAA,IAAA,EAyMC,YAzMD,EAAA,OAAA,EAAA,IAAA,EAAA,GAyMiC,YAzMjC,CAAA,EA0Mf,OA1Me,CA0MP,YA1MO,EA0MO,YA1MP,CAAA;;;;;;;;8CA0NQ,SAAS,gCAAgC,kBAClD,IACd;;;;;;;wBAsBmB;;;;;aAaX;;;;;;;;cAkBC,OAAO;;;;;;;;;;eA8BV,QAAQ,cAAc,gBAC5B,QAAQ,cAAc;;;;;;;;;kBAoBb,yBACE,sBACH,qBACD,cACP,QAAQ,cAAc;;;;;;;;;;;YAoBR;;;;;;eAUG;;;;;YASH;;;;GAOT,MAAA,CAAO,QAAA,KAAa,SAAS,cAAc"}
@@ -1,31 +1,170 @@
1
- import { type DatasetCore, type Dataset, type BaseQuad, type Stream, type Term, type DatasetCoreFactory } from "@rdfjs/types";
2
- export default class ExtendedDataset<InAndOutQuad extends BaseQuad = BaseQuad> implements Dataset<InAndOutQuad, InAndOutQuad> {
3
- protected dataset: DatasetCore<InAndOutQuad, InAndOutQuad>;
4
- protected datasetCoreFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>;
5
- constructor(dataset: DatasetCore<InAndOutQuad, InAndOutQuad>, datasetFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>);
6
- private createBlankDataset;
7
- addAll(quads: InAndOutQuad[] | Dataset<InAndOutQuad>): this;
8
- contains(other: Dataset<InAndOutQuad>): boolean;
9
- deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
10
- difference(other: DatasetCore<InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
11
- equals(other: Dataset<InAndOutQuad, InAndOutQuad>): boolean;
12
- every(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
13
- filter(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): Dataset<InAndOutQuad, InAndOutQuad>;
14
- forEach(iteratee: (quad: InAndOutQuad, dataset: this) => void): void;
15
- import(stream: Stream<InAndOutQuad>): Promise<this>;
16
- intersection(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
17
- map(iteratee: (quad: InAndOutQuad, dataset: this) => InAndOutQuad): Dataset<InAndOutQuad, InAndOutQuad>;
18
- reduce<A = unknown>(iteratee: (accumulator: A, quad: InAndOutQuad, dataset: this) => A, initialValue?: A): A;
19
- some(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
20
- toArray(): InAndOutQuad[];
21
- toCanonical(): string;
22
- toStream(): Stream<InAndOutQuad>;
23
- toString(): string;
24
- union(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
25
- match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset<InAndOutQuad, InAndOutQuad>;
26
- get size(): number;
27
- add(quad: InAndOutQuad): this;
28
- delete(quad: InAndOutQuad): this;
29
- has(quad: InAndOutQuad): boolean;
30
- [Symbol.iterator](): Iterator<InAndOutQuad, InAndOutQuad, undefined>;
1
+ import { BaseQuad, Dataset, DatasetCore, DatasetCoreFactory, Stream, Term } from "@rdfjs/types";
2
+
3
+ //#region src/ExtendedDataset.d.ts
4
+
5
+ /**
6
+ * A full implementation of the RDF JS Dataset interface.
7
+ */
8
+ declare class ExtendedDataset<InAndOutQuad extends BaseQuad = BaseQuad> implements Dataset<InAndOutQuad, InAndOutQuad> {
9
+ /**
10
+ * The main backing dataset
11
+ */
12
+ protected dataset: DatasetCore<InAndOutQuad, InAndOutQuad>;
13
+ /**
14
+ * A factory that generates datasets for the methods
15
+ */
16
+ protected datasetCoreFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>;
17
+ /**
18
+ * Constructor
19
+ */
20
+ constructor(dataset: DatasetCore<InAndOutQuad, InAndOutQuad>, datasetFactory: DatasetCoreFactory<InAndOutQuad, InAndOutQuad>);
21
+ /**
22
+ * Creates a blank dataset using the dataset factory
23
+ */
24
+ private createBlankDataset;
25
+ /**
26
+ * Imports the quads into this dataset.
27
+ * 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.
28
+ * @param quads
29
+ * @returns the dataset instance it was called on.
30
+ */
31
+ addAll(quads: InAndOutQuad[] | Dataset<InAndOutQuad>): this;
32
+ /**
33
+ * 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.
34
+ * Blank Nodes will be normalized.
35
+ * @param other
36
+ */
37
+ contains(other: Dataset<InAndOutQuad>): boolean;
38
+ /**
39
+ * 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.
40
+ * @param subject
41
+ * @param predicate
42
+ * @param object
43
+ * @param graph
44
+ * @returns the dataset instance it was called on.
45
+ */
46
+ deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
47
+ /**
48
+ * Returns a new dataset that contains alls quads from the current dataset, not included in the given dataset.
49
+ * @param other
50
+ */
51
+ difference(other: DatasetCore<InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
52
+ /**
53
+ * Returns true if the current instance contains the same graph structure as the given dataset.
54
+ * @param other
55
+ */
56
+ equals(other: Dataset<InAndOutQuad, InAndOutQuad>): boolean;
57
+ /**
58
+ * Universal quantification method, tests whether every quad in the dataset passes the test implemented by the provided iteratee.
59
+ * This method immediately returns boolean false once a quad that does not pass the test is found.
60
+ * This method always returns boolean true on an empty dataset.
61
+ * Note: This method is aligned with Array.prototype.every() in ECMAScript-262.
62
+ * @param iteratee
63
+ */
64
+ every(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
65
+ /**
66
+ * Creates a new dataset with all the quads that pass the test implemented by the provided iteratee.
67
+ * Note: This method is aligned with Array.prototype.filter() in ECMAScript-262.
68
+ * @param iteratee
69
+ */
70
+ filter(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): Dataset<InAndOutQuad, InAndOutQuad>;
71
+ /**
72
+ * Executes the provided iteratee once on each quad in the dataset.
73
+ * Note: This method is aligned with Array.prototype.forEach() in ECMAScript-262.
74
+ * @param iteratee
75
+ */
76
+ forEach(iteratee: (quad: InAndOutQuad, dataset: this) => void): void;
77
+ /**
78
+ * Imports all quads from the given stream into the dataset.
79
+ * The stream events end and error are wrapped in a Promise.
80
+ * @param stream
81
+ */
82
+ import(stream: Stream<InAndOutQuad>): Promise<this>;
83
+ /**
84
+ * Returns a new dataset containing alls quads from the current dataset that are also included in the given dataset.
85
+ * @param other
86
+ */
87
+ intersection(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
88
+ /**
89
+ * Returns a new dataset containing all quads returned by applying iteratee to each quad in the current dataset.
90
+ * @param iteratee
91
+ */
92
+ map(iteratee: (quad: InAndOutQuad, dataset: this) => InAndOutQuad): Dataset<InAndOutQuad, InAndOutQuad>;
93
+ /**
94
+ * This method calls the iteratee on each quad of the DatasetCore. 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.
95
+ * This method returns the return value of the last iteratee call.
96
+ * Note: This method is aligned with Array.prototype.reduce() in ECMAScript-262.
97
+ * @param iteratee
98
+ * @param initialValue
99
+ */
100
+ reduce<A = unknown>(iteratee: (accumulator: A, quad: InAndOutQuad, dataset: this) => A, initialValue?: A): A;
101
+ /**
102
+ * Existential quantification method, tests whether some quads in the dataset pass the test implemented by the provided iteratee.
103
+ * Note: This method is aligned with Array.prototype.some() in ECMAScript-262.
104
+ * @param iteratee
105
+ * @returns boolean true once a quad that passes the test is found.
106
+ */
107
+ some(iteratee: (quad: InAndOutQuad, dataset: this) => boolean): boolean;
108
+ /**
109
+ * Returns the set of quads within the dataset as a host language native sequence, for example an Array in ECMAScript-262.
110
+ * Note: Since a DatasetCore is an unordered set, the order of the quads within the returned sequence is arbitrary.
111
+ */
112
+ toArray(): InAndOutQuad[];
113
+ /**
114
+ * Returns an N-Quads string representation of the dataset, preprocessed with RDF Dataset Normalization algorithm.
115
+ */
116
+ toCanonical(): string;
117
+ /**
118
+ * Returns a stream that contains all quads of the dataset.
119
+ */
120
+ toStream(): Stream<InAndOutQuad>;
121
+ /**
122
+ * Returns an N-Quads string representation of the dataset.
123
+ * No prior normalization is required, therefore the results for the same quads may vary depending on the Dataset implementation.
124
+ */
125
+ toString(): string;
126
+ /**
127
+ * Returns a new Dataset that is a concatenation of this dataset and the quads given as an argument.
128
+ * @param other
129
+ */
130
+ union(other: Dataset<InAndOutQuad, InAndOutQuad>): Dataset<InAndOutQuad, InAndOutQuad>;
131
+ /**
132
+ * This method returns a new dataset that is comprised of all quads in the current instance matching the given arguments. The logic described in Quad Matching is applied for each quad in this dataset to check if it should be included in the output dataset.
133
+ * @param subject
134
+ * @param predicate
135
+ * @param object
136
+ * @param graph
137
+ * @returns a Dataset with matching triples
138
+ */
139
+ match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset<InAndOutQuad, InAndOutQuad>;
140
+ /**
141
+ * A non-negative integer that specifies the number of quads in the set.
142
+ */
143
+ get size(): number;
144
+ /**
145
+ * Adds the specified quad to the dataset.
146
+ * Existing quads, as defined in Quad.equals, will be ignored.
147
+ * @param quad
148
+ * @returns the dataset instance it was called on.
149
+ */
150
+ add(quad: InAndOutQuad): this;
151
+ /**
152
+ * Removes the specified quad from the dataset.
153
+ * This method returns the dataset instance it was called on.
154
+ * @param quad
155
+ */
156
+ delete(quad: InAndOutQuad): this;
157
+ /**
158
+ * Determines whether a dataset includes a certain quad, returning true or false as appropriate.
159
+ * @param quad
160
+ */
161
+ has(quad: InAndOutQuad): boolean;
162
+ /**
163
+ * Returns an iterator
164
+ */
165
+ [Symbol.iterator](): Iterator<InAndOutQuad, InAndOutQuad, undefined>;
31
166
  }
167
+ //# sourceMappingURL=ExtendedDataset.d.ts.map
168
+ //#endregion
169
+ export { ExtendedDataset as ExtendedDataset$1 };
170
+ //# sourceMappingURL=ExtendedDataset.d.ts.map