@ldo/subscribable-dataset 1.0.0-alpha.51 → 1.0.0-alpha.53

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 (82) hide show
  1. package/dist/{SubscribableDataset.d.cts → SubscribableDataset.d.ts} +5 -5
  2. package/dist/SubscribableDataset.d.ts.map +1 -0
  3. package/dist/{SubscribableDataset.mjs → SubscribableDataset.js} +1 -1
  4. package/dist/SubscribableDataset.js.map +1 -0
  5. package/dist/{SubscribableDatasetFactory.d.cts → SubscribableDatasetFactory.d.ts} +3 -3
  6. package/dist/SubscribableDatasetFactory.d.ts.map +1 -0
  7. package/dist/{SubscribableDatasetFactory.mjs → SubscribableDatasetFactory.js} +2 -2
  8. package/dist/SubscribableDatasetFactory.js.map +1 -0
  9. package/dist/{TransactionDataset.d.mts → TransactionDataset.d.ts} +3 -3
  10. package/dist/TransactionDataset.d.ts.map +1 -0
  11. package/dist/{TransactionDataset.mjs → TransactionDataset.js} +4 -4
  12. package/dist/TransactionDataset.js.map +1 -0
  13. package/dist/{TransactionDatasetFactory.d.cts → TransactionDatasetFactory.d.ts} +3 -3
  14. package/dist/TransactionDatasetFactory.d.ts.map +1 -0
  15. package/dist/{TransactionDatasetFactory.mjs → TransactionDatasetFactory.js} +2 -2
  16. package/dist/TransactionDatasetFactory.js.map +1 -0
  17. package/dist/{createSubscribableDataset.d.mts → createSubscribableDataset.d.ts} +2 -2
  18. package/dist/createSubscribableDataset.d.ts.map +1 -0
  19. package/dist/{createSubscribableDataset.mjs → createSubscribableDataset.js} +3 -3
  20. package/dist/createSubscribableDataset.js.map +1 -0
  21. package/dist/{createSubscribableDatasetFromSerializedInput.d.cts → createSubscribableDatasetFromSerializedInput.d.ts} +3 -3
  22. package/dist/createSubscribableDatasetFromSerializedInput.d.ts.map +1 -0
  23. package/dist/{createSubscribableDatasetFromSerializedInput.mjs → createSubscribableDatasetFromSerializedInput.js} +2 -2
  24. package/dist/createSubscribableDatasetFromSerializedInput.js.map +1 -0
  25. package/dist/{index.d.cts → index.d.ts} +9 -9
  26. package/dist/{index.mjs → index.js} +8 -8
  27. package/dist/{mergeDatasetChanges.d.cts → mergeDatasetChanges.d.ts} +2 -2
  28. package/dist/mergeDatasetChanges.d.ts.map +1 -0
  29. package/dist/{mergeDatasetChanges.mjs → mergeDatasetChanges.js} +1 -1
  30. package/dist/mergeDatasetChanges.js.map +1 -0
  31. package/dist/{types.d.cts → types.d.ts} +2 -2
  32. package/dist/types.d.ts.map +1 -0
  33. package/dist/{util.d.mts → util.d.ts} +1 -1
  34. package/dist/util.d.ts.map +1 -0
  35. package/dist/{util.mjs → util.js} +1 -1
  36. package/dist/util.js.map +1 -0
  37. package/package.json +11 -15
  38. package/dist/SubscribableDataset.cjs +0 -353
  39. package/dist/SubscribableDataset.d.cts.map +0 -1
  40. package/dist/SubscribableDataset.d.mts +0 -170
  41. package/dist/SubscribableDataset.d.mts.map +0 -1
  42. package/dist/SubscribableDataset.mjs.map +0 -1
  43. package/dist/SubscribableDatasetFactory.cjs +0 -16
  44. package/dist/SubscribableDatasetFactory.d.cts.map +0 -1
  45. package/dist/SubscribableDatasetFactory.d.mts +0 -17
  46. package/dist/SubscribableDatasetFactory.d.mts.map +0 -1
  47. package/dist/SubscribableDatasetFactory.mjs.map +0 -1
  48. package/dist/TransactionDataset.cjs +0 -195
  49. package/dist/TransactionDataset.d.cts +0 -131
  50. package/dist/TransactionDataset.d.cts.map +0 -1
  51. package/dist/TransactionDataset.d.mts.map +0 -1
  52. package/dist/TransactionDataset.mjs.map +0 -1
  53. package/dist/TransactionDatasetFactory.cjs +0 -13
  54. package/dist/TransactionDatasetFactory.d.cts.map +0 -1
  55. package/dist/TransactionDatasetFactory.d.mts +0 -14
  56. package/dist/TransactionDatasetFactory.d.mts.map +0 -1
  57. package/dist/TransactionDatasetFactory.mjs.map +0 -1
  58. package/dist/createSubscribableDataset.cjs +0 -33
  59. package/dist/createSubscribableDataset.d.cts +0 -23
  60. package/dist/createSubscribableDataset.d.cts.map +0 -1
  61. package/dist/createSubscribableDataset.d.mts.map +0 -1
  62. package/dist/createSubscribableDataset.mjs.map +0 -1
  63. package/dist/createSubscribableDatasetFromSerializedInput.cjs +0 -19
  64. package/dist/createSubscribableDatasetFromSerializedInput.d.cts.map +0 -1
  65. package/dist/createSubscribableDatasetFromSerializedInput.d.mts +0 -20
  66. package/dist/createSubscribableDatasetFromSerializedInput.d.mts.map +0 -1
  67. package/dist/createSubscribableDatasetFromSerializedInput.mjs.map +0 -1
  68. package/dist/index.cjs +0 -19
  69. package/dist/index.d.mts +0 -10
  70. package/dist/mergeDatasetChanges.cjs +0 -24
  71. package/dist/mergeDatasetChanges.d.cts.map +0 -1
  72. package/dist/mergeDatasetChanges.d.mts +0 -13
  73. package/dist/mergeDatasetChanges.d.mts.map +0 -1
  74. package/dist/mergeDatasetChanges.mjs.map +0 -1
  75. package/dist/types.d.cts.map +0 -1
  76. package/dist/types.d.mts +0 -123
  77. package/dist/types.d.mts.map +0 -1
  78. package/dist/util.cjs +0 -17
  79. package/dist/util.d.cts +0 -13
  80. package/dist/util.d.cts.map +0 -1
  81. package/dist/util.d.mts.map +0 -1
  82. package/dist/util.mjs.map +0 -1
