rdflib 2.2.22-4e175603 → 2.2.22-53d65d90
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/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +4 -0
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +90 -61
- package/esm/class-order.js +1 -1
- package/esm/collection.js +106 -70
- package/esm/default-graph.js +33 -13
- package/esm/empty.js +26 -8
- package/esm/factories/canonical-data-factory.js +30 -33
- package/esm/factories/extended-term-factory.js +14 -18
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +11 -9
- package/esm/fetcher.js +1644 -1355
- package/esm/formula.js +740 -632
- package/esm/index.js +51 -31
- package/esm/jsonldparser.js +26 -19
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +86 -38
- package/esm/literal.js +157 -120
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1085 -1008
- package/esm/named-node.js +99 -69
- package/esm/namespace.js +4 -2
- package/esm/node-internal.js +98 -74
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +16 -15
- package/esm/rdfaparser.js +846 -781
- package/esm/rdfxmlparser.js +365 -348
- package/esm/serialize.js +4 -20
- package/esm/serializer.js +886 -821
- package/esm/statement.js +72 -52
- package/esm/store.js +924 -822
- package/esm/types.js +21 -21
- package/esm/update-manager.js +983 -882
- package/esm/updates-via.js +134 -104
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +5 -4
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +58 -32
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +88 -60
- package/lib/class-order.js +1 -1
- package/lib/collection.js +104 -69
- package/lib/default-graph.js +32 -13
- package/lib/empty.js +25 -8
- package/lib/factories/canonical-data-factory.js +32 -35
- package/lib/factories/extended-term-factory.js +14 -18
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +11 -9
- package/lib/fetcher.js +1646 -1385
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +739 -632
- package/lib/index.js +87 -66
- package/lib/jsonldparser.js +26 -19
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +86 -54
- package/lib/literal.js +156 -120
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1089 -1010
- package/lib/named-node.js +98 -69
- package/lib/namespace.js +4 -2
- package/lib/node-internal.js +96 -73
- package/lib/node.js +1 -1
- package/lib/parse.js +6 -5
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +18 -19
- package/lib/rdfaparser.js +848 -783
- package/lib/rdfxmlparser.js +366 -350
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +4 -21
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +890 -825
- package/lib/statement.js +74 -54
- package/lib/store.d.ts +1 -1
- package/lib/store.js +926 -844
- package/lib/types.js +21 -21
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +959 -865
- package/lib/updates-via.js +134 -105
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +6 -4
- package/lib/utils-js.js +9 -8
- package/lib/utils.js +6 -6
- package/lib/variable.js +60 -34
- package/lib/xsd.js +2 -2
- package/package.json +6 -6
- package/src/jsonldparser.js +1 -1
- package/src/serialize.ts +4 -14
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +8 -2
package/esm/blank-node.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
1
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2
10
|
import ClassOrder from './class-order';
|
|
3
11
|
import Node from './node-internal';
|
|
4
12
|
import { BlankNodeTermType } from './types';
|
|
@@ -6,79 +14,100 @@ import { BlankNodeTermType } from './types';
|
|
|
6
14
|
* An RDF blank node is a Node without a URI
|
|
7
15
|
* @link https://rdf.js.org/data-model-spec/#blanknode-interface
|
|
8
16
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
static getId(id) {
|
|
15
|
-
if (id) {
|
|
16
|
-
if (typeof id !== 'string') {
|
|
17
|
-
console.log('Bad blank id:', id);
|
|
18
|
-
throw new Error('Bad id argument to new blank node: ' + id);
|
|
19
|
-
}
|
|
20
|
-
if (id.includes('#')) {
|
|
21
|
-
// Is a URI with hash fragment
|
|
22
|
-
let fragments = id.split('#');
|
|
23
|
-
return fragments[fragments.length - 1];
|
|
24
|
-
}
|
|
25
|
-
return id;
|
|
26
|
-
}
|
|
27
|
-
return 'n' + BlankNode.nextId++;
|
|
28
|
-
}
|
|
17
|
+
var BlankNode = /*#__PURE__*/function (_Node) {
|
|
18
|
+
_inherits(BlankNode, _Node);
|
|
19
|
+
var _super = _createSuper(BlankNode);
|
|
29
20
|
/**
|
|
30
21
|
* Initializes this node
|
|
31
22
|
* @param [id] The identifier for the blank node
|
|
32
23
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_defineProperty(
|
|
38
|
-
_defineProperty(
|
|
24
|
+
function BlankNode(id) {
|
|
25
|
+
var _this;
|
|
26
|
+
_classCallCheck(this, BlankNode);
|
|
27
|
+
_this = _super.call(this, BlankNode.getId(id));
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "termType", BlankNodeTermType);
|
|
29
|
+
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.BlankNode);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "isBlank", 1);
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
32
|
+
return _this;
|
|
39
33
|
}
|
|
40
34
|
|
|
41
35
|
/**
|
|
42
36
|
* The identifier for the blank node
|
|
43
37
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (this.classOrder < other.classOrder) {
|
|
52
|
-
return -1;
|
|
38
|
+
_createClass(BlankNode, [{
|
|
39
|
+
key: "id",
|
|
40
|
+
get: function get() {
|
|
41
|
+
return this.value;
|
|
42
|
+
},
|
|
43
|
+
set: function set(value) {
|
|
44
|
+
this.value = value;
|
|
53
45
|
}
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
}, {
|
|
47
|
+
key: "compareTerm",
|
|
48
|
+
value: function compareTerm(other) {
|
|
49
|
+
if (this.classOrder < other.classOrder) {
|
|
50
|
+
return -1;
|
|
51
|
+
}
|
|
52
|
+
if (this.classOrder > other.classOrder) {
|
|
53
|
+
return +1;
|
|
54
|
+
}
|
|
55
|
+
if (this.id < other.id) {
|
|
56
|
+
return -1;
|
|
57
|
+
}
|
|
58
|
+
if (this.id > other.id) {
|
|
59
|
+
return +1;
|
|
60
|
+
}
|
|
61
|
+
return 0;
|
|
56
62
|
}
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Gets a copy of this blank node in the specified formula
|
|
66
|
+
* @param formula The formula
|
|
67
|
+
*/
|
|
68
|
+
}, {
|
|
69
|
+
key: "copy",
|
|
70
|
+
value: function copy(formula) {
|
|
71
|
+
// depends on the formula
|
|
72
|
+
var bnodeNew = new BlankNode();
|
|
73
|
+
formula.copyTo(this, bnodeNew);
|
|
74
|
+
return bnodeNew;
|
|
59
75
|
}
|
|
60
|
-
|
|
61
|
-
|
|
76
|
+
}, {
|
|
77
|
+
key: "toCanonical",
|
|
78
|
+
value: function toCanonical() {
|
|
79
|
+
return BlankNode.NTAnonymousNodePrefix + this.value;
|
|
62
80
|
}
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
}, {
|
|
82
|
+
key: "toString",
|
|
83
|
+
value: function toString() {
|
|
84
|
+
return BlankNode.NTAnonymousNodePrefix + this.id;
|
|
85
|
+
}
|
|
86
|
+
}], [{
|
|
87
|
+
key: "getId",
|
|
88
|
+
value:
|
|
89
|
+
/**
|
|
90
|
+
* The next unique identifier for blank nodes
|
|
91
|
+
*/
|
|
65
92
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
93
|
+
function getId(id) {
|
|
94
|
+
if (id) {
|
|
95
|
+
if (typeof id !== 'string') {
|
|
96
|
+
console.log('Bad blank id:', id);
|
|
97
|
+
throw new Error('Bad id argument to new blank node: ' + id);
|
|
98
|
+
}
|
|
99
|
+
if (id.includes('#')) {
|
|
100
|
+
// Is a URI with hash fragment
|
|
101
|
+
var fragments = id.split('#');
|
|
102
|
+
return fragments[fragments.length - 1];
|
|
103
|
+
}
|
|
104
|
+
return id;
|
|
105
|
+
}
|
|
106
|
+
return 'n' + BlankNode.nextId++;
|
|
107
|
+
}
|
|
108
|
+
}]);
|
|
109
|
+
return BlankNode;
|
|
110
|
+
}(Node);
|
|
83
111
|
_defineProperty(BlankNode, "nextId", 0);
|
|
84
|
-
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
|
112
|
+
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
|
113
|
+
export { BlankNode as default };
|
package/esm/class-order.js
CHANGED
package/esm/collection.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
1
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2
10
|
import RdflibBlankNode from './blank-node';
|
|
3
11
|
import ClassOrder from './class-order';
|
|
4
12
|
import Literal from './literal';
|
|
@@ -32,86 +40,114 @@ export function fromValue(value) {
|
|
|
32
40
|
*
|
|
33
41
|
* Use generic T to control the contents of the array.
|
|
34
42
|
*/
|
|
35
|
-
|
|
43
|
+
var Collection = /*#__PURE__*/function (_Node) {
|
|
44
|
+
_inherits(Collection, _Node);
|
|
45
|
+
var _super = _createSuper(Collection);
|
|
36
46
|
/**
|
|
37
47
|
* The nodes in this collection
|
|
38
48
|
*/
|
|
39
49
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
_defineProperty(
|
|
45
|
-
_defineProperty(
|
|
46
|
-
_defineProperty(
|
|
47
|
-
_defineProperty(
|
|
50
|
+
function Collection(initial) {
|
|
51
|
+
var _this;
|
|
52
|
+
_classCallCheck(this, Collection);
|
|
53
|
+
_this = _super.call(this, (RdflibBlankNode.nextId++).toString());
|
|
54
|
+
_defineProperty(_assertThisInitialized(_this), "termType", CollectionTermType);
|
|
55
|
+
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Collection);
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "closed", false);
|
|
57
|
+
_defineProperty(_assertThisInitialized(_this), "compareTerm", RdflibBlankNode.prototype.compareTerm);
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "elements", []);
|
|
59
|
+
_defineProperty(_assertThisInitialized(_this), "isVar", 0);
|
|
48
60
|
if (initial && initial.length > 0) {
|
|
49
|
-
initial.forEach(element
|
|
50
|
-
|
|
61
|
+
initial.forEach(function (element) {
|
|
62
|
+
_this.elements.push(fromValue(element));
|
|
51
63
|
});
|
|
52
64
|
}
|
|
65
|
+
return _this;
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* Appends an element to this collection
|
|
63
|
-
* @param element - The new element
|
|
64
|
-
*/
|
|
65
|
-
append(element) {
|
|
66
|
-
return this.elements.push(element);
|
|
67
|
-
}
|
|
67
|
+
_createClass(Collection, [{
|
|
68
|
+
key: "id",
|
|
69
|
+
get: function get() {
|
|
70
|
+
return this.value;
|
|
71
|
+
},
|
|
72
|
+
set: function set(value) {
|
|
73
|
+
this.value = value;
|
|
74
|
+
}
|
|
68
75
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Appends an element to this collection
|
|
78
|
+
* @param element - The new element
|
|
79
|
+
*/
|
|
80
|
+
}, {
|
|
81
|
+
key: "append",
|
|
82
|
+
value: function append(element) {
|
|
83
|
+
return this.elements.push(element);
|
|
84
|
+
}
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Closes this collection
|
|
88
|
+
*/
|
|
89
|
+
}, {
|
|
90
|
+
key: "close",
|
|
91
|
+
value: function close() {
|
|
92
|
+
this.closed = true;
|
|
93
|
+
return this.closed;
|
|
94
|
+
}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
toNT() {
|
|
93
|
-
return Collection.toNT(this);
|
|
94
|
-
}
|
|
95
|
-
static toNT(collection) {
|
|
96
|
-
// return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
|
|
97
|
-
// As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
|
|
98
|
-
return RdflibBlankNode.NTAnonymousNodePrefix + collection.id;
|
|
99
|
-
}
|
|
96
|
+
/**
|
|
97
|
+
* Removes the first element from the collection (and return it)
|
|
98
|
+
*/
|
|
99
|
+
}, {
|
|
100
|
+
key: "shift",
|
|
101
|
+
value: function shift() {
|
|
102
|
+
return this.elements.shift();
|
|
103
|
+
}
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Creates a new Collection with the substituting bindings applied
|
|
107
|
+
* @param bindings - The bindings to substitute
|
|
108
|
+
*/
|
|
109
|
+
}, {
|
|
110
|
+
key: "substitute",
|
|
111
|
+
value: function substitute(bindings) {
|
|
112
|
+
var elementsCopy = this.elements.map(function (ea) {
|
|
113
|
+
return ea.substitute(bindings);
|
|
114
|
+
});
|
|
115
|
+
return new Collection(elementsCopy);
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "toNT",
|
|
119
|
+
value: function toNT() {
|
|
120
|
+
return Collection.toNT(this);
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "toString",
|
|
124
|
+
value:
|
|
125
|
+
/**
|
|
126
|
+
* Serializes the collection to a string.
|
|
127
|
+
* Surrounded by (parentheses) and separated by spaces.
|
|
128
|
+
*/
|
|
129
|
+
function toString() {
|
|
130
|
+
return '(' + this.elements.join(' ') + ')';
|
|
131
|
+
}
|
|
108
132
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Prepends the specified element to the collection's front
|
|
135
|
+
* @param element - The element to prepend
|
|
136
|
+
*/
|
|
137
|
+
}, {
|
|
138
|
+
key: "unshift",
|
|
139
|
+
value: function unshift(element) {
|
|
140
|
+
return this.elements.unshift(element);
|
|
141
|
+
}
|
|
142
|
+
}], [{
|
|
143
|
+
key: "toNT",
|
|
144
|
+
value: function toNT(collection) {
|
|
145
|
+
// return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
|
|
146
|
+
// As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
|
|
147
|
+
return RdflibBlankNode.NTAnonymousNodePrefix + collection.id;
|
|
148
|
+
}
|
|
149
|
+
}]);
|
|
150
|
+
return Collection;
|
|
151
|
+
}(Node);
|
|
152
|
+
_defineProperty(Collection, "termType", CollectionTermType);
|
|
153
|
+
export { Collection as default };
|
package/esm/default-graph.js
CHANGED
|
@@ -1,23 +1,43 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
1
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2
10
|
import Node from './node-internal';
|
|
3
11
|
import { DefaultGraphTermType } from './types';
|
|
4
12
|
import { defaultGraphURI } from './utils/default-graph-uri';
|
|
5
13
|
|
|
6
14
|
/** The RDF default graph */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
var DefaultGraph = /*#__PURE__*/function (_Node) {
|
|
16
|
+
_inherits(DefaultGraph, _Node);
|
|
17
|
+
var _super = _createSuper(DefaultGraph);
|
|
18
|
+
function DefaultGraph() {
|
|
19
|
+
var _this;
|
|
20
|
+
_classCallCheck(this, DefaultGraph);
|
|
21
|
+
_this = _super.call(this, '');
|
|
22
|
+
_defineProperty(_assertThisInitialized(_this), "value", '');
|
|
23
|
+
_defineProperty(_assertThisInitialized(_this), "termType", DefaultGraphTermType);
|
|
24
|
+
_defineProperty(_assertThisInitialized(_this), "uri", defaultGraphURI);
|
|
25
|
+
return _this;
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
27
|
+
_createClass(DefaultGraph, [{
|
|
28
|
+
key: "toCanonical",
|
|
29
|
+
value: function toCanonical() {
|
|
30
|
+
return this.value;
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "toString",
|
|
34
|
+
value: function toString() {
|
|
35
|
+
return 'DefaultGraph';
|
|
36
|
+
}
|
|
37
|
+
}]);
|
|
38
|
+
return DefaultGraph;
|
|
39
|
+
}(Node);
|
|
40
|
+
export { DefaultGraph as default };
|
|
21
41
|
export function isDefaultGraph(object) {
|
|
22
42
|
return !!object && object.termType === DefaultGraphTermType;
|
|
23
43
|
}
|
package/esm/empty.js
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
1
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
2
10
|
import Node from './node-internal';
|
|
3
11
|
import { EmptyTermType } from './types';
|
|
4
12
|
/**
|
|
5
13
|
* An empty node
|
|
6
14
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
var Empty = /*#__PURE__*/function (_Node) {
|
|
16
|
+
_inherits(Empty, _Node);
|
|
17
|
+
var _super = _createSuper(Empty);
|
|
18
|
+
function Empty() {
|
|
19
|
+
var _this;
|
|
20
|
+
_classCallCheck(this, Empty);
|
|
21
|
+
_this = _super.call(this, '');
|
|
22
|
+
_defineProperty(_assertThisInitialized(_this), "termType", EmptyTermType);
|
|
23
|
+
return _this;
|
|
11
24
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
_createClass(Empty, [{
|
|
26
|
+
key: "toString",
|
|
27
|
+
value: function toString() {
|
|
28
|
+
return '()';
|
|
29
|
+
}
|
|
30
|
+
}]);
|
|
31
|
+
return Empty;
|
|
32
|
+
}(Node);
|
|
33
|
+
export { Empty as default };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
var _supports;
|
|
1
3
|
import BlankNode from '../blank-node';
|
|
2
4
|
import Literal from '../literal';
|
|
3
5
|
import NamedNode from '../named-node';
|
|
@@ -12,31 +14,25 @@ export { defaultGraphURI } from '../utils/default-graph-uri';
|
|
|
12
14
|
/**
|
|
13
15
|
* Gets the default graph
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
var _defaultGraph = new DefaultGraph();
|
|
16
18
|
|
|
17
19
|
/** A basic internal RDFlib datafactory, which does not support Collections */
|
|
18
|
-
|
|
19
|
-
supports: {
|
|
20
|
-
[Feature.collections]: false,
|
|
21
|
-
[Feature.defaultGraphType]: false,
|
|
22
|
-
[Feature.equalsMethod]: true,
|
|
23
|
-
[Feature.identity]: false,
|
|
24
|
-
[Feature.id]: true,
|
|
25
|
-
[Feature.reversibleId]: false,
|
|
26
|
-
[Feature.variableType]: true
|
|
27
|
-
},
|
|
20
|
+
var CanonicalDataFactory = {
|
|
21
|
+
supports: (_supports = {}, _defineProperty(_supports, Feature.collections, false), _defineProperty(_supports, Feature.defaultGraphType, false), _defineProperty(_supports, Feature.equalsMethod, true), _defineProperty(_supports, Feature.identity, false), _defineProperty(_supports, Feature.id, true), _defineProperty(_supports, Feature.reversibleId, false), _defineProperty(_supports, Feature.variableType, true), _supports),
|
|
28
22
|
/**
|
|
29
23
|
* Creates a new blank node
|
|
30
24
|
* @param value - The blank node's identifier
|
|
31
25
|
*/
|
|
32
|
-
blankNode(value) {
|
|
26
|
+
blankNode: function blankNode(value) {
|
|
33
27
|
return new BlankNode(value);
|
|
34
28
|
},
|
|
35
|
-
defaultGraph: ()
|
|
29
|
+
defaultGraph: function defaultGraph() {
|
|
30
|
+
return _defaultGraph;
|
|
31
|
+
},
|
|
36
32
|
/**
|
|
37
33
|
* Compares to (rdf) objects for equality.
|
|
38
34
|
*/
|
|
39
|
-
equals(a, b) {
|
|
35
|
+
equals: function equals(a, b) {
|
|
40
36
|
if (a === b || !a || !b) {
|
|
41
37
|
return true;
|
|
42
38
|
}
|
|
@@ -59,7 +55,7 @@ const CanonicalDataFactory = {
|
|
|
59
55
|
* @example Use this to associate data with a term in an object
|
|
60
56
|
* { obj[id(term)] = "myData" }
|
|
61
57
|
*/
|
|
62
|
-
id(term) {
|
|
58
|
+
id: function id(term) {
|
|
63
59
|
if (!term) {
|
|
64
60
|
return 'undefined';
|
|
65
61
|
}
|
|
@@ -72,14 +68,14 @@ const CanonicalDataFactory = {
|
|
|
72
68
|
case VariableTermType:
|
|
73
69
|
return Variable.toString(term);
|
|
74
70
|
default:
|
|
75
|
-
|
|
71
|
+
var nq = this.termToNQ(term);
|
|
76
72
|
if (nq) {
|
|
77
73
|
return nq;
|
|
78
74
|
}
|
|
79
|
-
throw new Error(
|
|
75
|
+
throw new Error("Can't id term with type '".concat(term.termType, "'"));
|
|
80
76
|
}
|
|
81
77
|
},
|
|
82
|
-
isQuad(obj) {
|
|
78
|
+
isQuad: function isQuad(obj) {
|
|
83
79
|
return obj instanceof Statement;
|
|
84
80
|
},
|
|
85
81
|
/**
|
|
@@ -87,11 +83,11 @@ const CanonicalDataFactory = {
|
|
|
87
83
|
* @param value - The lexical value
|
|
88
84
|
* @param languageOrDatatype - Either the language or the datatype
|
|
89
85
|
*/
|
|
90
|
-
literal(value, languageOrDatatype) {
|
|
86
|
+
literal: function literal(value, languageOrDatatype) {
|
|
91
87
|
if (typeof value !== "string" && !languageOrDatatype) {
|
|
92
88
|
return Literal.fromValue(value);
|
|
93
89
|
}
|
|
94
|
-
|
|
90
|
+
var strValue = typeof value === 'string' ? value : '' + value;
|
|
95
91
|
if (typeof languageOrDatatype === 'string') {
|
|
96
92
|
if (languageOrDatatype.indexOf(':') === -1) {
|
|
97
93
|
return new Literal(strValue, languageOrDatatype);
|
|
@@ -106,7 +102,7 @@ const CanonicalDataFactory = {
|
|
|
106
102
|
* Creates a new named node
|
|
107
103
|
* @param value - The new named node
|
|
108
104
|
*/
|
|
109
|
-
namedNode(value) {
|
|
105
|
+
namedNode: function namedNode(value) {
|
|
110
106
|
return new NamedNode(value);
|
|
111
107
|
},
|
|
112
108
|
/**
|
|
@@ -116,8 +112,8 @@ const CanonicalDataFactory = {
|
|
|
116
112
|
* @param object - The object
|
|
117
113
|
* @param graph - The containing graph
|
|
118
114
|
*/
|
|
119
|
-
quad(subject, predicate, object, graph) {
|
|
120
|
-
return new Statement(subject, predicate, object, graph ||
|
|
115
|
+
quad: function quad(subject, predicate, object, graph) {
|
|
116
|
+
return new Statement(subject, predicate, object, graph || _defaultGraph);
|
|
121
117
|
},
|
|
122
118
|
/**
|
|
123
119
|
* Creates a new statement
|
|
@@ -126,14 +122,14 @@ const CanonicalDataFactory = {
|
|
|
126
122
|
* @param object - The object
|
|
127
123
|
* @param graph - The containing graph
|
|
128
124
|
*/
|
|
129
|
-
triple(subject, predicate, object, graph) {
|
|
125
|
+
triple: function triple(subject, predicate, object, graph) {
|
|
130
126
|
return this.quad(subject, predicate, object, graph);
|
|
131
127
|
},
|
|
132
|
-
quadToNQ(q) {
|
|
133
|
-
return
|
|
128
|
+
quadToNQ: function quadToNQ(q) {
|
|
129
|
+
return "".concat(this.termToNQ(q.subject), " ").concat(this.termToNQ(q.predicate), " ").concat(this.termToNQ(q.object), " ").concat(this.termToNQ(q.graph), " .");
|
|
134
130
|
},
|
|
135
|
-
/** Stringify a {term} to n-quads serialization. */
|
|
136
|
-
|
|
131
|
+
/** Stringify a {term} to n-quads serialization. */termToNQ: function termToNQ(term) {
|
|
132
|
+
var _this = this;
|
|
137
133
|
switch (term.termType) {
|
|
138
134
|
case BlankNodeTermType:
|
|
139
135
|
return '_:' + term.value;
|
|
@@ -147,13 +143,14 @@ const CanonicalDataFactory = {
|
|
|
147
143
|
case NamedNodeTermType:
|
|
148
144
|
return '<' + term.value + '>';
|
|
149
145
|
case CollectionTermType:
|
|
150
|
-
return '(' + term.elements.map(
|
|
146
|
+
return '(' + term.elements.map(function (t) {
|
|
147
|
+
return _this.termToNQ(t);
|
|
148
|
+
}).join(' ') + ')';
|
|
151
149
|
default:
|
|
152
|
-
throw new Error(
|
|
150
|
+
throw new Error("Can't serialize nonstandard term type (was '".concat(term.termType, "')"));
|
|
153
151
|
}
|
|
154
152
|
},
|
|
155
|
-
/** Convert an rdf object (term or quad) to n-quads serialization. */
|
|
156
|
-
toNQ(term) {
|
|
153
|
+
/** Convert an rdf object (term or quad) to n-quads serialization. */toNQ: function toNQ(term) {
|
|
157
154
|
if (this.isQuad(term)) {
|
|
158
155
|
return this.quadToNQ(term);
|
|
159
156
|
}
|
|
@@ -163,7 +160,7 @@ const CanonicalDataFactory = {
|
|
|
163
160
|
* Creates a new variable
|
|
164
161
|
* @param name - The name for the variable
|
|
165
162
|
*/
|
|
166
|
-
variable(name) {
|
|
163
|
+
variable: function variable(name) {
|
|
167
164
|
return new Variable(name);
|
|
168
165
|
}
|
|
169
166
|
};
|