rdflib 2.2.34 → 2.2.35-2bb9ed0b
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/515.rdflib.min.js +3 -0
- package/dist/515.rdflib.min.js.map +1 -0
- package/dist/789.rdflib.min.js +1 -0
- 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 -85
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -106
- package/esm/default-graph.js +13 -33
- package/esm/empty.js +8 -26
- package/esm/factories/canonical-data-factory.js +33 -30
- package/esm/factories/extended-term-factory.js +18 -14
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1364 -1668
- package/esm/formula.js +631 -739
- package/esm/index.js +31 -51
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +41 -86
- package/esm/literal.js +120 -157
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1008 -1090
- package/esm/named-node.js +69 -99
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -97
- package/esm/node.js +1 -2
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -2
- package/esm/query.js +15 -30
- package/esm/rdfaparser.js +775 -846
- package/esm/rdfxmlparser.js +348 -365
- package/esm/serialize.js +2 -3
- package/esm/serializer.js +834 -889
- package/esm/sparql-to-query.js +0 -2
- package/esm/statement.js +52 -72
- package/esm/store.js +852 -963
- package/esm/types.js +26 -21
- package/esm/update-manager.js +963 -1104
- package/esm/updates-via.js +104 -134
- 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 -6
- package/esm/utils.js +7 -6
- package/esm/variable.js +32 -58
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +56 -83
- package/lib/class-order.js +2 -3
- package/lib/collection.js +69 -104
- package/lib/default-graph.js +13 -32
- package/lib/empty.js +8 -25
- package/lib/factories/canonical-data-factory.js +36 -34
- package/lib/factories/extended-term-factory.js +19 -16
- package/lib/factories/factory-types.js +2 -3
- package/lib/factories/rdflib-data-factory.js +10 -13
- package/lib/fetcher.js +1394 -1693
- package/lib/formula.js +631 -738
- package/lib/index.js +66 -89
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +3 -4
- package/lib/lists.js +47 -87
- package/lib/literal.js +120 -156
- package/lib/log.js +8 -9
- package/lib/n3parser.js +1011 -1096
- package/lib/named-node.js +69 -98
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +72 -95
- package/lib/node.js +2 -4
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -2
- package/lib/query.js +19 -32
- package/lib/rdfaparser.js +777 -849
- package/lib/rdfxmlparser.js +350 -366
- package/lib/serialize.js +2 -3
- package/lib/serializer.js +838 -892
- package/lib/sparql-to-query.js +0 -2
- package/lib/statement.js +54 -74
- package/lib/store.js +873 -978
- package/lib/types.js +22 -43
- package/lib/update-manager.js +972 -1111
- package/lib/updates-via.js +105 -134
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -4
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +11 -13
- package/lib/utils.js +6 -7
- package/lib/variable.js +34 -60
- package/lib/xsd-internal.js +2 -3
- package/lib/xsd.js +3 -4
- package/package.json +31 -31
- package/src/n3parser.js +1 -1
- package/src/rdfxmlparser.js +2 -1
- package/src/serializer.js +1 -1
- package/.babelrc +0 -20
- package/dist/670.rdflib.min.js +0 -1
- package/dist/730.rdflib.min.js +0 -3
- package/dist/730.rdflib.min.js.map +0 -1
- /package/dist/{730.rdflib.min.js.LICENSE.txt → 515.rdflib.min.js.LICENSE.txt} +0 -0
package/esm/blank-node.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
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";
|
|
7
1
|
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; } }
|
|
10
2
|
import ClassOrder from './class-order';
|
|
11
3
|
import Node from './node-internal';
|
|
12
4
|
import { BlankNodeTermType } from './types';
|
|
@@ -14,103 +6,83 @@ import { BlankNodeTermType } from './types';
|
|
|
14
6
|
* An RDF blank node is a Node without a URI
|
|
15
7
|
* @link https://rdf.js.org/data-model-spec/#blanknode-interface
|
|
16
8
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
24
|
/**
|
|
21
25
|
* Initializes this node
|
|
22
26
|
* @param [id] The identifier for the blank node
|
|
23
27
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_defineProperty(_assertThisInitialized(_this), "termType", BlankNodeTermType);
|
|
29
|
-
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.BlankNode);
|
|
28
|
+
constructor(id) {
|
|
29
|
+
super(BlankNode.getId(id));
|
|
30
|
+
_defineProperty(this, "termType", BlankNodeTermType);
|
|
31
|
+
_defineProperty(this, "classOrder", ClassOrder.BlankNode);
|
|
30
32
|
/** Whether this is a blank node */
|
|
31
|
-
_defineProperty(
|
|
33
|
+
_defineProperty(this, "isBlank", 1);
|
|
32
34
|
/**
|
|
33
35
|
* This type of node is a variable.
|
|
34
36
|
*
|
|
35
37
|
* Note that the existence of this property already indicates that it is a variable.
|
|
36
38
|
*/
|
|
37
|
-
_defineProperty(
|
|
38
|
-
return _this;
|
|
39
|
+
_defineProperty(this, "isVar", 1);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* The identifier for the blank node
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
key: "compareTerm",
|
|
54
|
-
value: function compareTerm(other) {
|
|
55
|
-
if (this.classOrder < other.classOrder) {
|
|
56
|
-
return -1;
|
|
57
|
-
}
|
|
58
|
-
if (this.classOrder > other.classOrder) {
|
|
59
|
-
return +1;
|
|
60
|
-
}
|
|
61
|
-
if (this.id < other.id) {
|
|
62
|
-
return -1;
|
|
63
|
-
}
|
|
64
|
-
if (this.id > other.id) {
|
|
65
|
-
return +1;
|
|
66
|
-
}
|
|
67
|
-
return 0;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Gets a copy of this blank node in the specified formula
|
|
72
|
-
* @param formula The formula
|
|
73
|
-
*/
|
|
74
|
-
}, {
|
|
75
|
-
key: "copy",
|
|
76
|
-
value: function copy(formula) {
|
|
77
|
-
// depends on the formula
|
|
78
|
-
var bnodeNew = new BlankNode();
|
|
79
|
-
formula.copyTo(this, bnodeNew);
|
|
80
|
-
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;
|
|
81
54
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
value: function toCanonical() {
|
|
85
|
-
return BlankNode.NTAnonymousNodePrefix + this.value;
|
|
55
|
+
if (this.classOrder > other.classOrder) {
|
|
56
|
+
return +1;
|
|
86
57
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
value: function toString() {
|
|
90
|
-
return BlankNode.NTAnonymousNodePrefix + this.id;
|
|
58
|
+
if (this.id < other.id) {
|
|
59
|
+
return -1;
|
|
91
60
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
value: function getId(id) {
|
|
95
|
-
if (id) {
|
|
96
|
-
if (typeof id !== 'string') {
|
|
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++;
|
|
61
|
+
if (this.id > other.id) {
|
|
62
|
+
return +1;
|
|
107
63
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
+
}
|
|
111
84
|
/**
|
|
112
85
|
* The next unique identifier for blank nodes
|
|
113
86
|
*/
|
|
114
87
|
_defineProperty(BlankNode, "nextId", 0);
|
|
115
|
-
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
|
116
|
-
export { BlankNode as default };
|
|
88
|
+
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
package/esm/class-order.js
CHANGED
package/esm/collection.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
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";
|
|
7
1
|
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; } }
|
|
10
2
|
import RdflibBlankNode from './blank-node';
|
|
11
3
|
import ClassOrder from './class-order';
|
|
12
4
|
import Literal from './literal';
|
|
@@ -40,113 +32,85 @@ export function fromValue(value) {
|
|
|
40
32
|
*
|
|
41
33
|
* Use generic T to control the contents of the array.
|
|
42
34
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_defineProperty(_assertThisInitialized(_this), "termType", CollectionTermType);
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Collection);
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "closed", false);
|
|
53
|
-
_defineProperty(_assertThisInitialized(_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);
|
|
54
42
|
/**
|
|
55
43
|
* The nodes in this collection
|
|
56
44
|
*/
|
|
57
|
-
_defineProperty(
|
|
58
|
-
_defineProperty(
|
|
45
|
+
_defineProperty(this, "elements", []);
|
|
46
|
+
_defineProperty(this, "isVar", 0);
|
|
59
47
|
if (initial && initial.length > 0) {
|
|
60
|
-
initial.forEach(
|
|
61
|
-
|
|
48
|
+
initial.forEach(element => {
|
|
49
|
+
this.elements.push(fromValue(element));
|
|
62
50
|
});
|
|
63
51
|
}
|
|
64
|
-
return _this;
|
|
65
52
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.value = value;
|
|
73
|
-
}
|
|
53
|
+
get id() {
|
|
54
|
+
return this.value;
|
|
55
|
+
}
|
|
56
|
+
set id(value) {
|
|
57
|
+
this.value = value;
|
|
58
|
+
}
|
|
74
59
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return this.elements.push(element);
|
|
83
|
-
}
|
|
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
|
+
}
|
|
84
67
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return this.closed;
|
|
93
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* Closes this collection
|
|
70
|
+
*/
|
|
71
|
+
close() {
|
|
72
|
+
this.closed = true;
|
|
73
|
+
return this.closed;
|
|
74
|
+
}
|
|
94
75
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return this.elements.shift();
|
|
102
|
-
}
|
|
76
|
+
/**
|
|
77
|
+
* Removes the first element from the collection (and return it)
|
|
78
|
+
*/
|
|
79
|
+
shift() {
|
|
80
|
+
return this.elements.shift();
|
|
81
|
+
}
|
|
103
82
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "toString",
|
|
123
|
-
value:
|
|
124
|
-
/**
|
|
125
|
-
* Serializes the collection to a string.
|
|
126
|
-
* Surrounded by (parentheses) and separated by spaces.
|
|
127
|
-
*/
|
|
128
|
-
function toString() {
|
|
129
|
-
return '(' + this.elements.join(' ') + ')';
|
|
130
|
-
}
|
|
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
|
+
}
|
|
131
99
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
return Collection;
|
|
150
|
-
}(Node);
|
|
151
|
-
_defineProperty(Collection, "termType", CollectionTermType);
|
|
152
|
-
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,43 +1,23 @@
|
|
|
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";
|
|
7
1
|
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; } }
|
|
10
2
|
import Node from './node-internal';
|
|
11
3
|
import { DefaultGraphTermType } from './types';
|
|
12
4
|
import { defaultGraphURI } from './utils/default-graph-uri';
|
|
13
5
|
|
|
14
6
|
/** The RDF default graph */
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
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);
|
|
26
13
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
value: function toString() {
|
|
35
|
-
return 'DefaultGraph';
|
|
36
|
-
}
|
|
37
|
-
}]);
|
|
38
|
-
return DefaultGraph;
|
|
39
|
-
}(Node);
|
|
40
|
-
export { DefaultGraph as default };
|
|
14
|
+
toCanonical() {
|
|
15
|
+
return this.value;
|
|
16
|
+
}
|
|
17
|
+
toString() {
|
|
18
|
+
return 'DefaultGraph';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
41
21
|
export function isDefaultGraph(object) {
|
|
42
22
|
return !!object && object.termType === DefaultGraphTermType;
|
|
43
23
|
}
|
package/esm/empty.js
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
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";
|
|
7
1
|
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; } }
|
|
10
2
|
import Node from './node-internal';
|
|
11
3
|
import { EmptyTermType } from './types';
|
|
12
4
|
/**
|
|
13
5
|
* An empty node
|
|
14
6
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _this;
|
|
20
|
-
_classCallCheck(this, Empty);
|
|
21
|
-
_this = _super.call(this, '');
|
|
22
|
-
_defineProperty(_assertThisInitialized(_this), "termType", EmptyTermType);
|
|
23
|
-
return _this;
|
|
7
|
+
export default class Empty extends Node {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('');
|
|
10
|
+
_defineProperty(this, "termType", EmptyTermType);
|
|
24
11
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}]);
|
|
31
|
-
return Empty;
|
|
32
|
-
}(Node);
|
|
33
|
-
export { Empty as default };
|
|
12
|
+
toString() {
|
|
13
|
+
return '()';
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
var _supports;
|
|
3
1
|
import BlankNode from '../blank-node';
|
|
4
2
|
import Literal from '../literal';
|
|
5
3
|
import NamedNode from '../named-node';
|
|
@@ -14,25 +12,31 @@ export { defaultGraphURI } from '../utils/default-graph-uri';
|
|
|
14
12
|
/**
|
|
15
13
|
* Gets the default graph
|
|
16
14
|
*/
|
|
17
|
-
|
|
15
|
+
const defaultGraph = new DefaultGraph();
|
|
18
16
|
|
|
19
17
|
/** A basic internal RDFlib datafactory, which does not support Collections */
|
|
20
|
-
|
|
21
|
-
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
|
+
},
|
|
22
28
|
/**
|
|
23
29
|
* Creates a new blank node
|
|
24
30
|
* @param value - The blank node's identifier
|
|
25
31
|
*/
|
|
26
|
-
blankNode
|
|
32
|
+
blankNode(value) {
|
|
27
33
|
return new BlankNode(value);
|
|
28
34
|
},
|
|
29
|
-
defaultGraph:
|
|
30
|
-
return _defaultGraph;
|
|
31
|
-
},
|
|
35
|
+
defaultGraph: () => defaultGraph,
|
|
32
36
|
/**
|
|
33
37
|
* Compares to (rdf) objects for equality.
|
|
34
38
|
*/
|
|
35
|
-
equals
|
|
39
|
+
equals(a, b) {
|
|
36
40
|
if (a === b || !a || !b) {
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
@@ -55,7 +59,7 @@ var CanonicalDataFactory = {
|
|
|
55
59
|
* @example Use this to associate data with a term in an object
|
|
56
60
|
* { obj[id(term)] = "myData" }
|
|
57
61
|
*/
|
|
58
|
-
id
|
|
62
|
+
id(term) {
|
|
59
63
|
if (!term) {
|
|
60
64
|
return 'undefined';
|
|
61
65
|
}
|
|
@@ -68,14 +72,14 @@ var CanonicalDataFactory = {
|
|
|
68
72
|
case VariableTermType:
|
|
69
73
|
return Variable.toString(term);
|
|
70
74
|
default:
|
|
71
|
-
|
|
75
|
+
const nq = this.termToNQ(term);
|
|
72
76
|
if (nq) {
|
|
73
77
|
return nq;
|
|
74
78
|
}
|
|
75
|
-
throw new Error(
|
|
79
|
+
throw new Error(`Can't id term with type '${term.termType}'`);
|
|
76
80
|
}
|
|
77
81
|
},
|
|
78
|
-
isQuad
|
|
82
|
+
isQuad(obj) {
|
|
79
83
|
return obj instanceof Statement;
|
|
80
84
|
},
|
|
81
85
|
/**
|
|
@@ -83,11 +87,11 @@ var CanonicalDataFactory = {
|
|
|
83
87
|
* @param value - The lexical value
|
|
84
88
|
* @param languageOrDatatype - Either the language or the datatype
|
|
85
89
|
*/
|
|
86
|
-
literal
|
|
90
|
+
literal(value, languageOrDatatype) {
|
|
87
91
|
if (typeof value !== "string" && !languageOrDatatype) {
|
|
88
92
|
return Literal.fromValue(value);
|
|
89
93
|
}
|
|
90
|
-
|
|
94
|
+
const strValue = typeof value === 'string' ? value : '' + value;
|
|
91
95
|
if (typeof languageOrDatatype === 'string') {
|
|
92
96
|
if (languageOrDatatype.indexOf(':') === -1) {
|
|
93
97
|
return new Literal(strValue, languageOrDatatype);
|
|
@@ -102,7 +106,7 @@ var CanonicalDataFactory = {
|
|
|
102
106
|
* Creates a new named node
|
|
103
107
|
* @param value - The new named node
|
|
104
108
|
*/
|
|
105
|
-
namedNode
|
|
109
|
+
namedNode(value) {
|
|
106
110
|
return new NamedNode(value);
|
|
107
111
|
},
|
|
108
112
|
/**
|
|
@@ -112,8 +116,8 @@ var CanonicalDataFactory = {
|
|
|
112
116
|
* @param object - The object
|
|
113
117
|
* @param graph - The containing graph
|
|
114
118
|
*/
|
|
115
|
-
quad
|
|
116
|
-
return new Statement(subject, predicate, object, graph ||
|
|
119
|
+
quad(subject, predicate, object, graph) {
|
|
120
|
+
return new Statement(subject, predicate, object, graph || defaultGraph);
|
|
117
121
|
},
|
|
118
122
|
/**
|
|
119
123
|
* Creates a new statement
|
|
@@ -122,14 +126,14 @@ var CanonicalDataFactory = {
|
|
|
122
126
|
* @param object - The object
|
|
123
127
|
* @param graph - The containing graph
|
|
124
128
|
*/
|
|
125
|
-
triple
|
|
129
|
+
triple(subject, predicate, object, graph) {
|
|
126
130
|
return this.quad(subject, predicate, object, graph);
|
|
127
131
|
},
|
|
128
|
-
quadToNQ
|
|
129
|
-
return
|
|
132
|
+
quadToNQ(q) {
|
|
133
|
+
return `${this.termToNQ(q.subject)} ${this.termToNQ(q.predicate)} ${this.termToNQ(q.object)} ${this.termToNQ(q.graph)} .`;
|
|
130
134
|
},
|
|
131
|
-
/** Stringify a {term} to n-quads serialization. */
|
|
132
|
-
|
|
135
|
+
/** Stringify a {term} to n-quads serialization. */
|
|
136
|
+
termToNQ(term) {
|
|
133
137
|
switch (term.termType) {
|
|
134
138
|
case BlankNodeTermType:
|
|
135
139
|
return '_:' + term.value;
|
|
@@ -143,14 +147,13 @@ var CanonicalDataFactory = {
|
|
|
143
147
|
case NamedNodeTermType:
|
|
144
148
|
return '<' + term.value + '>';
|
|
145
149
|
case CollectionTermType:
|
|
146
|
-
return '(' + term.elements.map(
|
|
147
|
-
return _this.termToNQ(t);
|
|
148
|
-
}).join(' ') + ')';
|
|
150
|
+
return '(' + term.elements.map(t => this.termToNQ(t)).join(' ') + ')';
|
|
149
151
|
default:
|
|
150
|
-
throw new Error(
|
|
152
|
+
throw new Error(`Can't serialize nonstandard term type (was '${term.termType}')`);
|
|
151
153
|
}
|
|
152
154
|
},
|
|
153
|
-
/** 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) {
|
|
154
157
|
if (this.isQuad(term)) {
|
|
155
158
|
return this.quadToNQ(term);
|
|
156
159
|
}
|
|
@@ -160,7 +163,7 @@ var CanonicalDataFactory = {
|
|
|
160
163
|
* Creates a new variable
|
|
161
164
|
* @param name - The name for the variable
|
|
162
165
|
*/
|
|
163
|
-
variable
|
|
166
|
+
variable(name) {
|
|
164
167
|
return new Variable(name);
|
|
165
168
|
}
|
|
166
169
|
};
|