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