rdflib 2.2.21 → 2.2.22-b51259b5

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 (106) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +9 -1
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +61 -114
  5. package/esm/class-order.js +1 -1
  6. package/esm/collection.js +70 -128
  7. package/esm/convert.js +1 -2
  8. package/esm/default-graph.js +14 -48
  9. package/esm/empty.js +8 -39
  10. package/esm/factories/canonical-data-factory.js +33 -65
  11. package/esm/factories/extended-term-factory.js +18 -25
  12. package/esm/factories/factory-types.js +3 -2
  13. package/esm/factories/rdflib-data-factory.js +9 -19
  14. package/esm/fetcher.js +1341 -1854
  15. package/esm/formula.js +639 -846
  16. package/esm/index.js +40 -76
  17. package/esm/jsonldparser.js +24 -49
  18. package/esm/jsonparser.js +1 -8
  19. package/esm/lists.js +47 -110
  20. package/esm/literal.js +120 -189
  21. package/esm/log.js +7 -7
  22. package/esm/n3parser.js +1015 -1412
  23. package/esm/named-node.js +70 -119
  24. package/esm/namespace.js +2 -5
  25. package/esm/node-internal.js +73 -110
  26. package/esm/node.js +2 -7
  27. package/esm/parse.js +12 -19
  28. package/esm/patch-parser.js +10 -30
  29. package/esm/query-to-sparql.js +0 -18
  30. package/esm/query.js +63 -147
  31. package/esm/rdfaparser.js +794 -997
  32. package/esm/rdfxmlparser.js +347 -461
  33. package/esm/serialize.js +9 -27
  34. package/esm/serializer.js +820 -1049
  35. package/esm/sparql-to-query.js +44 -134
  36. package/esm/statement.js +54 -85
  37. package/esm/store.js +830 -1103
  38. package/esm/types.js +22 -21
  39. package/esm/update-manager.js +869 -1106
  40. package/esm/updates-via.js +104 -161
  41. package/esm/uri.js +9 -53
  42. package/esm/utils/default-graph-uri.js +3 -2
  43. package/esm/utils/termValue.js +0 -1
  44. package/esm/utils/terms.js +19 -21
  45. package/esm/utils-js.js +20 -61
  46. package/esm/utils.js +10 -21
  47. package/esm/variable.js +32 -78
  48. package/esm/xsd.js +2 -2
  49. package/lib/blank-node.js +60 -113
  50. package/lib/class-order.js +1 -2
  51. package/lib/collection.js +69 -131
  52. package/lib/convert.js +3 -9
  53. package/lib/default-graph.js +13 -52
  54. package/lib/empty.js +8 -43
  55. package/lib/factories/canonical-data-factory.js +35 -79
  56. package/lib/factories/extended-term-factory.js +18 -32
  57. package/lib/factories/factory-types.d.ts +6 -6
  58. package/lib/factories/factory-types.js +1 -4
  59. package/lib/factories/rdflib-data-factory.js +9 -23
  60. package/lib/fetcher.d.ts +6 -6
  61. package/lib/fetcher.js +1370 -1843
  62. package/lib/formula.js +640 -855
  63. package/lib/index.js +66 -152
  64. package/lib/jsonldparser.js +23 -53
  65. package/lib/jsonparser.js +1 -10
  66. package/lib/lists.js +55 -112
  67. package/lib/literal.js +120 -195
  68. package/lib/log.d.ts +0 -6
  69. package/lib/log.js +7 -8
  70. package/lib/n3parser.js +1030 -1436
  71. package/lib/named-node.js +69 -126
  72. package/lib/namespace.js +2 -7
  73. package/lib/node-internal.js +74 -107
  74. package/lib/node.js +2 -12
  75. package/lib/parse.d.ts +1 -1
  76. package/lib/parse.js +12 -32
  77. package/lib/patch-parser.js +11 -34
  78. package/lib/query-to-sparql.js +0 -23
  79. package/lib/query.js +62 -167
  80. package/lib/rdfaparser.js +796 -1009
  81. package/lib/rdfxmlparser.js +349 -466
  82. package/lib/serialize.js +11 -37
  83. package/lib/serializer.js +823 -1064
  84. package/lib/sparql-to-query.js +42 -167
  85. package/lib/statement.js +55 -91
  86. package/lib/store.d.ts +1 -1
  87. package/lib/store.js +850 -1112
  88. package/lib/tf-types.d.ts +4 -4
  89. package/lib/types.d.ts +8 -8
  90. package/lib/types.js +23 -23
  91. package/lib/update-manager.d.ts +1 -1
  92. package/lib/update-manager.js +865 -1103
  93. package/lib/updates-via.js +105 -164
  94. package/lib/uri.js +8 -61
  95. package/lib/utils/default-graph-uri.js +3 -5
  96. package/lib/utils/termValue.js +0 -2
  97. package/lib/utils/terms.js +19 -40
  98. package/lib/utils-js.js +23 -88
  99. package/lib/utils.js +10 -27
  100. package/lib/variable.js +34 -85
  101. package/lib/xsd-internal.js +0 -3
  102. package/lib/xsd.js +2 -6
  103. package/package.json +35 -35
  104. package/src/fetcher.ts +2 -2
  105. package/src/update-manager.ts +12 -7
  106. package/changes.txt +0 -59