@@ -1,353 +0,0 @@
1
- let _ldo_dataset = require("@ldo/dataset");
2
- let events = require("events");
3
- let _ldo_rdf_utils = require("@ldo/rdf-utils");
4
- let uuid = require("uuid");
5
- //#region src/SubscribableDataset.ts
6
- /**
7
- * A wrapper for a dataset that allows subscriptions to be made on nodes to
8
- * be triggered whenever a quad containing that added or removed.
9
- */
10
- var SubscribableDataset = class extends _ldo_dataset.ExtendedDataset {
11
- /**
12
- * @param datasetFactory A RDF/JS Dataset Factory
13
- * @param initialDataset An RDF/JS Dataset with initial Quads
14
- */
15
- constructor(datasetFactory, transactionDatasetFactory, initialDataset) {
16
- super(initialDataset || datasetFactory.dataset(), datasetFactory);
17
- this.listenerHashMap = /* @__PURE__ */ new Map();
18
- this.transactionDatasetFactory = transactionDatasetFactory;
19
- this.eventEmitter = new events.EventEmitter();
20
- this.datasetFactory = datasetFactory;
21
- }
22
- /**
23
- * ==================================================================
24
- * DATASET METHODS
25
- * ==================================================================
26
- */
27
- /**
28
- * A helper method that mimics what the super of addAll would be
29
- */
30
- superAddAll(quads) {
31
- for (const quad of quads) super.add(quad);
32
- return this;
33
- }
34
- /**
35
- * Imports the quads into this dataset.
36
- * 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.
37
- * @param quads
38
- * @returns the dataset instance it was called on.
39
- */
40
- addAll(quads) {
41
- this.superAddAll(quads);
42
- this.triggerSubscriptionForQuads({ added: this.datasetFactory.dataset(quads) });
43
- return this;
44
- }
45
- /**
46
- * Bulk add and remove triples
47
- * @param changed
48
- */
49
- bulk(changed) {
50
- if (changed.added) this.superAddAll(changed.added);
51
- if (changed.removed) changed.removed.forEach((quad) => {
52
- super.delete(quad);
53
- });
54
- this.triggerSubscriptionForQuads(changed);
55
- return this;
56
- }
57
- /**
58
- * 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.
59
- * @param subject
60
- * @param predicate
61
- * @param object
62
- * @param graph
63
- * @returns the dataset instance it was called on.
64
- */
65
- deleteMatches(subject, predicate, object, graph) {
66
- const matching = super.match(subject, predicate, object, graph);
67
- for (const quad of matching) super.delete(quad);
68
- this.triggerSubscriptionForQuads({ removed: matching });
69
- return this;
70
- }
71
- /**
72
- * Adds the specified quad to the dataset.
73
- * Existing quads, as defined in Quad.equals, will be ignored.
74
- * @param quad
75
- * @returns the dataset instance it was called on.
76
- */
77
- add(quad) {
78
- super.add(quad);
79
- this.triggerSubscriptionForQuads({ added: this.datasetFactory.dataset([quad]) });
80
- return this;
81
- }
82
- /**
83
- * Removes the specified quad from the dataset.
84
- * This method returns the dataset instance it was called on.
85
- * @param quad
86
- */
87
- delete(quad) {
88
- super.delete(quad);
89
- this.triggerSubscriptionForQuads({ removed: this.datasetFactory.dataset([quad]) });
90
- return this;
91
- }
92
- /**
93
- * ==================================================================
94
- * EVENTEMITTER METHODS
95
- * ==================================================================
96
- */
97
- /**
98
- * Triggers all subscriptions based on an updated quads
99
- * @param changed The changed triples of the transaction
100
- */
101
- triggerSubscriptionForQuads(changed) {
102
- const matchingDatasetChanges = {};
103
- const populateMatchingDatasetChanges = (changeType) => {
104
- changed[changeType]?.forEach((changedQuad) => {
105
- const quad = changedQuad;
106
- [
107
- [
108
- null,
109
- null,
110
- null,
111
- null
112
- ],
113
- [
114
- quad.subject,
115
- null,
116
- null,
117
- null
118
- ],
119
- [
120
- quad.subject,
121
- quad.predicate,
122
- null,
123
- null
124
- ],
125
- [
126
- quad.subject,
127
- null,
128
- quad.object,
129
- null
130
- ],
131
- [
132
- null,
133
- quad.predicate,
134
- null,
135
- null
136
- ],
137
- [
138
- null,
139
- quad.predicate,
140
- quad.object,
141
- null
142
- ],
143
- [
144
- null,
145
- null,
146
- quad.object,
147
- null
148
- ],
149
- [
150
- quad.subject,
151
- quad.predicate,
152
- quad.object,
153
- null
154
- ],
155
- [
156
- null,
157
- null,
158
- null,
159
- quad.graph
160
- ],
161
- [
162
- quad.subject,
163
- null,
164
- null,
165
- quad.graph
166
- ],
167
- [
168
- quad.subject,
169
- quad.predicate,
170
- null,
171
- quad.graph
172
- ],
173
- [
174
- quad.subject,
175
- null,
176
- quad.object,
177
- quad.graph
178
- ],
179
- [
180
- null,
181
- quad.predicate,
182
- null,
183
- quad.graph
184
- ],
185
- [
186
- null,
187
- quad.predicate,
188
- quad.object,
189
- quad.graph
190
- ],
191
- [
192
- null,
193
- null,
194
- quad.object,
195
- quad.graph
196
- ],
197
- [
198
- quad.subject,
199
- quad.predicate,
200
- quad.object,
201
- quad.graph
202
- ]
203
- ].forEach((quadMatch) => {
204
- const eventName = (0, _ldo_rdf_utils.quadMatchToString)(quadMatch);
205
- if (this.eventEmitter.listenerCount(eventName) > 0) {
206
- if (!matchingDatasetChanges[eventName]) matchingDatasetChanges[eventName] = {
207
- triggerQuadMatch: quadMatch,
208
- changes: {}
209
- };
210
- if (!matchingDatasetChanges[eventName].changes[changeType]) matchingDatasetChanges[eventName].changes[changeType] = this.datasetFactory.dataset();
211
- matchingDatasetChanges[eventName].changes[changeType]?.add(changedQuad);
212
- }
213
- });
214
- });
215
- };
216
- populateMatchingDatasetChanges("added");
217
- populateMatchingDatasetChanges("removed");
218
- const transactionId = (0, uuid.v4)();
219
- Object.entries(matchingDatasetChanges).forEach(([quadMatchString, info]) => {
220
- this.eventEmitter.emit(quadMatchString, info.changes, transactionId, info.triggerQuadMatch);
221
- });
222
- }
223
- /**
224
- * Alias for emitter.on(eventName, listener).
225
- * @param eventName
226
- * @param listener
227
- * @returns
228
- */
229
- addListener(eventName, listener) {
230
- return this.on(eventName, listener);
231
- }
232
- /**
233
- * Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
234
- * @param eventName
235
- * @param dataset
236
- * @param datasetChanges
237
- * @returns true if the event had listeners, false otherwise.
238
- */
239
- emit(eventName, changes) {
240
- return this.eventEmitter.emit((0, _ldo_rdf_utils.quadMatchToString)(eventName), changes);
241
- }
242
- /**
243
- * Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.
244
- */
245
- eventNames() {
246
- return this.eventEmitter.eventNames().map((eventName) => (0, _ldo_rdf_utils.stringToQuadMatch)(eventName));
247
- }
248
- /**
249
- * Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to events.defaultMaxListeners.
250
- */
251
- getMaxListeners() {
252
- return this.eventEmitter.getMaxListeners();
253
- }
254
- /**
255
- * Returns the number of listeners listening to the event named eventName.
256
- */
257
- listenerCount(eventName) {
258
- return this.eventEmitter.listenerCount((0, _ldo_rdf_utils.quadMatchToString)(eventName));
259
- }
260
- /**
261
- * Returns a copy of the array of listeners for the event named eventName.
262
- */
263
- listeners(eventName) {
264
- return this.eventEmitter.listeners((0, _ldo_rdf_utils.quadMatchToString)(eventName));
265
- }
266
- /**
267
- * Alias for emitter.removeListener()
268
- */
269
- off(eventName, listener) {
270
- this.removeListener(eventName, listener);
271
- }
272
- /**
273
- * Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
274
- */
275
- on(eventName, listener) {
276
- const eventString = (0, _ldo_rdf_utils.quadMatchToString)(eventName);
277
- if (!this.listenerHashMap.has(listener)) this.listenerHashMap.set(listener, /* @__PURE__ */ new Set());
278
- this.listenerHashMap.get(listener)?.add(eventString);
279
- this.eventEmitter.on(eventString, listener);
280
- return this;
281
- }
282
- /**
283
- * Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
284
- */
285
- once(eventName, listener) {
286
- this.eventEmitter.once((0, _ldo_rdf_utils.quadMatchToString)(eventName), listener);
287
- return this;
288
- }
289
- /**
290
- * Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
291
- */
292
- prependListener(eventName, listener) {
293
- this.eventEmitter.prependListener((0, _ldo_rdf_utils.quadMatchToString)(eventName), listener);
294
- return this;
295
- }
296
- /**
297
- * Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.
298
- */
299
- prependOnceListener(eventName, listener) {
300
- this.eventEmitter.prependOnceListener((0, _ldo_rdf_utils.quadMatchToString)(eventName), listener);
301
- return this;
302
- }
303
- /**
304
- * Removes all listeners, or those of the specified eventName.
305
- */
306
- removeAllListeners(eventName) {
307
- this.eventEmitter.removeAllListeners((0, _ldo_rdf_utils.quadMatchToString)(eventName));
308
- return this;
309
- }
310
- /**
311
- * Removes the specified listener from the listener array for the event named eventName.
312
- */
313
- removeListener(eventName, listener) {
314
- this.eventEmitter.removeListener((0, _ldo_rdf_utils.quadMatchToString)(eventName), listener);
315
- return this;
316
- }
317
- /**
318
- * Removes the specified listener from the listener array for the event named eventName.
319
- */
320
- removeListenerFromAllEvents(listener) {
321
- const eventStringSet = this.listenerHashMap.get(listener);
322
- if (eventStringSet) eventStringSet.forEach((eventString) => {
323
- this.eventEmitter.off(eventString, listener);
324
- });
325
- return this;
326
- }
327
- /**
328
- * By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.
329
- */
330
- setMaxListeners(n) {
331
- this.eventEmitter.setMaxListeners(n);
332
- return this;
333
- }
334
- /**
335
- * Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).
336
- */
337
- rawListeners(eventName) {
338
- return this.eventEmitter.rawListeners((0, _ldo_rdf_utils.quadMatchToString)(eventName));
339
- }
340
- /**
341
- * ==================================================================
342
- * TRANSACTION METHODS
343
- * ==================================================================
344
- */
345
- /**
346
- * Returns a transactional dataset that will update this dataset when its transaction is committed.
347
- */
348
- startTransaction() {
349
- return this.transactionDatasetFactory.transactionDataset(this);
350
- }
351
- };
352
- //#endregion
353
- exports.SubscribableDataset = SubscribableDataset;
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDataset.d.cts","names":[],"sources":["../src/SubscribableDataset.ts"],"mappings":";;;;;;;;;AAwBA;;cAAa,mBAAA,sBAAyC,QAAA,GAAW,QAAA,UACvD,eAAA,CAAgB,YAAA,aACb,oBAAA,CAAqB,YAAA;EAFoB;;;EAAA,UAO1C,cAAA,EAAgB,cAAA,CAAe,YAAA;EAAA;;;EAAA,UAK/B,YAAA,EAAc,YAAA;EAIa;;;EAAA,UAA3B,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;EAIrC;;;EAAA,UAAjB,eAAA,EAAiB,GAAA,CAAI,iBAAA,CAAkB,YAAA,GAAe,GAAA;EASR;;;;cADtD,cAAA,EAAgB,cAAA,CAAe,YAAA,EAAc,YAAA,GAC7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ACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EA3O5B;;;EAoPK,mBAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EApP5B;;;EAgQK,kBAAA,CAAmB,SAAA,EAAW,SAAA;EA/OpB;;;EAuPV,cAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EA5OhB;;;EAqPd,2BAAA,CAA4B,QAAA,EAAU,iBAAA,CAAkB,YAAA;EAlOtD;;;EA+OK,eAAA,CAAgB,CAAA;EApJX;;;EA4JL,YAAA,CAAa,SAAA,EAAW,SAAA,GAAY,iBAAA,CAAkB,YAAA;EA/IhD;;;;;EASN;;;EAqJA,gBAAA,CAAA,GAAoB,mBAAA,CAAoB,YAAA;AAAA"}
@@ -1,170 +0,0 @@
1
- import { ISubscribableDataset, ITransactionDataset, ITransactionDatasetFactory, nodeEventListener } from "./types.mjs";
2
- import { ExtendedDataset } from "@ldo/dataset";
3
- import { EventEmitter } from "events";
4
- import { DatasetChanges, QuadMatch } from "@ldo/rdf-utils";
5
- import { BaseQuad, Dataset, DatasetFactory, Term } from "@rdfjs/types";
6
-
7
- //#region src/SubscribableDataset.d.ts
8
- /**
9
- * A wrapper for a dataset that allows subscriptions to be made on nodes to
10
- * be triggered whenever a quad containing that added or removed.
11
- */
12
- declare class SubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad> extends ExtendedDataset<InAndOutQuad> implements ISubscribableDataset<InAndOutQuad> {
13
- /**
14
- * DatasetFactory for creating new datasets
15
- */
16
- protected datasetFactory: DatasetFactory<InAndOutQuad>;
17
- /**
18
- * The underlying event emitter
19
- */
20
- protected eventEmitter: EventEmitter;
21
- /**
22
- * The underlying dataset factory for creating transaction datasets
23
- */
24
- protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;
25
- /**
26
- * Helps find all the events for a given listener
27
- */
28
- protected listenerHashMap: Map<nodeEventListener<InAndOutQuad>, Set<string>>;
29
- /**
30
- * @param datasetFactory A RDF/JS Dataset Factory
31
- * @param initialDataset An RDF/JS Dataset with initial Quads
32
- */
33
- constructor(datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>, transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>, initialDataset?: Dataset<InAndOutQuad, InAndOutQuad>);
34
- /**
35
- * ==================================================================
36
- * DATASET METHODS
37
- * ==================================================================
38
- */
39
- /**
40
- * A helper method that mimics what the super of addAll would be
41
- */
42
- private superAddAll;
43
- /**
44
- * Imports the quads into this dataset.
45
- * 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.
46
- * @param quads
47
- * @returns the dataset instance it was called on.
48
- */
49
- addAll(quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[]): this;
50
- /**
51
- * Bulk add and remove triples
52
- * @param changed
53
- */
54
- bulk(changed: DatasetChanges<InAndOutQuad>): this;
55
- /**
56
- * 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.
57
- * @param subject
58
- * @param predicate
59
- * @param object
60
- * @param graph
61
- * @returns the dataset instance it was called on.
62
- */
63
- deleteMatches(subject?: Term, predicate?: Term, object?: Term, graph?: Term): this;
64
- /**
65
- * Adds the specified quad to the dataset.
66
- * Existing quads, as defined in Quad.equals, will be ignored.
67
- * @param quad
68
- * @returns the dataset instance it was called on.
69
- */
70
- add(quad: InAndOutQuad): this;
71
- /**
72
- * Removes the specified quad from the dataset.
73
- * This method returns the dataset instance it was called on.
74
- * @param quad
75
- */
76
- delete(quad: InAndOutQuad): this;
77
- /**
78
- * ==================================================================
79
- * EVENTEMITTER METHODS
80
- * ==================================================================
81
- */
82
- /**
83
- * Triggers all subscriptions based on an updated quads
84
- * @param changed The changed triples of the transaction
85
- */
86
- protected triggerSubscriptionForQuads(changed: DatasetChanges<InAndOutQuad>): void;
87
- /**
88
- * Alias for emitter.on(eventName, listener).
89
- * @param eventName
90
- * @param listener
91
- * @returns
92
- */
93
- addListener(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
94
- /**
95
- * Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.
96
- * @param eventName
97
- * @param dataset
98
- * @param datasetChanges
99
- * @returns true if the event had listeners, false otherwise.
100
- */
101
- emit(eventName: QuadMatch, changes: DatasetChanges<InAndOutQuad>): boolean;
102
- /**
103
- * Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.
104
- */
105
- eventNames(): QuadMatch[];
106
- /**
107
- * Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to events.defaultMaxListeners.
108
- */
109
- getMaxListeners(): number;
110
- /**
111
- * Returns the number of listeners listening to the event named eventName.
112
- */
113
- listenerCount(eventName: QuadMatch): number;
114
- /**
115
- * Returns a copy of the array of listeners for the event named eventName.
116
- */
117
- listeners(eventName: QuadMatch): nodeEventListener<InAndOutQuad>[];
118
- /**
119
- * Alias for emitter.removeListener()
120
- */
121
- off(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): void;
122
- /**
123
- * Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
124
- */
125
- on(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
126
- /**
127
- * Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.
128
- */
129
- once(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
130
- /**
131
- * Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.
132
- */
133
- prependListener(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
134
- /**
135
- * Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.
136
- */
137
- prependOnceListener(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
138
- /**
139
- * Removes all listeners, or those of the specified eventName.
140
- */
141
- removeAllListeners(eventName: QuadMatch): this;
142
- /**
143
- * Removes the specified listener from the listener array for the event named eventName.
144
- */
145
- removeListener(eventName: QuadMatch, listener: nodeEventListener<InAndOutQuad>): this;
146
- /**
147
- * Removes the specified listener from the listener array for the event named eventName.
148
- */
149
- removeListenerFromAllEvents(listener: nodeEventListener<InAndOutQuad>): this;
150
- /**
151
- * By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.
152
- */
153
- setMaxListeners(n: number): this;
154
- /**
155
- * Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).
156
- */
157
- rawListeners(eventName: QuadMatch): nodeEventListener<InAndOutQuad>[];
158
- /**
159
- * ==================================================================
160
- * TRANSACTION METHODS
161
- * ==================================================================
162
- */
163
- /**
164
- * Returns a transactional dataset that will update this dataset when its transaction is committed.
165
- */
166
- startTransaction(): ITransactionDataset<InAndOutQuad>;
167
- }
168
- //#endregion
169
- export { SubscribableDataset };
170
- //# sourceMappingURL=SubscribableDataset.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDataset.d.mts","names":[],"sources":["../src/SubscribableDataset.ts"],"mappings":";;;;;;;;;AAwBA;;cAAa,mBAAA,sBAAyC,QAAA,GAAW,QAAA,UACvD,eAAA,CAAgB,YAAA,aACb,oBAAA,CAAqB,YAAA;EAFoB;;;EAAA,UAO1C,cAAA,EAAgB,cAAA,CAAe,YAAA;EAAA;;;EAAA,UAK/B,YAAA,EAAc,YAAA;EAIa;;;EAAA,UAA3B,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;EAIrC;;;EAAA,UAAjB,eAAA,EAAiB,GAAA,CAAI,iBA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IAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EAtPM;;;EA+P7B,eAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EA3O5B;;;EAoPK,mBAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EApP5B;;;EAgQK,kBAAA,CAAmB,SAAA,EAAW,SAAA;EA/OpB;;;EAuPV,cAAA,CACL,SAAA,EAAW,SAAA,EACX,QAAA,EAAU,iBAAA,CAAkB,YAAA;EA5OhB;;;EAqPd,2BAAA,CAA4B,QAAA,EAAU,iBAAA,CAAkB,YAAA;EAlOtD;;;EA+OK,eAAA,CAAgB,CAAA;EApJX;;;EA4JL,YAAA,CAAa,SAAA,EAAW,SAAA,GAAY,iBAAA,CAAkB,YAAA;EA/IhD;;;;;EASN;;;EAqJA,gBAAA,CAAA,GAAoB,mBAAA,CAAoB,YAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDataset.mjs","names":[],"sources":["../src/SubscribableDataset.ts"],"sourcesContent":["import { EventEmitter } from \"events\";\nimport { quadMatchToString, stringToQuadMatch } from \"@ldo/rdf-utils\";\nimport type {\n DatasetChanges,\n QuadMatch,\n SubjectNode,\n PredicateNode,\n ObjectNode,\n GraphNode,\n} from \"@ldo/rdf-utils\";\nimport type { Dataset, BaseQuad, Term, DatasetFactory } from \"@rdfjs/types\";\nimport type {\n nodeEventListener,\n ISubscribableDataset,\n ITransactionDataset,\n ITransactionDatasetFactory,\n} from \"./types\";\nimport { ExtendedDataset } from \"@ldo/dataset\";\nimport { v4 } from \"uuid\";\n\n/**\n * A wrapper for a dataset that allows subscriptions to be made on nodes to\n * be triggered whenever a quad containing that added or removed.\n */\nexport class SubscribableDataset<InAndOutQuad extends BaseQuad = BaseQuad>\n extends ExtendedDataset<InAndOutQuad>\n implements ISubscribableDataset<InAndOutQuad>\n{\n /**\n * DatasetFactory for creating new datasets\n */\n protected datasetFactory: DatasetFactory<InAndOutQuad>;\n\n /**\n * The underlying event emitter\n */\n protected eventEmitter: EventEmitter;\n /**\n * The underlying dataset factory for creating transaction datasets\n */\n protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;\n /**\n * Helps find all the events for a given listener\n */\n protected listenerHashMap: Map<nodeEventListener<InAndOutQuad>, Set<string>> =\n new Map();\n\n /**\n * @param datasetFactory A RDF/JS Dataset Factory\n * @param initialDataset An RDF/JS Dataset with initial Quads\n */\n constructor(\n datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>,\n transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>,\n initialDataset?: Dataset<InAndOutQuad, InAndOutQuad>,\n ) {\n super(initialDataset || datasetFactory.dataset(), datasetFactory);\n this.transactionDatasetFactory = transactionDatasetFactory;\n this.eventEmitter = new EventEmitter();\n this.datasetFactory = datasetFactory;\n }\n\n /**\n * ==================================================================\n * DATASET METHODS\n * ==================================================================\n */\n\n /**\n * A helper method that mimics what the super of addAll would be\n */\n private superAddAll(\n quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],\n ): this {\n for (const quad of quads) {\n super.add(quad);\n }\n return this;\n }\n\n /**\n * Imports the quads into this dataset.\n * 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.\n * @param quads\n * @returns the dataset instance it was called on.\n */\n public addAll(\n quads: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],\n ): this {\n this.superAddAll(quads);\n this.triggerSubscriptionForQuads({\n added: this.datasetFactory.dataset(quads),\n });\n return this;\n }\n\n /**\n * Bulk add and remove triples\n * @param changed\n */\n public bulk(changed: DatasetChanges<InAndOutQuad>): this {\n if (changed.added) {\n this.superAddAll(changed.added);\n }\n if (changed.removed) {\n changed.removed.forEach((quad) => {\n super.delete(quad);\n });\n }\n this.triggerSubscriptionForQuads(changed);\n return this;\n }\n\n /**\n * 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.\n * @param subject\n * @param predicate\n * @param object\n * @param graph\n * @returns the dataset instance it was called on.\n */\n public deleteMatches(\n subject?: Term,\n predicate?: Term,\n object?: Term,\n graph?: Term,\n ): this {\n const matching = super.match(subject, predicate, object, graph);\n for (const quad of matching) {\n super.delete(quad);\n }\n this.triggerSubscriptionForQuads({ removed: matching });\n return this;\n }\n\n /**\n * Adds the specified quad to the dataset.\n * Existing quads, as defined in Quad.equals, will be ignored.\n * @param quad\n * @returns the dataset instance it was called on.\n */\n public add(quad: InAndOutQuad): this {\n super.add(quad);\n this.triggerSubscriptionForQuads({\n added: this.datasetFactory.dataset([quad]),\n });\n return this;\n }\n\n /**\n * Removes the specified quad from the dataset.\n * This method returns the dataset instance it was called on.\n * @param quad\n */\n public delete(quad: InAndOutQuad): this {\n super.delete(quad);\n this.triggerSubscriptionForQuads({\n removed: this.datasetFactory.dataset([quad]),\n });\n return this;\n }\n\n /**\n * ==================================================================\n * EVENTEMITTER METHODS\n * ==================================================================\n */\n\n /**\n * Triggers all subscriptions based on an updated quads\n * @param changed The changed triples of the transaction\n */\n protected triggerSubscriptionForQuads(\n changed: DatasetChanges<InAndOutQuad>,\n ): void {\n // A mapping of serialized QuadMatches to the changed quads\n const matchingDatasetChanges: Record<\n string,\n {\n changes: DatasetChanges<InAndOutQuad>;\n triggerQuadMatch: QuadMatch;\n }\n > = {};\n\n // Population MatchingDatasetChanges\n const populateMatchingDatasetChanges = (\n changeType: \"added\" | \"removed\",\n ) => {\n const changedQuads = changed[changeType];\n changedQuads?.forEach((changedQuad) => {\n // Cast the input because RDFJS types assume RDF 1.2 where a Subject can\n // be a Quad\n const quad = changedQuad as {\n subject: SubjectNode;\n predicate: PredicateNode;\n object: ObjectNode;\n graph: GraphNode;\n };\n // All possible matches that could match with this triple\n const quadMatches: QuadMatch[] = [\n [null, null, null, null],\n [quad.subject, null, null, null],\n [quad.subject, quad.predicate, null, null],\n [quad.subject, null, quad.object, null],\n [null, quad.predicate, null, null],\n [null, quad.predicate, quad.object, null],\n [null, null, quad.object, null],\n [quad.subject, quad.predicate, quad.object, null],\n [null, null, null, quad.graph],\n [quad.subject, null, null, quad.graph],\n [quad.subject, quad.predicate, null, quad.graph],\n [quad.subject, null, quad.object, quad.graph],\n [null, quad.predicate, null, quad.graph],\n [null, quad.predicate, quad.object, quad.graph],\n [null, null, quad.object, quad.graph],\n [quad.subject, quad.predicate, quad.object, quad.graph],\n ];\n quadMatches.forEach((quadMatch) => {\n const eventName = quadMatchToString(quadMatch);\n // Only add to the map if there's actually a listener for this\n if (this.eventEmitter.listenerCount(eventName) > 0) {\n // Set matchingDatasetChanges to include data to emit\n if (!matchingDatasetChanges[eventName]) {\n matchingDatasetChanges[eventName] = {\n triggerQuadMatch: quadMatch,\n changes: {},\n };\n }\n if (!matchingDatasetChanges[eventName].changes[changeType]) {\n matchingDatasetChanges[eventName].changes[changeType] =\n this.datasetFactory.dataset();\n }\n matchingDatasetChanges[eventName].changes[changeType]?.add(\n changedQuad,\n );\n }\n });\n });\n };\n populateMatchingDatasetChanges(\"added\");\n populateMatchingDatasetChanges(\"removed\");\n\n const transactionId = v4();\n // Alert all listeners\n Object.entries(matchingDatasetChanges).forEach(\n ([quadMatchString, info]) => {\n this.eventEmitter.emit(\n quadMatchString,\n info.changes,\n transactionId,\n info.triggerQuadMatch,\n );\n },\n );\n }\n\n /**\n * Alias for emitter.on(eventName, listener).\n * @param eventName\n * @param listener\n * @returns\n */\n public addListener(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n return this.on(eventName, listener);\n }\n\n /**\n * Synchronously calls each of the listeners registered for the event named eventName, in the order they were registered, passing the supplied arguments to each.\n * @param eventName\n * @param dataset\n * @param datasetChanges\n * @returns true if the event had listeners, false otherwise.\n */\n public emit(\n eventName: QuadMatch,\n changes: DatasetChanges<InAndOutQuad>,\n ): boolean {\n return this.eventEmitter.emit(quadMatchToString(eventName), changes);\n }\n\n /**\n * Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbols.\n */\n public eventNames(): QuadMatch[] {\n return this.eventEmitter\n .eventNames()\n .map((eventName) => stringToQuadMatch(eventName as string));\n }\n\n /**\n * Returns the current max listener value for the EventEmitter which is either set by emitter.setMaxListeners(n) or defaults to events.defaultMaxListeners.\n */\n public getMaxListeners(): number {\n return this.eventEmitter.getMaxListeners();\n }\n\n /**\n * Returns the number of listeners listening to the event named eventName.\n */\n public listenerCount(eventName: QuadMatch): number {\n return this.eventEmitter.listenerCount(quadMatchToString(eventName));\n }\n\n /**\n * Returns a copy of the array of listeners for the event named eventName.\n */\n public listeners(eventName: QuadMatch): nodeEventListener<InAndOutQuad>[] {\n return this.eventEmitter.listeners(\n quadMatchToString(eventName),\n ) as nodeEventListener<InAndOutQuad>[];\n }\n\n /**\n * Alias for emitter.removeListener()\n */\n public off(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): void {\n this.removeListener(eventName, listener);\n }\n\n /**\n * Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.\n */\n public on(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n const eventString = quadMatchToString(eventName);\n if (!this.listenerHashMap.has(listener)) {\n this.listenerHashMap.set(listener, new Set());\n }\n this.listenerHashMap.get(listener)?.add(eventString);\n this.eventEmitter.on(eventString, listener);\n return this;\n }\n\n /**\n * Adds a one-time listener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.\n */\n public once(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n this.eventEmitter.once(quadMatchToString(eventName), listener);\n return this;\n }\n\n /**\n * Adds the listener function to the beginning of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.\n */\n public prependListener(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n this.eventEmitter.prependListener(quadMatchToString(eventName), listener);\n return this;\n }\n\n /**\n * Adds a one-time listener function for the event named eventName to the beginning of the listeners array. The next time eventName is triggered, this listener is removed, and then invoked.\n */\n public prependOnceListener(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n this.eventEmitter.prependOnceListener(\n quadMatchToString(eventName),\n listener,\n );\n return this;\n }\n\n /**\n * Removes all listeners, or those of the specified eventName.\n */\n public removeAllListeners(eventName: QuadMatch): this {\n this.eventEmitter.removeAllListeners(quadMatchToString(eventName));\n return this;\n }\n\n /**\n * Removes the specified listener from the listener array for the event named eventName.\n */\n public removeListener(\n eventName: QuadMatch,\n listener: nodeEventListener<InAndOutQuad>,\n ): this {\n this.eventEmitter.removeListener(quadMatchToString(eventName), listener);\n return this;\n }\n\n /**\n * Removes the specified listener from the listener array for the event named eventName.\n */\n removeListenerFromAllEvents(listener: nodeEventListener<InAndOutQuad>): this {\n const eventStringSet = this.listenerHashMap.get(listener);\n if (eventStringSet) {\n eventStringSet.forEach((eventString) => {\n this.eventEmitter.off(eventString, listener);\n });\n }\n return this;\n }\n\n /**\n * By default EventEmitters will print a warning if more than 10 listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners() method allows the limit to be modified for this specific EventEmitter instance. The value can be set to Infinity (or 0) to indicate an unlimited number of listeners.\n */\n public setMaxListeners(n: number): this {\n this.eventEmitter.setMaxListeners(n);\n return this;\n }\n\n /**\n * Returns a copy of the array of listeners for the event named eventName, including any wrappers (such as those created by .once()).\n */\n public rawListeners(eventName: QuadMatch): nodeEventListener<InAndOutQuad>[] {\n return this.eventEmitter.rawListeners(\n quadMatchToString(eventName),\n ) as nodeEventListener[];\n }\n\n /**\n * ==================================================================\n * TRANSACTION METHODS\n * ==================================================================\n */\n\n /**\n * Returns a transactional dataset that will update this dataset when its transaction is committed.\n */\n public startTransaction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;;;;;CAMT,mBAA0B,WAA4B;AACpD,OAAK,aAAa,mBAAmB,kBAAkB,UAAU,CAAC;AAClE,SAAO;;;;;CAMT,eACE,WACA,UACM;AACN,OAAK,aAAa,eAAe,kBAAkB,UAAU,EAAE,SAAS;AACxE,SAAO;;;;;CAMT,4BAA4B,UAAiD;EAC3E,MAAM,iBAAiB,KAAK,gBAAgB,IAAI,SAAS;AACzD,MAAI,eACF,gBAAe,SAAS,gBAAgB;AACtC,QAAK,aAAa,IAAI,aAAa,SAAS;IAC5C;AAEJ,SAAO;;;;;CAMT,gBAAuB,GAAiB;AACtC,OAAK,aAAa,gBAAgB,EAAE;AACpC,SAAO;;;;;CAMT,aAAoB,WAAyD;AAC3E,SAAO,KAAK,aAAa,aACvB,kBAAkB,UAAU,CAC7B;;;;;;;;;;CAYH,mBAA6D;AAC3D,SAAO,KAAK,0BAA0B,mBAAmB,KAAK"}
@@ -1,16 +0,0 @@
1
- const require_SubscribableDataset = require("./SubscribableDataset.cjs");
2
- //#region src/SubscribableDatasetFactory.ts
3
- /**
4
- * A DatasetFactory that returns a SubscribableDataset given a generic DatasetFactory.
5
- */
6
- var SubscribableDatasetFactory = class {
7
- constructor(datasetFactory, transactionDatasetFactory) {
8
- this.datasetFactory = datasetFactory;
9
- this.transactionDatasetFactory = transactionDatasetFactory;
10
- }
11
- dataset(quads) {
12
- return new require_SubscribableDataset.SubscribableDataset(this.datasetFactory, this.transactionDatasetFactory, quads ? this.datasetFactory.dataset(quads) : void 0);
13
- }
14
- };
15
- //#endregion
16
- exports.SubscribableDatasetFactory = SubscribableDatasetFactory;
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDatasetFactory.d.cts","names":[],"sources":["../src/SubscribableDatasetFactory.ts"],"mappings":";;;;;;;AAOA;cAAa,0BAAA,sBACU,QAAA,GAAW,QAAA,aACrB,cAAA,CAAe,YAAA,EAAc,YAAA;EAAA,UAE9B,cAAA,EAAgB,cAAA,CAAe,YAAA,EAAc,YAAA;EAAA,UAC7C,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;cAE9D,cAAA,EAAgB,cAAA,CAAe,YAAA,EAAc,YAAA,GAC7C,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;EAMxD,OAAA,CACE,KAAA,GAAQ,OAAA,CAAQ,YAAA,EAAc,YAAA,IAAgB,YAAA,KAC7C,mBAAA,CAAoB,YAAA;AAAA"}
@@ -1,17 +0,0 @@
1
- import { ITransactionDatasetFactory } from "./types.mjs";
2
- import { SubscribableDataset } from "./SubscribableDataset.mjs";
3
- import { BaseQuad, Dataset, DatasetFactory } from "@rdfjs/types";
4
-
5
- //#region src/SubscribableDatasetFactory.d.ts
6
- /**
7
- * A DatasetFactory that returns a SubscribableDataset given a generic DatasetFactory.
8
- */
9
- declare class SubscribableDatasetFactory<InAndOutQuad extends BaseQuad = BaseQuad> implements DatasetFactory<InAndOutQuad, InAndOutQuad> {
10
- protected datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>;
11
- protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;
12
- constructor(datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>, transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>);
13
- dataset(quads?: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[]): SubscribableDataset<InAndOutQuad>;
14
- }
15
- //#endregion
16
- export { SubscribableDatasetFactory };
17
- //# sourceMappingURL=SubscribableDatasetFactory.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDatasetFactory.d.mts","names":[],"sources":["../src/SubscribableDatasetFactory.ts"],"mappings":";;;;;;;AAOA;cAAa,0BAAA,sBACU,QAAA,GAAW,QAAA,aACrB,cAAA,CAAe,YAAA,EAAc,YAAA;EAAA,UAE9B,cAAA,EAAgB,cAAA,CAAe,YAAA,EAAc,YAAA;EAAA,UAC7C,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;cAE9D,cAAA,EAAgB,cAAA,CAAe,YAAA,EAAc,YAAA,GAC7C,yBAAA,EAA2B,0BAAA,CAA2B,YAAA;EAMxD,OAAA,CACE,KAAA,GAAQ,OAAA,CAAQ,YAAA,EAAc,YAAA,IAAgB,YAAA,KAC7C,mBAAA,CAAoB,YAAA;AAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SubscribableDatasetFactory.mjs","names":[],"sources":["../src/SubscribableDatasetFactory.ts"],"sourcesContent":["import type { DatasetFactory, BaseQuad, Dataset } from \"@rdfjs/types\";\nimport type { ITransactionDatasetFactory } from \"./types\";\nimport { SubscribableDataset } from \"./SubscribableDataset\";\n\n/**\n * A DatasetFactory that returns a SubscribableDataset given a generic DatasetFactory.\n */\nexport class SubscribableDatasetFactory<\n InAndOutQuad extends BaseQuad = BaseQuad,\n> implements DatasetFactory<InAndOutQuad, InAndOutQuad>\n{\n protected datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>;\n protected transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>;\n constructor(\n datasetFactory: DatasetFactory<InAndOutQuad, InAndOutQuad>,\n transactionDatasetFactory: ITransactionDatasetFactory<InAndOutQuad>,\n ) {\n this.datasetFactory = datasetFactory;\n this.transactionDatasetFactory = transactionDatasetFactory;\n }\n\n dataset(\n quads?: Dataset<InAndOutQuad, InAndOutQuad> | InAndOutQuad[],\n ): SubscribableDataset<InAndOutQuad> {\n return new SubscribableDataset(\n this.datasetFactory,\n this.transactionDatasetFactory,\n quads ? this.datasetFactory.dataset(quads) : undefined,\n );\n }\n}\n"],"mappings":";;;;;AAOA,IAAa,6BAAb,MAGA;CAGE,YACE,gBACA,2BACA;AACA,OAAK,iBAAiB;AACtB,OAAK,4BAA4B;;CAGnC,QACE,OACmC;AACnC,SAAO,IAAI,oBACT,KAAK,gBACL,KAAK,2BACL,QAAQ,KAAK,eAAe,QAAQ,MAAM,GAAG,KAAA,EAC9C"}