rdflib 2.2.10 → 2.2.12-5f141ca2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/.babelrc +0 -0
  2. package/README.md +1 -0
  3. package/changes.txt +0 -0
  4. package/dist/rdflib.min.js +62 -0
  5. package/dist/rdflib.min.js.map +1 -0
  6. package/esm/blank-node.js +137 -0
  7. package/esm/class-order.js +12 -0
  8. package/esm/collection.js +173 -0
  9. package/esm/convert.js +61 -0
  10. package/esm/default-graph.js +57 -0
  11. package/esm/empty.js +46 -0
  12. package/esm/factories/canonical-data-factory.js +204 -0
  13. package/esm/factories/extended-term-factory.js +55 -0
  14. package/esm/factories/factory-types.js +18 -0
  15. package/esm/factories/rdflib-data-factory.js +55 -0
  16. package/esm/fetcher.js +2180 -0
  17. package/esm/formula.js +987 -0
  18. package/esm/index.js +64 -0
  19. package/esm/jsonldparser.js +122 -0
  20. package/esm/jsonparser.js +60 -0
  21. package/esm/literal.js +236 -0
  22. package/esm/log.js +13 -0
  23. package/esm/n3parser.js +1854 -0
  24. package/esm/named-node.js +154 -0
  25. package/esm/namespace.js +17 -0
  26. package/esm/node-internal.js +151 -0
  27. package/esm/node.js +46 -0
  28. package/esm/parse.js +138 -0
  29. package/esm/patch-parser.js +110 -0
  30. package/esm/query-to-sparql.js +83 -0
  31. package/esm/query.js +620 -0
  32. package/esm/rdfaparser.js +1197 -0
  33. package/esm/rdfxmlparser.js +588 -0
  34. package/esm/serialize.js +95 -0
  35. package/esm/serializer.js +1162 -0
  36. package/esm/sparql-to-query.js +566 -0
  37. package/esm/statement.js +128 -0
  38. package/esm/store.js +1306 -0
  39. package/esm/tf-types.js +1 -0
  40. package/esm/types.js +25 -0
  41. package/esm/update-manager.js +1252 -0
  42. package/esm/updates-via.js +197 -0
  43. package/esm/uri.js +245 -0
  44. package/esm/utils/default-graph-uri.js +4 -0
  45. package/esm/utils/termValue.js +8 -0
  46. package/esm/utils/terms.js +72 -0
  47. package/esm/utils-js.js +348 -0
  48. package/esm/utils.js +103 -0
  49. package/esm/variable.js +101 -0
  50. package/esm/xsd-internal.js +10 -0
  51. package/esm/xsd.js +15 -0
  52. package/lib/blank-node.d.ts +44 -0
  53. package/lib/blank-node.js +0 -0
  54. package/lib/class-order.d.ts +7 -0
  55. package/lib/class-order.js +0 -0
  56. package/lib/collection.d.ts +65 -0
  57. package/lib/collection.js +0 -0
  58. package/lib/convert.d.ts +2 -0
  59. package/lib/convert.js +0 -0
  60. package/lib/default-graph.d.ts +13 -0
  61. package/lib/default-graph.js +0 -0
  62. package/lib/empty.d.ts +11 -0
  63. package/lib/empty.js +0 -0
  64. package/lib/factories/canonical-data-factory.d.ts +6 -0
  65. package/lib/factories/canonical-data-factory.js +0 -0
  66. package/lib/factories/extended-term-factory.d.ts +13 -0
  67. package/lib/factories/extended-term-factory.js +0 -0
  68. package/lib/factories/factory-types.d.ts +67 -0
  69. package/lib/factories/factory-types.js +0 -0
  70. package/lib/factories/rdflib-data-factory.d.ts +4 -0
  71. package/lib/factories/rdflib-data-factory.js +0 -0
  72. package/lib/fetcher.d.ts +443 -0
  73. package/lib/fetcher.js +3 -2
  74. package/lib/formula.d.ts +327 -0
  75. package/lib/formula.js +0 -0
  76. package/lib/index.d.ts +40 -0
  77. package/lib/index.js +0 -0
  78. package/lib/jsonldparser.d.ts +13 -0
  79. package/lib/jsonldparser.js +0 -0
  80. package/lib/jsonparser.d.ts +4 -0
  81. package/lib/jsonparser.js +0 -0
  82. package/lib/literal.d.ts +67 -0
  83. package/lib/literal.js +0 -0
  84. package/lib/log.d.ts +15 -0
  85. package/lib/log.js +0 -0
  86. package/lib/n3parser.d.ts +62 -0
  87. package/lib/n3parser.js +1334 -1289
  88. package/lib/named-node.d.ts +44 -0
  89. package/lib/named-node.js +0 -0
  90. package/lib/namespace.d.ts +7 -0
  91. package/lib/namespace.js +0 -0
  92. package/lib/node-internal.d.ts +63 -0
  93. package/lib/node-internal.js +0 -0
  94. package/lib/node.d.ts +2 -0
  95. package/lib/node.js +0 -0
  96. package/lib/parse.d.ts +16 -0
  97. package/lib/parse.js +0 -0
  98. package/lib/patch-parser.d.ts +3 -0
  99. package/lib/patch-parser.js +0 -0
  100. package/lib/query-to-sparql.d.ts +1 -0
  101. package/lib/query-to-sparql.js +0 -0
  102. package/lib/query.d.ts +27 -0
  103. package/lib/query.js +0 -0
  104. package/lib/rdfaparser.d.ts +78 -0
  105. package/lib/rdfaparser.js +0 -0
  106. package/lib/rdfxmlparser.d.ts +60 -0
  107. package/lib/rdfxmlparser.js +430 -413
  108. package/lib/serialize.d.ts +23 -0
  109. package/lib/serialize.js +1 -1
  110. package/lib/serializer.d.ts +54 -0
  111. package/lib/serializer.js +851 -824
  112. package/lib/sparql-to-query.d.ts +6 -0
  113. package/lib/sparql-to-query.js +0 -0
  114. package/lib/statement.d.ts +55 -0
  115. package/lib/statement.js +0 -0
  116. package/lib/store.d.ts +302 -0
  117. package/lib/store.js +0 -0
  118. package/lib/tf-types.d.ts +151 -0
  119. package/lib/tf-types.js +0 -0
  120. package/lib/types.d.ts +68 -0
  121. package/lib/types.js +0 -0
  122. package/lib/update-manager.d.ts +198 -0
  123. package/lib/update-manager.js +0 -0
  124. package/lib/updates-via.d.ts +26 -0
  125. package/lib/updates-via.js +0 -0
  126. package/lib/uri.d.ts +33 -0
  127. package/lib/uri.js +0 -0
  128. package/lib/utils/default-graph-uri.d.ts +3 -0
  129. package/lib/utils/default-graph-uri.js +0 -0
  130. package/lib/utils/termValue.d.ts +3 -0
  131. package/lib/utils/termValue.js +0 -0
  132. package/lib/utils/terms.d.ts +33 -0
  133. package/lib/utils/terms.js +0 -0
  134. package/lib/utils-js.d.ts +50 -0
  135. package/lib/utils-js.js +0 -0
  136. package/lib/utils.d.ts +20 -0
  137. package/lib/utils.js +0 -0
  138. package/lib/variable.d.ts +29 -0
  139. package/lib/variable.js +0 -0
  140. package/lib/xsd-internal.d.ts +11 -0
  141. package/lib/xsd-internal.js +0 -0
  142. package/lib/xsd.d.ts +19 -0
  143. package/lib/xsd.js +8 -14
  144. package/package.json +3 -3
  145. package/src/blank-node.ts +0 -0
  146. package/src/class-order.ts +0 -0
  147. package/src/collection.ts +0 -0
  148. package/src/convert.js +0 -0
  149. package/src/default-graph.ts +0 -0
  150. package/src/empty.ts +0 -0
  151. package/src/factories/canonical-data-factory.ts +0 -0
  152. package/src/factories/extended-term-factory.ts +0 -0
  153. package/src/factories/factory-types.ts +0 -0
  154. package/src/factories/rdflib-data-factory.ts +0 -0
  155. package/src/fetcher.ts +6 -3
  156. package/src/formula.ts +0 -0
  157. package/src/index.ts +0 -0
  158. package/src/jsonldparser.js +0 -0
  159. package/src/jsonparser.js +0 -0
  160. package/src/literal.ts +0 -0
  161. package/src/log.js +0 -0
  162. package/src/n3parser.js +1114 -1110
  163. package/src/named-node.ts +0 -0
  164. package/src/namespace.ts +0 -0
  165. package/src/node-internal.ts +0 -0
  166. package/src/node.ts +0 -0
  167. package/src/parse.ts +0 -0
  168. package/src/patch-parser.js +0 -0
  169. package/src/query-to-sparql.js +0 -0
  170. package/src/query.js +0 -0
  171. package/src/rdfaparser.js +0 -0
  172. package/src/rdfxmlparser.js +22 -21
  173. package/src/serialize.ts +3 -3
  174. package/src/serializer.js +74 -62
  175. package/src/sparql-to-query.js +0 -0
  176. package/src/statement.ts +0 -0
  177. package/src/store.ts +0 -0
  178. package/src/tf-types.ts +0 -0
  179. package/src/types.ts +0 -0
  180. package/src/update-manager.ts +0 -0
  181. package/src/updates-via.js +0 -0
  182. package/src/uri.ts +0 -0
  183. package/src/utils/default-graph-uri.ts +0 -0
  184. package/src/utils/termValue.ts +0 -0
  185. package/src/utils/terms.ts +0 -0
  186. package/src/utils-js.js +0 -0
  187. package/src/utils.ts +0 -0
  188. package/src/variable.ts +0 -0
  189. package/src/xsd-internal.js +0 -0
  190. package/src/xsd.js +16 -14