package/esm/literal.js CHANGED
@@ -1,32 +1,15 @@
1
- import _typeof from "@babel/runtime/helpers/typeof";
2
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
- import _createClass from "@babel/runtime/helpers/createClass";
4
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
- import _inherits from "@babel/runtime/helpers/inherits";
6
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
-
10
- 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); }; }
11
-
12
- 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; } }
13
-
14
2
  import ClassOrder from './class-order';
15
3
  import RDFlibNamedNode from './named-node';
16
4
  import Node from './node-internal';
17
5
  import { LiteralTermType } from './types';
18
6
  import { isLiteral } from './utils/terms';
19
7
  import XSD from './xsd-internal';
20
-
21
8
  /**
22
9
  * An RDF literal, containing some value which isn't expressed as an IRI.
23
10
  * @link https://rdf.js.org/data-model-spec/#literal-interface
24
11
  */
25
- var Literal = /*#__PURE__*/function (_Node) {
26
- _inherits(Literal, _Node);
27
-
28
- var _super = _createSuper(Literal);
29
-
12
+ export default class Literal extends Node {
30
13
  /**
31
14
  * The literal's datatype as a named node
32
15
  */
@@ -41,196 +24,144 @@ var Literal = /*#__PURE__*/function (_Node) {
41
24
  * @param language - The language for the literal. Defaults to ''.
42
25
  * @param datatype - The literal's datatype as a named node. Defaults to xsd:string.
43
26
  */
44
- function Literal(value, language, datatype) {
45
- var _this;
46
-
47
- _classCallCheck(this, Literal);
48
-
49
- _this = _super.call(this, value);
50
-
51
- _defineProperty(_assertThisInitialized(_this), "termType", LiteralTermType);
52
-
53
- _defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Literal);
54
-
55
- _defineProperty(_assertThisInitialized(_this), "datatype", XSD.string);
56
-
57
- _defineProperty(_assertThisInitialized(_this), "isVar", 0);
58
-
59
- _defineProperty(_assertThisInitialized(_this), "language", '');
60
-
27
+ constructor(value, language, datatype) {
28
+ super(value);
29
+ _defineProperty(this, "termType", LiteralTermType);
30
+ _defineProperty(this, "classOrder", ClassOrder.Literal);
31
+ _defineProperty(this, "datatype", XSD.string);
32
+ _defineProperty(this, "isVar", 0);
33
+ _defineProperty(this, "language", '');
61
34
  if (language) {
62
- _this.language = language;
63
- _this.datatype = XSD.langString;
35
+ this.language = language;
36
+ this.datatype = XSD.langString;
64
37
  } else if (datatype) {
65
- _this.datatype = RDFlibNamedNode.fromValue(datatype);
38
+ this.datatype = RDFlibNamedNode.fromValue(datatype);
66
39
  } else {
67
- _this.datatype = XSD.string;
40
+ this.datatype = XSD.string;
68
41
  }
69
-
70
- return _this;
71
42
  }
43
+
72
44
  /**
73
45
  * Gets a copy of this literal
74
46
  */
47
+ copy() {
48
+ return new Literal(this.value, this.lang, this.datatype);
49
+ }
75
50
 
76
-
77
- _createClass(Literal, [{
78
- key: "copy",
79
- value: function copy() {
80
- return new Literal(this.value, this.lang, this.datatype);
51
+ /**
52
+ * Gets whether two literals are the same
53
+ * @param other The other statement
54
+ */
55
+ equals(other) {
56
+ if (!other) {
57
+ return false;
81
58
  }
82
- /**
83
- * Gets whether two literals are the same
84
- * @param other The other statement
85
- */
86
-
87
- }, {
88
- key: "equals",
89
- value: function equals(other) {
90
- if (!other) {
91
- return false;
92
- }
59
+ return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
60
+ }
93
61
 
94
- return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
95
- }
96
- /**
97
- * The language for the literal
98
- * @deprecated use {language} instead
99
- */
62
+ /**
63
+ * The language for the literal
64
+ * @deprecated use {language} instead
65
+ */
66
+ get lang() {
67
+ return this.language;
68
+ }
69
+ set lang(language) {
70
+ this.language = language || '';
71
+ }
72
+ toNT() {
73
+ return Literal.toNT(this);
74
+ }
100
75
 
101
- }, {
102
- key: "lang",
103
- get: function get() {
104
- return this.language;
105
- },
106
- set: function set(language) {
107
- this.language = language || '';
108
- }
109
- }, {
110
- key: "toNT",
111
- value: function toNT() {
112
- return Literal.toNT(this);
76
+ /** Serializes a literal to an N-Triples string */
77
+ static toNT(literal) {
78
+ if (typeof literal.value === 'number') {
79
+ return '' + literal.value;
80
+ } else if (typeof literal.value !== 'string') {
81
+ throw new Error('Value of RDF literal is not string or number: ' + literal.value);
113
82
  }
114
- /** Serializes a literal to an N-Triples string */
115
-
116
- }, {
117
- key: "toString",
118
- value: function toString() {
119
- return '' + this.value;
83
+ var str = literal.value;
84
+ // #x22 ("), #x5C (\), #x0A (\n) and #xD (\r) are disallowed and need to be replaced
85
+ // see https://www.w3.org/TR/n-triples/#grammar-production-STRING_LITERAL_QUOTE
86
+ str = str.replace(/\\/g, '\\\\');
87
+ str = str.replace(/\"/g, '\\"');
88
+ str = str.replace(/\n/g, '\\n');
89
+ str = str.replace(/\r/g, '\\r');
90
+ str = '"' + str + '"';
91
+ if (literal.language) {
92
+ str += '@' + literal.language;
93
+ } else if (!literal.datatype.equals(XSD.string)) {
94
+ // Only add datatype if it's not a string
95
+ str += '^^' + literal.datatype.toCanonical();
120
96
  }
121
- /**
122
- * Builds a literal node from a boolean value
123
- * @param value - The value
124
- */
125
-
126
- }], [{
127
- key: "toNT",
128
- value: function toNT(literal) {
129
- if (typeof literal.value === 'number') {
130
- return '' + literal.value;
131
- } else if (typeof literal.value !== 'string') {
132
- throw new Error('Value of RDF literal is not string or number: ' + literal.value);
133
- }
134
-
135
- var str = literal.value; // #x22 ("), #x5C (\), #x0A (\n) and #xD (\r) are disallowed and need to be replaced
136
- // see https://www.w3.org/TR/n-triples/#grammar-production-STRING_LITERAL_QUOTE
137
-
138
- str = str.replace(/\\/g, '\\\\');
139
- str = str.replace(/\"/g, '\\"');
140
- str = str.replace(/\n/g, '\\n');
141
- str = str.replace(/\r/g, '\\r');
142
- str = '"' + str + '"';
97
+ return str;
98
+ }
99
+ toString() {
100
+ return '' + this.value;
101
+ }
143
102
 
144
- if (literal.language) {
145
- str += '@' + literal.language;
146
- } else if (!literal.datatype.equals(XSD.string)) {
147
- // Only add datatype if it's not a string
148
- str += '^^' + literal.datatype.toCanonical();
149
- }
103
+ /**
104
+ * Builds a literal node from a boolean value
105
+ * @param value - The value
106
+ */
107
+ static fromBoolean(value) {
108
+ let strValue = value ? '1' : '0';
109
+ return new Literal(strValue, null, XSD.boolean);
110
+ }
150
111
 
151
- return str;
152
- }
153
- }, {
154
- key: "fromBoolean",
155
- value: function fromBoolean(value) {
156
- var strValue = value ? '1' : '0';
157
- return new Literal(strValue, null, XSD.boolean);
112
+ /**
113
+ * Builds a literal node from a date value
114
+ * @param value The value
115
+ */
116
+ static fromDate(value) {
117
+ if (!(value instanceof Date)) {
118
+ throw new TypeError('Invalid argument to Literal.fromDate()');
158
119
  }
159
- /**
160
- * Builds a literal node from a date value
161
- * @param value The value
162
- */
163
-
164
- }, {
165
- key: "fromDate",
166
- value: function fromDate(value) {
167
- if (!(value instanceof Date)) {
168
- throw new TypeError('Invalid argument to Literal.fromDate()');
169
- }
170
-
171
- var d2 = function d2(x) {
172
- return ('' + (100 + x)).slice(1, 3);
173
- };
120
+ let d2 = function (x) {
121
+ return ('' + (100 + x)).slice(1, 3);
122
+ };
123
+ let date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
124
+ return new Literal(date, null, XSD.dateTime);
125
+ }
174
126
 
175
- var date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
176
- return new Literal(date, null, XSD.dateTime);
127
+ /**
128
+ * Builds a literal node from a number value
129
+ * @param value - The value
130
+ */
131
+ static fromNumber(value) {
132
+ if (typeof value !== 'number') {
133
+ throw new TypeError('Invalid argument to Literal.fromNumber()');
177
134
  }
178
- /**
179
- * Builds a literal node from a number value
180
- * @param value - The value
181
- */
182
-
183
- }, {
184
- key: "fromNumber",
185
- value: function fromNumber(value) {
186
- if (typeof value !== 'number') {
187
- throw new TypeError('Invalid argument to Literal.fromNumber()');
188
- }
189
-
190
- var datatype;
191
- var strValue = value.toString();
192
-
193
- if (strValue.indexOf('e') < 0 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
194
- datatype = Number.isInteger(value) ? XSD.integer : XSD.decimal;
195
- } else {
196
- datatype = XSD.double;
197
- }
198
-
199
- return new Literal(strValue, null, datatype);
135
+ let datatype;
136
+ const strValue = value.toString();
137
+ if (strValue.indexOf('e') < 0 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
138
+ datatype = Number.isInteger(value) ? XSD.integer : XSD.decimal;
139
+ } else {
140
+ datatype = XSD.double;
200
141
  }
201
- /**
202
- * Builds a literal node from an input value
203
- * @param value - The input value
204
- */
205
-
206
- }, {
207
- key: "fromValue",
208
- value: function fromValue(value) {
209
- if (isLiteral(value)) {
210
- return value;
211
- }
212
-
213
- switch (_typeof(value)) {
214
- case 'object':
215
- if (value instanceof Date) {
216
- return Literal.fromDate(value);
217
- }
218
-
219
- case 'boolean':
220
- return Literal.fromBoolean(value);
221
-
222
- case 'number':
223
- return Literal.fromNumber(value);
224
-
225
- case 'string':
226
- return new Literal(value);
227
- }
142
+ return new Literal(strValue, null, datatype);
143
+ }
228
144
 
229
- throw new Error("Can't make literal from " + value + ' of type ' + _typeof(value));
145
+ /**
146
+ * Builds a literal node from an input value
147
+ * @param value - The input value
148
+ */
149
+ static fromValue(value) {
150
+ if (isLiteral(value)) {
151
+ return value;
230
152
  }
231
- }]);
232
-
233
- return Literal;
234
- }(Node);
235
-
236
- export { Literal as default };
153
+ switch (typeof value) {
154
+ case 'object':
155
+ if (value instanceof Date) {
156
+ return Literal.fromDate(value);
157
+ }
158
+ case 'boolean':
159
+ return Literal.fromBoolean(value);
160
+ case 'number':
161
+ return Literal.fromNumber(value);
162
+ case 'string':
163
+ return new Literal(value);
164
+ }
165
+ throw new Error("Can't make literal from " + value + ' of type ' + typeof value);
166
+ }
167
+ }
package/esm/log.js CHANGED
@@ -2,12 +2,12 @@
2
2
  * A Dummy log
3
3
  * @module log
4
4
  */
5
- var log = {
6
- debug: function debug(x) {},
7
- warn: function warn(x) {},
8
- info: function info(x) {},
9
- error: function error(x) {},
10
- success: function success(x) {},
11
- msg: function msg(x) {}
5
+ const log = {
6
+ debug(x) {},
7
+ warn(x) {},
8
+ info(x) {},
9
+ error(x) {},
10
+ success(x) {},
11
+ msg(x) {}
12
12
  };
13
13
  export default log;