@_linked/rdf-mem-store 0.0.1
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.
- package/CHANGELOG.md +7 -0
- package/README.md +285 -0
- package/lib/cjs/Datafactory.d.ts +29 -0
- package/lib/cjs/Datafactory.js +101 -0
- package/lib/cjs/Datafactory.js.map +1 -0
- package/lib/cjs/InMemoryStore.d.ts +35 -0
- package/lib/cjs/InMemoryStore.js +98 -0
- package/lib/cjs/InMemoryStore.js.map +1 -0
- package/lib/cjs/collections/NodeMap.d.ts +35 -0
- package/lib/cjs/collections/NodeMap.js +244 -0
- package/lib/cjs/collections/NodeMap.js.map +1 -0
- package/lib/cjs/collections/NodeSet.d.ts +55 -0
- package/lib/cjs/collections/NodeSet.js +296 -0
- package/lib/cjs/collections/NodeSet.js.map +1 -0
- package/lib/cjs/collections/NodeURIMappings.d.ts +20 -0
- package/lib/cjs/collections/NodeURIMappings.js +65 -0
- package/lib/cjs/collections/NodeURIMappings.js.map +1 -0
- package/lib/cjs/collections/NodeValuesSet.d.ts +63 -0
- package/lib/cjs/collections/NodeValuesSet.js +100 -0
- package/lib/cjs/collections/NodeValuesSet.js.map +1 -0
- package/lib/cjs/collections/QuadArray.d.ts +17 -0
- package/lib/cjs/collections/QuadArray.js +67 -0
- package/lib/cjs/collections/QuadArray.js.map +1 -0
- package/lib/cjs/collections/QuadMap.d.ts +64 -0
- package/lib/cjs/collections/QuadMap.js +155 -0
- package/lib/cjs/collections/QuadMap.js.map +1 -0
- package/lib/cjs/collections/QuadSet.d.ts +22 -0
- package/lib/cjs/collections/QuadSet.js +106 -0
- package/lib/cjs/collections/QuadSet.js.map +1 -0
- package/lib/cjs/collections/SearchMap.d.ts +5 -0
- package/lib/cjs/collections/SearchMap.js +13 -0
- package/lib/cjs/collections/SearchMap.js.map +1 -0
- package/lib/cjs/events/EventBatcher.d.ts +20 -0
- package/lib/cjs/events/EventBatcher.js +97 -0
- package/lib/cjs/events/EventBatcher.js.map +1 -0
- package/lib/cjs/events/EventEmitter.d.ts +15 -0
- package/lib/cjs/events/EventEmitter.js +102 -0
- package/lib/cjs/events/EventEmitter.js.map +1 -0
- package/lib/cjs/index.d.ts +14 -0
- package/lib/cjs/index.js +48 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/IGraphObject.d.ts +29 -0
- package/lib/cjs/interfaces/IGraphObject.js +3 -0
- package/lib/cjs/interfaces/IGraphObject.js.map +1 -0
- package/lib/cjs/interfaces/IGraphObjectSet.d.ts +24 -0
- package/lib/cjs/interfaces/IGraphObjectSet.js +3 -0
- package/lib/cjs/interfaces/IGraphObjectSet.js.map +1 -0
- package/lib/cjs/interfaces/IShape.d.ts +22 -0
- package/lib/cjs/interfaces/IShape.js +3 -0
- package/lib/cjs/interfaces/IShape.js.map +1 -0
- package/lib/cjs/interfaces/ISingleGraphObject.d.ts +3 -0
- package/lib/cjs/interfaces/ISingleGraphObject.js +3 -0
- package/lib/cjs/interfaces/ISingleGraphObject.js.map +1 -0
- package/lib/cjs/models.d.ts +1167 -0
- package/lib/cjs/models.js +2668 -0
- package/lib/cjs/models.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/utils/Debug.d.ts +3 -0
- package/lib/cjs/utils/Debug.js +46 -0
- package/lib/cjs/utils/Debug.js.map +1 -0
- package/lib/cjs/utils/LocalQueryResolver.d.ts +21 -0
- package/lib/cjs/utils/LocalQueryResolver.js +1442 -0
- package/lib/cjs/utils/LocalQueryResolver.js.map +1 -0
- package/lib/cjs/utils/URI.d.ts +18 -0
- package/lib/cjs/utils/URI.js +42 -0
- package/lib/cjs/utils/URI.js.map +1 -0
- package/lib/cjs/utils/toNamedNode.d.ts +8 -0
- package/lib/cjs/utils/toNamedNode.js +15 -0
- package/lib/cjs/utils/toNamedNode.js.map +1 -0
- package/lib/esm/Datafactory.d.ts +29 -0
- package/lib/esm/Datafactory.js +97 -0
- package/lib/esm/Datafactory.js.map +1 -0
- package/lib/esm/InMemoryStore.d.ts +35 -0
- package/lib/esm/InMemoryStore.js +94 -0
- package/lib/esm/InMemoryStore.js.map +1 -0
- package/lib/esm/collections/NodeMap.d.ts +35 -0
- package/lib/esm/collections/NodeMap.js +240 -0
- package/lib/esm/collections/NodeMap.js.map +1 -0
- package/lib/esm/collections/NodeSet.d.ts +55 -0
- package/lib/esm/collections/NodeSet.js +292 -0
- package/lib/esm/collections/NodeSet.js.map +1 -0
- package/lib/esm/collections/NodeURIMappings.d.ts +20 -0
- package/lib/esm/collections/NodeURIMappings.js +61 -0
- package/lib/esm/collections/NodeURIMappings.js.map +1 -0
- package/lib/esm/collections/NodeValuesSet.d.ts +63 -0
- package/lib/esm/collections/NodeValuesSet.js +96 -0
- package/lib/esm/collections/NodeValuesSet.js.map +1 -0
- package/lib/esm/collections/QuadArray.d.ts +17 -0
- package/lib/esm/collections/QuadArray.js +63 -0
- package/lib/esm/collections/QuadArray.js.map +1 -0
- package/lib/esm/collections/QuadMap.d.ts +64 -0
- package/lib/esm/collections/QuadMap.js +151 -0
- package/lib/esm/collections/QuadMap.js.map +1 -0
- package/lib/esm/collections/QuadSet.d.ts +22 -0
- package/lib/esm/collections/QuadSet.js +102 -0
- package/lib/esm/collections/QuadSet.js.map +1 -0
- package/lib/esm/collections/SearchMap.d.ts +5 -0
- package/lib/esm/collections/SearchMap.js +9 -0
- package/lib/esm/collections/SearchMap.js.map +1 -0
- package/lib/esm/events/EventBatcher.d.ts +20 -0
- package/lib/esm/events/EventBatcher.js +90 -0
- package/lib/esm/events/EventBatcher.js.map +1 -0
- package/lib/esm/events/EventEmitter.d.ts +15 -0
- package/lib/esm/events/EventEmitter.js +98 -0
- package/lib/esm/events/EventEmitter.js.map +1 -0
- package/lib/esm/index.d.ts +14 -0
- package/lib/esm/index.js +22 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/IGraphObject.d.ts +29 -0
- package/lib/esm/interfaces/IGraphObject.js +2 -0
- package/lib/esm/interfaces/IGraphObject.js.map +1 -0
- package/lib/esm/interfaces/IGraphObjectSet.d.ts +24 -0
- package/lib/esm/interfaces/IGraphObjectSet.js +2 -0
- package/lib/esm/interfaces/IGraphObjectSet.js.map +1 -0
- package/lib/esm/interfaces/IShape.d.ts +22 -0
- package/lib/esm/interfaces/IShape.js +2 -0
- package/lib/esm/interfaces/IShape.js.map +1 -0
- package/lib/esm/interfaces/ISingleGraphObject.d.ts +3 -0
- package/lib/esm/interfaces/ISingleGraphObject.js +2 -0
- package/lib/esm/interfaces/ISingleGraphObject.js.map +1 -0
- package/lib/esm/models.d.ts +1167 -0
- package/lib/esm/models.js +2659 -0
- package/lib/esm/models.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/utils/Debug.d.ts +3 -0
- package/lib/esm/utils/Debug.js +42 -0
- package/lib/esm/utils/Debug.js.map +1 -0
- package/lib/esm/utils/LocalQueryResolver.d.ts +21 -0
- package/lib/esm/utils/LocalQueryResolver.js +1434 -0
- package/lib/esm/utils/LocalQueryResolver.js.map +1 -0
- package/lib/esm/utils/URI.d.ts +18 -0
- package/lib/esm/utils/URI.js +38 -0
- package/lib/esm/utils/URI.js.map +1 -0
- package/lib/esm/utils/toNamedNode.d.ts +8 -0
- package/lib/esm/utils/toNamedNode.js +12 -0
- package/lib/esm/utils/toNamedNode.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeURIMappings = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
6
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
7
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
8
|
+
*/
|
|
9
|
+
const models_js_1 = require("../models.js");
|
|
10
|
+
const NodeMap_js_1 = require("./NodeMap.js");
|
|
11
|
+
const NodeSet_js_1 = require("./NodeSet.js");
|
|
12
|
+
//TODO: rename to something more fitting now that it also handles TMP NamedNodes
|
|
13
|
+
class NodeURIMappings extends NodeMap_js_1.NodeMap {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.originalUris = new Map();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Will create a blanknode the first time you give a certain URI
|
|
20
|
+
* and return the same blanknode when you request it again.
|
|
21
|
+
* Note that the blanknode itself will have its own local URI regardless of the give URI
|
|
22
|
+
* this method allows you to parse a set of data that
|
|
23
|
+
* uses a certain identifier for a certain blanknode across several places
|
|
24
|
+
* and convert it to a local blanknode
|
|
25
|
+
* @param {string} givenUri
|
|
26
|
+
* @returns {BlankNode}
|
|
27
|
+
*/
|
|
28
|
+
getOrCreateBlankNode(givenUri) {
|
|
29
|
+
//TODO: rename this method to getOrCreateBlankNode
|
|
30
|
+
if (this.has(givenUri)) {
|
|
31
|
+
return this.get(givenUri);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
var blankNode = new models_js_1.BlankNode();
|
|
35
|
+
this.set(givenUri, blankNode);
|
|
36
|
+
this.originalUris.set(blankNode.uri, givenUri);
|
|
37
|
+
return blankNode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getBlankNodes() {
|
|
41
|
+
return new NodeSet_js_1.NodeSet(this.filter((n) => n instanceof models_js_1.BlankNode).values());
|
|
42
|
+
}
|
|
43
|
+
getOrCreateNamedNode(uri) {
|
|
44
|
+
//the temp URI's in one environment may already be used in another environment
|
|
45
|
+
//so we need to check for temporary URI's and convert them to a local temporary URI
|
|
46
|
+
if (uri.substring(0, models_js_1.NamedNode.TEMP_URI_BASE.length) ==
|
|
47
|
+
models_js_1.NamedNode.TEMP_URI_BASE) {
|
|
48
|
+
if (!this.has(uri)) {
|
|
49
|
+
//create a new temp node that has a LOCAL temp URI
|
|
50
|
+
var tmpResource = models_js_1.NamedNode.create();
|
|
51
|
+
this.set(uri, tmpResource);
|
|
52
|
+
this.originalUris.set(tmpResource.uri, uri);
|
|
53
|
+
return tmpResource;
|
|
54
|
+
}
|
|
55
|
+
return this.get(uri);
|
|
56
|
+
}
|
|
57
|
+
return models_js_1.NamedNode.getOrCreate(uri);
|
|
58
|
+
}
|
|
59
|
+
getOriginalUri(localUri) {
|
|
60
|
+
//return the original uri, and if we dont have a mapping it will not have changed
|
|
61
|
+
return this.originalUris.get(localUri) || localUri;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.NodeURIMappings = NodeURIMappings;
|
|
65
|
+
//# sourceMappingURL=NodeURIMappings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeURIMappings.js","sourceRoot":"","sources":["../../../src/collections/NodeURIMappings.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4CAAiD;AACjD,6CAAqC;AACrC,6CAAqC;AAErC,gFAAgF;AAChF,MAAa,eAAgB,SAAQ,oBAAkB;IAAvD;;QACE,iBAAY,GAAwB,IAAI,GAAG,EAAE,CAAC;IAmDhD,CAAC;IAjDC;;;;;;;;;OASG;IACH,oBAAoB,CAAC,QAAgB;QACnC,kDAAkD;QAClD,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,IAAI,SAAS,GAAc,IAAI,qBAAS,EAAE,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAC9B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC/C,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,aAAa;QACX,OAAO,IAAI,oBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,qBAAS,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,oBAAoB,CAAC,GAAW;QAC9B,8EAA8E;QAC9E,mFAAmF;QACnF,IACE,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,qBAAS,CAAC,aAAa,CAAC,MAAM,CAAC;YAChD,qBAAS,CAAC,aAAa,EACvB,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnB,kDAAkD;gBAClD,IAAI,WAAW,GAAc,qBAAS,CAAC,MAAM,EAAE,CAAC;gBAChD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;gBAC3B,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBAC5C,OAAO,WAAW,CAAC;YACrB,CAAC;YACD,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,qBAAS,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,cAAc,CAAC,QAAgB;QAC7B,iFAAiF;QACjF,OAAO,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC;IACrD,CAAC;CACF;AApDD,0CAoDC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { NodeSet } from './NodeSet.js';
|
|
2
|
+
import { NamedNode, Node } from '../models.js';
|
|
3
|
+
import { QuadSet } from './QuadSet.js';
|
|
4
|
+
export declare class NodeValuesSet extends NodeSet {
|
|
5
|
+
private _subject;
|
|
6
|
+
private _property;
|
|
7
|
+
constructor(_subject: Node, _property: NamedNode, iterable?: Iterable<Node>);
|
|
8
|
+
get subject(): Node;
|
|
9
|
+
get property(): NamedNode;
|
|
10
|
+
/**
|
|
11
|
+
* Listen to any changes in the valueset for this subject + property combination
|
|
12
|
+
* If you provide context (usually 'this'), removing the onChange listener will remove all listeners for this property & context, regardless of what callback you provide. (this is helpful if you dont have access to the excact same callback function)
|
|
13
|
+
* @param callback
|
|
14
|
+
* @param context
|
|
15
|
+
*/
|
|
16
|
+
onChange(callback: (quads?: QuadSet, property?: NamedNode) => void, context?: any): void;
|
|
17
|
+
/**
|
|
18
|
+
* Remove listener for changes in the valueset for this subject + property combination
|
|
19
|
+
* If you provide context (usually 'this'), removing the onChange listener will remove all listeners for this property & context, regardless of what callback you provide. (this is helpful if you dont have access to the excact same callback function)
|
|
20
|
+
* @param callback
|
|
21
|
+
* @param context
|
|
22
|
+
*/
|
|
23
|
+
removeOnChange(callback: (quads?: QuadSet, property?: NamedNode) => void, context?: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* When cloned we switch to a NodeSet of all the values
|
|
26
|
+
* And detach from the magic of PropertyValueSets, which are only meant to be used internally in the NamedNode model
|
|
27
|
+
* @param args
|
|
28
|
+
*/
|
|
29
|
+
createNew(...args: any[]): any;
|
|
30
|
+
/**
|
|
31
|
+
* Add a new node to this set of values.
|
|
32
|
+
* This creates a new quad in the local graph.
|
|
33
|
+
* This is equivalent to manually adding a new property value using `subject.set(predicate,object)`
|
|
34
|
+
* @param value the node to add
|
|
35
|
+
*/
|
|
36
|
+
add(value: Node): this;
|
|
37
|
+
/**
|
|
38
|
+
* Remove a node from this set of values.
|
|
39
|
+
* This removes a quad in the local graph (if the node was an existing value)
|
|
40
|
+
* This is equivalent to manually removing a property value using `subject.unset(predicate,object)`
|
|
41
|
+
* @param value the node to remove
|
|
42
|
+
*/
|
|
43
|
+
delete(value: Node): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Actually removes a node from this value set. Does not remove any quads in the local graph
|
|
46
|
+
* DO NOT use this method.
|
|
47
|
+
* Use subject.getAll(predicate).remove(object) or subject.unset(predicate,object) instead
|
|
48
|
+
* @internal
|
|
49
|
+
* @param v
|
|
50
|
+
*/
|
|
51
|
+
__delete(v: any): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Adds a value directly to this value set. Does not create new quads in the local graph
|
|
54
|
+
* DO NOT USE this method.
|
|
55
|
+
* Use subject.getAll(predicate).add(object) or subject.set(predicate,object) instead.
|
|
56
|
+
* @internal
|
|
57
|
+
* @param v
|
|
58
|
+
*/
|
|
59
|
+
__add(v: any): this;
|
|
60
|
+
sort(compareFn?: any, thisArg?: any): NodeSet | any;
|
|
61
|
+
concat(...sets: any[]): NodeSet | any;
|
|
62
|
+
filter(fn: any): this;
|
|
63
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NodeValuesSet = void 0;
|
|
4
|
+
/*
|
|
5
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
6
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
7
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
8
|
+
*/
|
|
9
|
+
const NodeSet_js_1 = require("./NodeSet.js");
|
|
10
|
+
class NodeValuesSet extends NodeSet_js_1.NodeSet {
|
|
11
|
+
constructor(_subject, _property, iterable) {
|
|
12
|
+
super(iterable);
|
|
13
|
+
this._subject = _subject;
|
|
14
|
+
this._property = _property;
|
|
15
|
+
}
|
|
16
|
+
get subject() {
|
|
17
|
+
return this._subject;
|
|
18
|
+
}
|
|
19
|
+
get property() {
|
|
20
|
+
return this._property;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Listen to any changes in the valueset for this subject + property combination
|
|
24
|
+
* If you provide context (usually 'this'), removing the onChange listener will remove all listeners for this property & context, regardless of what callback you provide. (this is helpful if you dont have access to the excact same callback function)
|
|
25
|
+
* @param callback
|
|
26
|
+
* @param context
|
|
27
|
+
*/
|
|
28
|
+
onChange(callback, context) {
|
|
29
|
+
this._subject.onChange(this._property, callback, context);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Remove listener for changes in the valueset for this subject + property combination
|
|
33
|
+
* If you provide context (usually 'this'), removing the onChange listener will remove all listeners for this property & context, regardless of what callback you provide. (this is helpful if you dont have access to the excact same callback function)
|
|
34
|
+
* @param callback
|
|
35
|
+
* @param context
|
|
36
|
+
*/
|
|
37
|
+
removeOnChange(callback, context) {
|
|
38
|
+
this._subject.removeOnChange(this._property, callback, context);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* When cloned we switch to a NodeSet of all the values
|
|
42
|
+
* And detach from the magic of PropertyValueSets, which are only meant to be used internally in the NamedNode model
|
|
43
|
+
* @param args
|
|
44
|
+
*/
|
|
45
|
+
createNew(...args) {
|
|
46
|
+
return new NodeSet_js_1.NodeSet(...args);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Add a new node to this set of values.
|
|
50
|
+
* This creates a new quad in the local graph.
|
|
51
|
+
* This is equivalent to manually adding a new property value using `subject.set(predicate,object)`
|
|
52
|
+
* @param value the node to add
|
|
53
|
+
*/
|
|
54
|
+
add(value) {
|
|
55
|
+
this._subject.set(this._property, value);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Remove a node from this set of values.
|
|
60
|
+
* This removes a quad in the local graph (if the node was an existing value)
|
|
61
|
+
* This is equivalent to manually removing a property value using `subject.unset(predicate,object)`
|
|
62
|
+
* @param value the node to remove
|
|
63
|
+
*/
|
|
64
|
+
delete(value) {
|
|
65
|
+
return this._subject.unset(this._property, value);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Actually removes a node from this value set. Does not remove any quads in the local graph
|
|
69
|
+
* DO NOT use this method.
|
|
70
|
+
* Use subject.getAll(predicate).remove(object) or subject.unset(predicate,object) instead
|
|
71
|
+
* @internal
|
|
72
|
+
* @param v
|
|
73
|
+
*/
|
|
74
|
+
__delete(v) {
|
|
75
|
+
return super.delete(v);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Adds a value directly to this value set. Does not create new quads in the local graph
|
|
79
|
+
* DO NOT USE this method.
|
|
80
|
+
* Use subject.getAll(predicate).add(object) or subject.set(predicate,object) instead.
|
|
81
|
+
* @internal
|
|
82
|
+
* @param v
|
|
83
|
+
*/
|
|
84
|
+
__add(v) {
|
|
85
|
+
return super.add(v);
|
|
86
|
+
}
|
|
87
|
+
//here we overload the type definitions to indicate its a NodeSet that will be returned
|
|
88
|
+
//HOWEVER, without '|any' this will not be expected by Typescript unless we find a really intricate way of rewriting all methods of CoreSet / CoreIterable that return this into methods that return ...?
|
|
89
|
+
sort(compareFn, thisArg) {
|
|
90
|
+
return super.sort(compareFn, thisArg);
|
|
91
|
+
}
|
|
92
|
+
concat(...sets) {
|
|
93
|
+
return super.concat(...sets);
|
|
94
|
+
}
|
|
95
|
+
filter(fn) {
|
|
96
|
+
return super.filter(fn);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.NodeValuesSet = NodeValuesSet;
|
|
100
|
+
//# sourceMappingURL=NodeValuesSet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeValuesSet.js","sourceRoot":"","sources":["../../../src/collections/NodeValuesSet.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,6CAAqC;AAIrC,MAAa,aAAc,SAAQ,oBAAO;IACxC,YACU,QAAc,EACd,SAAoB,EAC5B,QAAyB;QAEzB,KAAK,CAAC,QAAQ,CAAC,CAAC;QAJR,aAAQ,GAAR,QAAQ,CAAM;QACd,cAAS,GAAT,SAAS,CAAW;IAI9B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CACN,QAAyD,EACzD,OAAQ;QAEP,IAAI,CAAC,QAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,E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} from '../models.js';
|
|
2
|
+
import { NodeSet } from './NodeSet.js';
|
|
3
|
+
export declare class QuadArray extends Array<Quad> {
|
|
4
|
+
removeAll(alteration?: boolean): void;
|
|
5
|
+
moveTo(graph: Graph, alteration?: boolean): QuadArray;
|
|
6
|
+
makeExplicit(): void;
|
|
7
|
+
getSubjects(): NodeSet<NamedNode>;
|
|
8
|
+
getPredicates(): NodeSet<NamedNode>;
|
|
9
|
+
getObjects(): NodeSet;
|
|
10
|
+
map<S>(callbackfn: (value: Quad, index: number, array: Quad[]) => S): S[];
|
|
11
|
+
getExplicit(): Quad[];
|
|
12
|
+
getImplicit(): Quad[];
|
|
13
|
+
turnOn(): void;
|
|
14
|
+
turnOff(): void;
|
|
15
|
+
toString(): string;
|
|
16
|
+
print(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuadArray = void 0;
|
|
4
|
+
const NodeSet_js_1 = require("./NodeSet.js");
|
|
5
|
+
//TODO: test performance of QuadArray vs QuadSet and probably remove QuadArray
|
|
6
|
+
class QuadArray extends Array {
|
|
7
|
+
removeAll(alteration = false) {
|
|
8
|
+
this.forEach((quad) => quad.remove(alteration));
|
|
9
|
+
}
|
|
10
|
+
moveTo(graph, alteration = true) {
|
|
11
|
+
let result = new QuadArray();
|
|
12
|
+
this.forEach((quad) => {
|
|
13
|
+
result.push(quad.moveToGraph(graph, alteration));
|
|
14
|
+
});
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
makeExplicit() {
|
|
18
|
+
this.forEach((quad) => quad.makeExplicit());
|
|
19
|
+
}
|
|
20
|
+
getSubjects() {
|
|
21
|
+
//return new NamedNodeSet(this.map(quad => quad.subject).values());
|
|
22
|
+
//that's short, but probably this is faster:
|
|
23
|
+
var res = new NodeSet_js_1.NodeSet();
|
|
24
|
+
for (var quad of this) {
|
|
25
|
+
res.add(quad.subject);
|
|
26
|
+
}
|
|
27
|
+
return res;
|
|
28
|
+
}
|
|
29
|
+
getPredicates() {
|
|
30
|
+
var res = new NodeSet_js_1.NodeSet();
|
|
31
|
+
for (var quad of this) {
|
|
32
|
+
res.add(quad.predicate);
|
|
33
|
+
}
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
getObjects() {
|
|
37
|
+
var res = new NodeSet_js_1.NodeSet();
|
|
38
|
+
for (var quad of this) {
|
|
39
|
+
res.add(quad.object);
|
|
40
|
+
}
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
map(callbackfn) {
|
|
44
|
+
return super.map(callbackfn);
|
|
45
|
+
}
|
|
46
|
+
getExplicit() {
|
|
47
|
+
return this.filter((quad) => !quad.implicit);
|
|
48
|
+
}
|
|
49
|
+
getImplicit() {
|
|
50
|
+
return this.filter((quad) => quad.implicit);
|
|
51
|
+
}
|
|
52
|
+
turnOn() {
|
|
53
|
+
this.forEach((quad) => quad.turnOn());
|
|
54
|
+
}
|
|
55
|
+
turnOff() {
|
|
56
|
+
this.forEach((quad) => quad.turnOff());
|
|
57
|
+
}
|
|
58
|
+
toString() {
|
|
59
|
+
//without this the toString() would print 3 URI's for each quad followed by a ',' which looks messy and unclear
|
|
60
|
+
return this.join('\n');
|
|
61
|
+
}
|
|
62
|
+
print() {
|
|
63
|
+
console.log(this.toString());
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.QuadArray = QuadArray;
|
|
67
|
+
//# sourceMappingURL=QuadArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuadArray.js","sourceRoot":"","sources":["../../../src/collections/QuadArray.ts"],"names":[],"mappings":";;;AAMA,6CAAqC;AAErC,8EAA8E;AAC9E,MAAa,SAAU,SAAQ,KAAW;IACxC,SAAS,CAAC,aAAsB,KAAK;QACnC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM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ACT,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,QAAQ;QACN,+GAA+G;QAC/G,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAED,KAAK;QACH,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/B,CAAC;CACF;AAvED,8BAuEC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { NamedNode, Node, Quad } from '../models.js';
|
|
2
|
+
import { NodeSet } from './NodeSet.js';
|
|
3
|
+
import { QuadSet } from './QuadSet.js';
|
|
4
|
+
import { CoreSet } from '@_linked/core/collections/CoreSet';
|
|
5
|
+
import { ICoreIterable } from '@_linked/core/interfaces/ICoreIterable';
|
|
6
|
+
/**
|
|
7
|
+
* A map who's values are sets
|
|
8
|
+
* When you iterate over this map with methods like map and forEach you'll iterate over the values of the sets
|
|
9
|
+
*/
|
|
10
|
+
declare class CoreMapToSet<K, S extends CoreSet<V>, V> extends Map<K, S> implements ICoreIterable<V> {
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether all the members of an array satisfy the specified test.
|
|
13
|
+
* @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
|
|
14
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
15
|
+
*/
|
|
16
|
+
every(callbackfn: (value: V, key: K, map: CoreMapToSet<K, S, V>) => boolean, thisArg?: any): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* This object is a Map whos values are sets.
|
|
19
|
+
* This forEach method calls the callback-function for each items in each of those sets.
|
|
20
|
+
* The first parameter has the type of the items in the sets
|
|
21
|
+
* The second parameter is the key
|
|
22
|
+
* The type information can unfortunately not be defined as they would conflict with the usual forEach method
|
|
23
|
+
* @param callbackfn
|
|
24
|
+
* @param thisArg
|
|
25
|
+
*/
|
|
26
|
+
forEach(callbackfn: (value: any, key: any, map: any) => void, thisArg?: any): void;
|
|
27
|
+
/**
|
|
28
|
+
* Determines whether the specified callback function returns true for any element of an array.
|
|
29
|
+
* @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
|
|
30
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
31
|
+
*/
|
|
32
|
+
some(callbackfn: (value: V, key: K, set: S, map: this) => boolean, thisArg?: any): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Maps all values contained in this map of set into a new single set
|
|
35
|
+
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
|
36
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
37
|
+
*/
|
|
38
|
+
map<R extends CoreSet<any>>(callbackfn: (value: V, key: K, set: S, map: this) => any, resultType?: typeof CoreSet, thisArg?: any): R;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the end values in the map that meet the condition specified in a callback function.
|
|
41
|
+
* The result will be a single set of values
|
|
42
|
+
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
|
|
43
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
44
|
+
*/
|
|
45
|
+
filter<R extends CoreSet<any>>(callbackfn: (value: V, key: K, set: S, map: this) => any, resultType?: typeof CoreSet, thisArg?: any): R;
|
|
46
|
+
first(): V | null;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the value of the first element in the Set where predicate is true, and undefined
|
|
49
|
+
* otherwise.
|
|
50
|
+
*/
|
|
51
|
+
find(predicate: (value: V, index: K, set: S) => boolean, thisArg?: any): V | undefined;
|
|
52
|
+
toString(): string;
|
|
53
|
+
}
|
|
54
|
+
export declare class QuadMap extends CoreMapToSet<Node, QuadSet, Quad> {
|
|
55
|
+
removeAll(alteration?: boolean): void;
|
|
56
|
+
getSubjects(): NodeSet<NamedNode>;
|
|
57
|
+
getPredicates(): NodeSet<NamedNode>;
|
|
58
|
+
getObjects(): NodeSet;
|
|
59
|
+
getQuadSet(): QuadSet;
|
|
60
|
+
delete(v: any): boolean;
|
|
61
|
+
__delete(v: any): boolean;
|
|
62
|
+
__set(k: Node, v: Quad): void;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QuadMap = void 0;
|
|
4
|
+
const NodeSet_js_1 = require("./NodeSet.js");
|
|
5
|
+
const QuadSet_js_1 = require("./QuadSet.js");
|
|
6
|
+
const CoreSet_1 = require("@_linked/core/collections/CoreSet");
|
|
7
|
+
/**
|
|
8
|
+
* A map who's values are sets
|
|
9
|
+
* When you iterate over this map with methods like map and forEach you'll iterate over the values of the sets
|
|
10
|
+
*/
|
|
11
|
+
class CoreMapToSet extends Map {
|
|
12
|
+
/**
|
|
13
|
+
* Determines whether all the members of an array satisfy the specified test.
|
|
14
|
+
* @param callbackfn A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.
|
|
15
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
16
|
+
*/
|
|
17
|
+
every(callbackfn, thisArg) {
|
|
18
|
+
for (let [key, set] of this) {
|
|
19
|
+
for (let value of set) {
|
|
20
|
+
if (!callbackfn.apply(thisArg, [value, key, this])) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This object is a Map whos values are sets.
|
|
29
|
+
* This forEach method calls the callback-function for each items in each of those sets.
|
|
30
|
+
* The first parameter has the type of the items in the sets
|
|
31
|
+
* The second parameter is the key
|
|
32
|
+
* The type information can unfortunately not be defined as they would conflict with the usual forEach method
|
|
33
|
+
* @param callbackfn
|
|
34
|
+
* @param thisArg
|
|
35
|
+
*/
|
|
36
|
+
forEach(callbackfn, thisArg) {
|
|
37
|
+
for (let [key, set] of this) {
|
|
38
|
+
for (let value of set) {
|
|
39
|
+
callbackfn.apply(thisArg, [value, key, this]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Determines whether the specified callback function returns true for any element of an array.
|
|
45
|
+
* @param callbackfn A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.
|
|
46
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
47
|
+
*/
|
|
48
|
+
some(callbackfn, thisArg) {
|
|
49
|
+
for (let [key, set] of this) {
|
|
50
|
+
for (let value of set) {
|
|
51
|
+
if (callbackfn.apply(thisArg, [value, key, set, this])) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Maps all values contained in this map of set into a new single set
|
|
60
|
+
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
|
|
61
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
62
|
+
*/
|
|
63
|
+
map(callbackfn, resultType = CoreSet_1.CoreSet, thisArg) {
|
|
64
|
+
//create the result map, whos values will be 'mapped' into new values from the current values of this map
|
|
65
|
+
//whilst maintaining set organisation
|
|
66
|
+
var resultSet = new resultType();
|
|
67
|
+
for (let [key, set] of this) {
|
|
68
|
+
for (let value of set) {
|
|
69
|
+
//get the right set and add the mapped value to it
|
|
70
|
+
resultSet.add(callbackfn.apply(thisArg, [value, key, set, this]));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return resultSet;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the end values in the map that meet the condition specified in a callback function.
|
|
77
|
+
* The result will be a single set of values
|
|
78
|
+
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
|
|
79
|
+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
80
|
+
*/
|
|
81
|
+
filter(callbackfn, resultType = CoreSet_1.CoreSet, thisArg) {
|
|
82
|
+
//create the result map, whos values will be 'mapped' into new values from the current values of this map
|
|
83
|
+
//whilst maintaining set organisation
|
|
84
|
+
var resultSet = new resultType();
|
|
85
|
+
for (let [key, set] of this) {
|
|
86
|
+
//use the type of the first set to determine the result type
|
|
87
|
+
for (let value of set) {
|
|
88
|
+
//if the filter function returns true-ish
|
|
89
|
+
if (callbackfn.apply(thisArg, [value, key, set, this])) {
|
|
90
|
+
//add to result set
|
|
91
|
+
resultSet.add(value);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return resultSet;
|
|
96
|
+
}
|
|
97
|
+
first() {
|
|
98
|
+
return this.values().next().value.first();
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Returns the value of the first element in the Set where predicate is true, and undefined
|
|
102
|
+
* otherwise.
|
|
103
|
+
*/
|
|
104
|
+
find(predicate, thisArg) {
|
|
105
|
+
for (let [key, set] of this) {
|
|
106
|
+
for (let value of set) {
|
|
107
|
+
if (predicate.apply(thisArg, [value, key, this])) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
toString() {
|
|
115
|
+
let res = 'MapToSets:\n';
|
|
116
|
+
for (let [key, set] of this) {
|
|
117
|
+
res += '\t[' + key.toString() + '] => ' + set.toString() + '\n';
|
|
118
|
+
}
|
|
119
|
+
return res;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
class QuadMap extends CoreMapToSet {
|
|
123
|
+
removeAll(alteration = false) {
|
|
124
|
+
this.forEach((quad) => quad.remove(alteration));
|
|
125
|
+
}
|
|
126
|
+
getSubjects() {
|
|
127
|
+
return this.map((quad) => quad.subject, NodeSet_js_1.NodeSet);
|
|
128
|
+
}
|
|
129
|
+
getPredicates() {
|
|
130
|
+
return this.map((quad) => quad.predicate, NodeSet_js_1.NodeSet);
|
|
131
|
+
}
|
|
132
|
+
getObjects() {
|
|
133
|
+
return this.map((quad) => quad.predicate, NodeSet_js_1.NodeSet);
|
|
134
|
+
}
|
|
135
|
+
getQuadSet() {
|
|
136
|
+
return this.map((q) => q, QuadSet_js_1.QuadSet);
|
|
137
|
+
}
|
|
138
|
+
delete(v) {
|
|
139
|
+
throw new Error('Do not delete values directly from a QuadMap. Either create a new set of all values with getQuadSet() or use methods like map() and filter() which also return a new set.');
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
__delete(v) {
|
|
143
|
+
return super.delete(v);
|
|
144
|
+
}
|
|
145
|
+
__set(k, v) {
|
|
146
|
+
//make sure we have a QuadSet ready for that key
|
|
147
|
+
if (!this.has(k)) {
|
|
148
|
+
this.set(k, new QuadSet_js_1.QuadSet());
|
|
149
|
+
}
|
|
150
|
+
//then add this quad to that set
|
|
151
|
+
this.get(k).add(v);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.QuadMap = QuadMap;
|
|
155
|
+
//# sourceMappingURL=QuadMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuadMap.js","sourceRoot":"","sources":["../../../src/collections/QuadMap.ts"],"names":[],"mappings":";;;AAMA,6CAAqC;AACrC,6CAAqC;AACrC,+DAA0D;AAG1D;;;GAGG;AACH,MAAM,YACJ,SAAQ,GAAS;IAGjB;;;;OAIG;IACH,KAAK,CACH,UAAqE,EACrE,OAAa;QAEb,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAC5B,KAAK,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;gBACtB,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC;oBACnD,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CACL,UAAoD,EACpD,OAAa;QAEb,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAC5B,KAAK,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;gBACtB,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,IAAI,CACF,UAA4D,EAC5D,OAAa;QAEb,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;YAC5B,KAAK,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;gBACtB,IAAI,UAAU,CAAC,KAAK,CA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,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAO,CAAC,CAAC;IACrD,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,oBAAO,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,CAAC,CAAC;QACN,MAAM,IAAI,KAAK,CACb,2KAA2K,CAC5K,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,QAAQ,CAAC,CAAC;QACR,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC;IAED,KAAK,CAAC,CAAO,EAAE,CAAO;QACpB,gDAAgD;QAChD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,oBAAO,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,gCAAgC;QAChC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;CACF;AAxCD,0BAwCC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Graph, NamedNode, Node, Quad } from '../models.js';
|
|
2
|
+
import { CoreSet } from '@_linked/core/collections/CoreSet';
|
|
3
|
+
import { NodeSet } from './NodeSet.js';
|
|
4
|
+
export declare class QuadSet extends CoreSet<Quad> {
|
|
5
|
+
removeAll(alteration?: boolean): void;
|
|
6
|
+
moveTo(graph: Graph, alteration?: boolean): QuadSet;
|
|
7
|
+
makeExplicit(): void;
|
|
8
|
+
getSubjects(): NodeSet<NamedNode>;
|
|
9
|
+
getPredicates(): NodeSet<NamedNode>;
|
|
10
|
+
getObjects(): NodeSet;
|
|
11
|
+
getNamedNodeObjects(): NodeSet<NamedNode>;
|
|
12
|
+
getLiteralObjects(): NodeSet;
|
|
13
|
+
getLike(subject?: NamedNode, predicate?: NamedNode, object?: Node): this;
|
|
14
|
+
getNamedNodes(): NodeSet<NamedNode>;
|
|
15
|
+
getNodes(): NodeSet;
|
|
16
|
+
hasNode(node: Node): boolean;
|
|
17
|
+
getExplicit(): this;
|
|
18
|
+
getImplicit(): this;
|
|
19
|
+
turnOn(): void;
|
|
20
|
+
turnOff(): void;
|
|
21
|
+
toString(): string;
|
|
22
|
+
}
|