@@ -0,0 +1,197 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+
4
+ /*
5
+ * Updates-Via
6
+ */
7
+ import DataFactory from './factories/rdflib-data-factory';
8
+ export var UpdatesSocket = /*#__PURE__*/function () {
9
+ function UpdatesSocket(parent, via) {
10
+ _classCallCheck(this, UpdatesSocket);
11
+
12
+ this.parent = parent;
13
+ this.via = via;
14
+ this.connected = false;
15
+ this.pending = {};
16
+ this.subscribed = {};
17
+ this.socket = {};
18
+
19
+ try {
20
+ this.socket = new WebSocket(via);
21
+ this.socket.onopen = this.onOpen;
22
+ this.socket.onclose = this.onClose;
23
+ this.socket.onmessage = this.onMessage;
24
+ this.socket.onerror = this.onError;
25
+ } catch (error) {
26
+ this.onError(error);
27
+ }
28
+ }
29
+
30
+ _createClass(UpdatesSocket, [{
31
+ key: "_decode",
32
+ value: function _decode(q) {
33
+ var elt;
34
+ var i;
35
+ var k;
36
+ var r;
37
+ var ref;
38
+ var ref1;
39
+ var v;
40
+ r = {};
41
+
42
+ ref = function () {
43
+ var j, len, ref, results;
44
+ ref = q.split('&');
45
+ results = [];
46
+
47
+ for (j = 0, len = ref.length; j < len; j++) {
48
+ elt = ref[j];
49
+ results.push(elt.split('='));
50
+ }
51
+
52
+ return results;
53
+ }();
54
+
55
+ for (i in ref) {
56
+ elt = ref[i];
57
+ ref1 = [decodeURIComponent(elt[0]), decodeURIComponent(elt[1])];
58
+ k = ref1[0];
59
+ v = ref1[1];
60
+
61
+ if (r[k] == null) {
62
+ r[k] = [];
63
+ }
64
+
65
+ r[k].push(v);
66
+ }
67
+
68
+ return r;
69
+ }
70
+ }, {
71
+ key: "_send",
72
+ value: function _send(method, uri, data) {
73
+ var base, message;
74
+ message = [method, uri, data].join(' ');
75
+ return typeof (base = this.socket).send === 'function' ? base.send(message) : void 0;
76
+ }
77
+ }, {
78
+ key: "_subscribe",
79
+ value: function _subscribe(uri) {
80
+ this._send('sub', uri, '');
81
+
82
+ this.subscribed[uri] = true;
83
+ return this.subscribed[uri];
84
+ }
85
+ }, {
86
+ key: "onClose",
87
+ value: function onClose(e) {
88
+ var uri;
89
+ this.connected = false;
90
+
91
+ for (uri in this.subscribed) {
92
+ this.pending[uri] = true;
93
+ }
94
+
95
+ this.subscribed = {};
96
+ return this.subscribed;
97
+ }
98
+ }, {
99
+ key: "onError",
100
+ value: function onError(e) {
101
+ throw new Error('onError' + e);
102
+ }
103
+ }, {
104
+ key: "onMessage",
105
+ value: function onMessage(e) {
106
+ var base, message;
107
+ message = e.data.split(' ');
108
+
109
+ if (message[0] === 'ping') {
110
+ return typeof (base = this.socket).send === 'function' ? base.send('pong ' + message.slice(1).join(' ')) : void 0;
111
+ } else if (message[0] === 'pub') {
112
+ return this.parent.onUpdate(message[1], this._decode(message[2]));
113
+ }
114
+ }
115
+ }, {
116
+ key: "onOpen",
117
+ value: function onOpen(e) {
118
+ var results, uri;
119
+ this.connected = true;
120
+ results = [];
121
+
122
+ for (uri in this.pending) {
123
+ delete this.pending[uri];
124
+ results.push(this._subscribe(uri));
125
+ }
126
+
127
+ return results;
128
+ }
129
+ }, {
130
+ key: "subscribe",
131
+ value: function subscribe(uri) {
132
+ if (this.connected) {
133
+ return this._subscribe(uri);
134
+ } else {
135
+ this.pending[uri] = true;
136
+ return this.pending[uri];
137
+ }
138
+ }
139
+ }]);
140
+
141
+ return UpdatesSocket;
142
+ }();
143
+ export var UpdatesVia = /*#__PURE__*/function () {
144
+ function UpdatesVia(fetcher) {
145
+ _classCallCheck(this, UpdatesVia);
146
+
147
+ this.fetcher = fetcher;
148
+ this.graph = {};
149
+ this.via = {};
150
+ this.fetcher.addCallback('headers', this.onHeaders);
151
+ }
152
+
153
+ _createClass(UpdatesVia, [{
154
+ key: "onHeaders",
155
+ value: function onHeaders(d) {
156
+ var etag, uri, via;
157
+
158
+ if (d.headers == null) {
159
+ return true;
160
+ }
161
+
162
+ if (typeof WebSocket === 'undefined' || WebSocket === null) {
163
+ return true;
164
+ }
165
+
166
+ etag = d.headers['etag'];
167
+ via = d.headers['updates-via'];
168
+ uri = d.uri;
169
+
170
+ if (etag && via) {
171
+ this.graph[uri] = {
172
+ etag: etag,
173
+ via: via
174
+ };
175
+ this.register(via, uri);
176
+ }
177
+
178
+ return true;
179
+ }
180
+ }, {
181
+ key: "onUpdate",
182
+ value: function onUpdate(uri, d) {
183
+ return this.fetcher.refresh(DataFactory.namedNode(uri));
184
+ }
185
+ }, {
186
+ key: "register",
187
+ value: function register(via, uri) {
188
+ if (this.via[via] == null) {
189
+ this.via[via] = new UpdatesSocket(this, via);
190
+ }
191
+
192
+ return this.via[via].subscribe(uri);
193
+ }
194
+ }]);
195
+
196
+ return UpdatesVia;
197
+ }();
package/esm/uri.js ADDED
@@ -0,0 +1,245 @@
1
+ /*
2
+ * Implements URI-specific functions
3
+ *
4
+ * See RFC 2386
5
+ *
6
+ * See also:
7
+ * http://www.w3.org/2005/10/ajaw/uri.js
8
+ * http://www.w3.org/2000/10/swap/uripath.py
9
+ *
10
+ */
11
+ var alert = alert || console.log;
12
+ import RDFlibNamedNode from './named-node';
13
+ /**
14
+ * Gets the document part of an URI
15
+ * @param uri The URI
16
+ */
17
+
18
+ export function docpart(uri) {
19
+ var i;
20
+ i = uri.indexOf('#');
21
+
22
+ if (i < 0) {
23
+ return uri;
24
+ } else {
25
+ return uri.slice(0, i);
26
+ }
27
+ }
28
+ /**
29
+ * Gets the document part of an URI as a named node
30
+ * @param x - The URI
31
+ */
32
+
33
+ export function document(x) {
34
+ return new RDFlibNamedNode(docpart(x));
35
+ }
36
+ /**
37
+ * Gets the hostname in an URI
38
+ * @param u The URI
39
+ */
40
+
41
+ export function hostpart(u) {
42
+ var m = /[^\/]*\/\/([^\/]*)\//.exec(u);
43
+
44
+ if (m) {
45
+ return m[1];
46
+ } else {
47
+ return '';
48
+ }
49
+ }
50
+ /**
51
+ * Joins an URI with a base
52
+ * @param given - The relative part
53
+ * @param base - The base URI
54
+ */
55
+
56
+ export function join(given, base) {
57
+ var baseColon, baseScheme, baseSingle;
58
+ var colon, lastSlash, path;
59
+ var baseHash = base.indexOf('#');
60
+
61
+ if (baseHash > 0) {
62
+ base = base.slice(0, baseHash);
63
+ }
64
+
65
+ if (given.length === 0) {
66
+ return base;
67
+ }
68
+
69
+ if (given.indexOf('#') === 0) {
70
+ return base + given;
71
+ }
72
+
73
+ colon = given.indexOf(':');
74
+
75
+ if (colon >= 0) {
76
+ return given;
77
+ }
78
+
79
+ baseColon = base.indexOf(':');
80
+
81
+ if (base.length === 0) {
82
+ return given;
83
+ }
84
+
85
+ if (baseColon < 0) {
86
+ alert('Invalid base: ' + base + ' in join with given: ' + given);
87
+ return given;
88
+ }
89
+
90
+ baseScheme = base.slice(0, +baseColon + 1 || 9e9);
91
+
92
+ if (given.indexOf('//') === 0) {
93
+ return baseScheme + given;
94
+ }
95
+
96
+ if (base.indexOf('//', baseColon) === baseColon + 1) {
97
+ baseSingle = base.indexOf('/', baseColon + 3);
98
+
99
+ if (baseSingle < 0) {
100
+ if (base.length - baseColon - 3 > 0) {
101
+ return base + '/' + given;
102
+ } else {
103
+ return baseScheme + given;
104
+ }
105
+ }
106
+ } else {
107
+ baseSingle = base.indexOf('/', baseColon + 1);
108
+
109
+ if (baseSingle < 0) {
110
+ if (base.length - baseColon - 1 > 0) {
111
+ return base + '/' + given;
112
+ } else {
113
+ return baseScheme + given;
114
+ }
115
+ }
116
+ }
117
+
118
+ if (given.indexOf('/') === 0) {
119
+ return base.slice(0, baseSingle) + given;
120
+ }
121
+
122
+ path = base.slice(baseSingle);
123
+ lastSlash = path.lastIndexOf('/');
124
+
125
+ if (lastSlash < 0) {
126
+ return baseScheme + given;
127
+ }
128
+
129
+ if (lastSlash >= 0 && lastSlash < path.length - 1) {
130
+ path = path.slice(0, +lastSlash + 1 || 9e9);
131
+ }
132
+
133
+ path += given;
134
+
135
+ while (path.match(/[^\/]*\/\.\.\//)) {
136
+ path = path.replace(/[^\/]*\/\.\.\//, '');
137
+ }
138
+
139
+ path = path.replace(/\.\//g, '');
140
+ path = path.replace(/\/\.$/, '/');
141
+ return base.slice(0, baseSingle) + path;
142
+ }
143
+ /**
144
+ * Gets the protocol part of an URI
145
+ * @param uri The URI
146
+ */
147
+
148
+ export function protocol(uri) {
149
+ var i = uri.indexOf(':');
150
+
151
+ if (i < 0) {
152
+ return null;
153
+ } else {
154
+ return uri.slice(0, i);
155
+ }
156
+ }
157
+ /**
158
+ * Gets a relative uri
159
+ * @param base The base URI
160
+ * @param uri The absolute URI
161
+ */
162
+
163
+ export function refTo(base, uri) {
164
+ var c, i, k, l, len, len1, n, o, p, q, ref, ref1, s;
165
+ var commonHost = new RegExp('^[-_a-zA-Z0-9.]+:(//[^/]*)?/[^/]*$');
166
+
167
+ if (!base) {
168
+ return uri;
169
+ }
170
+
171
+ if (base === uri) {
172
+ return '';
173
+ }
174
+
175
+ for (i = o = 0, len = uri.length; o < len; i = ++o) {
176
+ var _c = uri[i];
177
+
178
+ if (_c !== base[i]) {
179
+ break;
180
+ }
181
+ }
182
+
183
+ if (base.slice(0, i).match(commonHost)) {
184
+ k = uri.indexOf('//');
185
+
186
+ if (k < 0) {
187
+ k = -2;
188
+ }
189
+
190
+ l = uri.indexOf('/', k + 2);
191
+
192
+ if (uri[l + 1] !== '/' && base[l + 1] !== '/' && uri.slice(0, l) === base.slice(0, l)) {
193
+ return uri.slice(l);
194
+ }
195
+ }
196
+
197
+ if (uri[i] === '#' && base.length === i) {
198
+ return uri.slice(i);
199
+ }
200
+
201
+ while (i > 0 && uri[i - 1] !== '/') {
202
+ i--;
203
+ }
204
+
205
+ if (i < 3) {
206
+ return uri;
207
+ }
208
+
209
+ if (base.indexOf('//', i - 2) > 0 || uri.indexOf('//', i - 2) > 0) {
210
+ return uri;
211
+ }
212
+
213
+ if (base.indexOf(':', i) > 0) {
214
+ return uri;
215
+ }
216
+
217
+ n = 0;
218
+ ref = base.slice(i);
219
+
220
+ for (p = 0, len1 = ref.length; p < len1; p++) {
221
+ c = ref[p];
222
+
223
+ if (c === '/') {
224
+ n++;
225
+ }
226
+ }
227
+
228
+ if (n === 0 && i < uri.length && uri[i] === '#') {
229
+ return './' + uri.slice(i);
230
+ }
231
+
232
+ if (n === 0 && i === uri.length) {
233
+ return './';
234
+ }
235
+
236
+ s = '';
237
+
238
+ if (n > 0) {
239
+ for (q = 1, ref1 = n; ref1 >= 1 ? q <= ref1 : q >= ref1; ref1 >= 1 ? ++q : --q) {
240
+ s += '../';
241
+ }
242
+ }
243
+
244
+ return s + uri.slice(i);
245
+ }
@@ -0,0 +1,4 @@
1
+ // Prevents circular dependencies between data-factory-internal and statement
2
+ import NamedNode from '../named-node';
3
+ export var defaultGraphURI = 'chrome:theSession';
4
+ export var defaultGraphNode = new NamedNode(defaultGraphURI);
@@ -0,0 +1,8 @@
1
+ /** Retrieve the value of a term, or self if already a string. */
2
+ export function termValue(node) {
3
+ if (typeof node === 'string') {
4
+ return node;
5
+ }
6
+
7
+ return node.value;
8
+ }
@@ -0,0 +1,72 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import { CollectionTermType, NamedNodeTermType, VariableTermType, BlankNodeTermType, LiteralTermType, GraphTermType, DefaultGraphTermType } from '../types';
3
+
4
+ /** TypeGuard for RDFLib Statements */
5
+ export function isStatement(obj) {
6
+ return _typeof(obj) === 'object' && obj !== null && 'subject' in obj;
7
+ }
8
+ /** TypeGuard for RDFlib Stores */
9
+
10
+ export function isStore(obj) {
11
+ return _typeof(obj) === 'object' && obj !== null && 'statements' in obj;
12
+ }
13
+ /** TypeGuard for RDFLib Collections */
14
+
15
+ export function isCollection(obj) {
16
+ return isTerm(obj) && obj.termType === CollectionTermType;
17
+ }
18
+ /** TypeGuard for valid RDFlib Object types, also allows Collections */
19
+
20
+ export function isRDFlibObject(obj) {
21
+ return obj && Object.prototype.hasOwnProperty.call(obj, 'termType') && (obj.termType === NamedNodeTermType || obj.termType === VariableTermType || obj.termType === BlankNodeTermType || obj.termType === CollectionTermType || obj.termType === LiteralTermType || obj.termType === GraphTermType);
22
+ }
23
+ /** TypeGuard for RDFLib Variables */
24
+
25
+ export function isVariable(obj) {
26
+ return isTerm(obj) && obj.termType === VariableTermType;
27
+ }
28
+ /** TypeGuard for RDF/JS spec Terms */
29
+
30
+ export function isTerm(obj) {
31
+ return _typeof(obj) === 'object' && obj !== null && 'termType' in obj;
32
+ }
33
+ /** TypeGuard for RDF/JS spec Literals */
34
+
35
+ export function isLiteral(value) {
36
+ return value.termType === LiteralTermType;
37
+ }
38
+ /** TypeGuard for RDF/JS spec Quads */
39
+
40
+ export function isQuad(obj) {
41
+ return _typeof(obj) === "object" && obj !== null && 'subject' in obj && 'predicate' in obj && 'object' in obj;
42
+ }
43
+ /** TypeGuard for RDF/JS spec NamedNodes */
44
+
45
+ export function isNamedNode(obj) {
46
+ return isTerm(obj) && obj.termType === 'NamedNode';
47
+ }
48
+ /** TypeGuard for RDF/JS spec BlankNodes */
49
+
50
+ export function isBlankNode(obj) {
51
+ return isTerm(obj) && 'termType' in obj && obj.termType === 'BlankNode';
52
+ }
53
+ /** TypeGuard for valid RDF/JS spec Subject types */
54
+
55
+ export function isSubject(obj) {
56
+ return isTerm(obj) && (obj.termType === NamedNodeTermType || obj.termType === VariableTermType || obj.termType === BlankNodeTermType);
57
+ }
58
+ /** TypeGuard for valid RDF/JS spec Predicate types */
59
+
60
+ export function isPredicate(obj) {
61
+ return isTerm(obj) && (obj.termType === NamedNodeTermType || obj.termType === VariableTermType);
62
+ }
63
+ /** TypeGuard for valid RDF/JS spec Object types */
64
+
65
+ export function isRDFObject(obj) {
66
+ return isTerm(obj) && (obj.termType === NamedNodeTermType || obj.termType === VariableTermType || obj.termType === BlankNodeTermType || obj.termType === LiteralTermType);
67
+ }
68
+ /** TypeGuard for valid RDF/JS Graph types */
69
+
70
+ export function isGraph(obj) {
71
+ return isTerm(obj) && (obj.termType === NamedNodeTermType || obj.termType === VariableTermType || obj.termType === BlankNodeTermType || obj.termType === DefaultGraphTermType);
72
+ }