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.
Files changed (90) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +0 -2
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +57 -82
  5. package/esm/class-order.js +1 -1
  6. package/esm/collection.js +70 -103
  7. package/esm/default-graph.js +13 -30
  8. package/esm/empty.js +8 -23
  9. package/esm/factories/canonical-data-factory.js +33 -29
  10. package/esm/factories/extended-term-factory.js +18 -13
  11. package/esm/factories/factory-types.js +1 -1
  12. package/esm/factories/rdflib-data-factory.js +9 -11
  13. package/esm/fetcher.js +1366 -1651
  14. package/esm/formula.js +631 -736
  15. package/esm/index.js +31 -48
  16. package/esm/jsonldparser.js +19 -26
  17. package/esm/jsonparser.js +1 -1
  18. package/esm/lists.js +38 -86
  19. package/esm/literal.js +120 -154
  20. package/esm/log.js +7 -7
  21. package/esm/n3parser.js +1009 -1086
  22. package/esm/named-node.js +69 -96
  23. package/esm/namespace.js +2 -4
  24. package/esm/node-internal.js +73 -96
  25. package/esm/node.js +1 -1
  26. package/esm/parse.js +3 -3
  27. package/esm/patch-parser.js +1 -1
  28. package/esm/query.js +15 -16
  29. package/esm/rdfaparser.js +775 -841
  30. package/esm/rdfxmlparser.js +348 -364
  31. package/esm/serialize.js +2 -2
  32. package/esm/serializer.js +835 -877
  33. package/esm/statement.js +52 -71
  34. package/esm/store.js +853 -957
  35. package/esm/types.js +21 -21
  36. package/esm/update-manager.js +965 -1100
  37. package/esm/updates-via.js +104 -132
  38. package/esm/uri.js +3 -3
  39. package/esm/utils/default-graph-uri.js +2 -2
  40. package/esm/utils/terms.js +4 -5
  41. package/esm/utils-js.js +5 -5
  42. package/esm/utils.js +6 -6
  43. package/esm/variable.js +32 -55
  44. package/esm/xsd.js +2 -2
  45. package/lib/blank-node.js +57 -80
  46. package/lib/class-order.js +1 -1
  47. package/lib/collection.js +70 -101
  48. package/lib/default-graph.js +14 -29
  49. package/lib/empty.js +9 -22
  50. package/lib/factories/canonical-data-factory.js +35 -31
  51. package/lib/factories/extended-term-factory.js +18 -13
  52. package/lib/factories/factory-types.js +1 -1
  53. package/lib/factories/rdflib-data-factory.js +9 -11
  54. package/lib/fetcher.js +1375 -1654
  55. package/lib/formula.js +632 -735
  56. package/lib/index.js +80 -84
  57. package/lib/jsonldparser.js +21 -32
  58. package/lib/jsonparser.js +1 -1
  59. package/lib/lists.js +47 -87
  60. package/lib/literal.js +121 -153
  61. package/lib/log.js +7 -7
  62. package/lib/n3parser.js +1012 -1090
  63. package/lib/named-node.js +70 -95
  64. package/lib/namespace.js +2 -4
  65. package/lib/node-internal.js +73 -94
  66. package/lib/node.js +1 -1
  67. package/lib/parse.js +5 -6
  68. package/lib/patch-parser.js +1 -1
  69. package/lib/query.js +20 -18
  70. package/lib/rdfaparser.js +778 -843
  71. package/lib/rdfxmlparser.js +351 -365
  72. package/lib/serialize.js +2 -2
  73. package/lib/serializer.js +840 -880
  74. package/lib/statement.js +55 -73
  75. package/lib/store.js +860 -958
  76. package/lib/types.js +21 -21
  77. package/lib/update-manager.js +970 -1102
  78. package/lib/updates-via.js +107 -132
  79. package/lib/uri.js +3 -3
  80. package/lib/utils/default-graph-uri.js +2 -2
  81. package/lib/utils/terms.js +4 -6
  82. package/lib/utils-js.js +8 -9
  83. package/lib/utils.js +6 -6
  84. package/lib/variable.js +35 -57
  85. package/lib/xsd.js +2 -2
  86. package/package.json +2 -2
  87. package/src/n3parser.js +1 -1
  88. package/src/serializer.js +1 -1
  89. package/src/update-manager.ts +2 -1
  90. package/.babelrc +0 -20
package/esm/literal.js CHANGED
@@ -1,12 +1,4 @@
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 _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
2
  import ClassOrder from './class-order';
11
3
  import RDFlibNamedNode from './named-node';
12
4
  import Node from './node-internal';
@@ -17,183 +9,157 @@ import XSD from './xsd-internal';
17
9
  * An RDF literal, containing some value which isn't expressed as an IRI.
18
10
  * @link https://rdf.js.org/data-model-spec/#literal-interface
19
11
  */
20
- var Literal = /*#__PURE__*/function (_Node) {
12
+ export default class Literal extends Node {
21
13
  /**
22
14
  * Initializes a literal
23
15
  * @param value - The literal's lexical value
24
16
  * @param language - The language for the literal. Defaults to ''.
25
17
  * @param datatype - The literal's datatype as a named node. Defaults to xsd:string.
26
18
  */
27
- function Literal(value, language, datatype) {
28
- var _this;
29
- _classCallCheck(this, Literal);
30
- _this = _callSuper(this, Literal, [value]);
31
- _defineProperty(_this, "termType", LiteralTermType);
32
- _defineProperty(_this, "classOrder", ClassOrder.Literal);
19
+ constructor(value, language, datatype) {
20
+ super(value);
21
+ _defineProperty(this, "termType", LiteralTermType);
22
+ _defineProperty(this, "classOrder", ClassOrder.Literal);
33
23
  /**
34
24
  * The literal's datatype as a named node
35
25
  */
36
- _defineProperty(_this, "datatype", XSD.string);
37
- _defineProperty(_this, "isVar", 0);
26
+ _defineProperty(this, "datatype", XSD.string);
27
+ _defineProperty(this, "isVar", 0);
38
28
  /**
39
29
  * The language for the literal
40
30
  */
41
- _defineProperty(_this, "language", '');
31
+ _defineProperty(this, "language", '');
42
32
  if (language) {
43
- _this.language = language;
44
- _this.datatype = XSD.langString;
33
+ this.language = language;
34
+ this.datatype = XSD.langString;
45
35
  } else if (datatype) {
46
- _this.datatype = RDFlibNamedNode.fromValue(datatype);
36
+ this.datatype = RDFlibNamedNode.fromValue(datatype);
47
37
  } else {
48
- _this.datatype = XSD.string;
38
+ this.datatype = XSD.string;
49
39
  }
50
- return _this;
51
40
  }
52
41
 
53
42
  /**
54
43
  * Gets a copy of this literal
55
44
  */
56
- _inherits(Literal, _Node);
57
- return _createClass(Literal, [{
58
- key: "copy",
59
- value: function copy() {
60
- return new Literal(this.value, this.lang, this.datatype);
61
- }
45
+ copy() {
46
+ return new Literal(this.value, this.lang, this.datatype);
47
+ }
62
48
 
63
- /**
64
- * Gets whether two literals are the same
65
- * @param other The other statement
66
- */
67
- }, {
68
- key: "equals",
69
- value: function equals(other) {
70
- if (!other) {
71
- return false;
72
- }
73
- return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
49
+ /**
50
+ * Gets whether two literals are the same
51
+ * @param other The other statement
52
+ */
53
+ equals(other) {
54
+ if (!other) {
55
+ return false;
74
56
  }
57
+ return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
58
+ }
75
59
 
76
- /**
77
- * The language for the literal
78
- * @deprecated use {language} instead
79
- */
80
- }, {
81
- key: "lang",
82
- get: function get() {
83
- return this.language;
84
- },
85
- set: function set(language) {
86
- this.language = language || '';
60
+ /**
61
+ * The language for the literal
62
+ * @deprecated use {language} instead
63
+ */
64
+ get lang() {
65
+ return this.language;
66
+ }
67
+ set lang(language) {
68
+ this.language = language || '';
69
+ }
70
+ toNT() {
71
+ return Literal.toNT(this);
72
+ }
73
+
74
+ /** Serializes a literal to an N-Triples string */
75
+ static toNT(literal) {
76
+ if (typeof literal.value === 'number') {
77
+ return '' + literal.value;
78
+ } else if (typeof literal.value !== 'string') {
79
+ throw new Error('Value of RDF literal is not string or number: ' + literal.value);
87
80
  }
88
- }, {
89
- key: "toNT",
90
- value: function toNT() {
91
- return Literal.toNT(this);
81
+ var str = literal.value;
82
+ // #x22 ("), #x5C (\), #x0A (\n) and #xD (\r) are disallowed and need to be replaced
83
+ // see https://www.w3.org/TR/n-triples/#grammar-production-STRING_LITERAL_QUOTE
84
+ str = str.replace(/\\/g, '\\\\');
85
+ str = str.replace(/\"/g, '\\"');
86
+ str = str.replace(/\n/g, '\\n');
87
+ str = str.replace(/\r/g, '\\r');
88
+ str = '"' + str + '"';
89
+ if (literal.language) {
90
+ str += '@' + literal.language;
91
+ } else if (!literal.datatype.equals(XSD.string)) {
92
+ // Only add datatype if it's not a string
93
+ str += '^^' + literal.datatype.toCanonical();
92
94
  }
95
+ return str;
96
+ }
97
+ toString() {
98
+ return '' + this.value;
99
+ }
93
100
 
94
- /** Serializes a literal to an N-Triples string */
95
- }, {
96
- key: "toString",
97
- value: function toString() {
98
- return '' + this.value;
99
- }
101
+ /**
102
+ * Builds a literal node from a boolean value
103
+ * @param value - The value
104
+ */
105
+ static fromBoolean(value) {
106
+ let strValue = value ? '1' : '0';
107
+ return new Literal(strValue, null, XSD.boolean);
108
+ }
100
109
 
101
- /**
102
- * Builds a literal node from a boolean value
103
- * @param value - The value
104
- */
105
- }], [{
106
- key: "toNT",
107
- value: function toNT(literal) {
108
- if (typeof literal.value === 'number') {
109
- return '' + literal.value;
110
- } else if (typeof literal.value !== 'string') {
111
- throw new Error('Value of RDF literal is not string or number: ' + literal.value);
112
- }
113
- var str = literal.value;
114
- // #x22 ("), #x5C (\), #x0A (\n) and #xD (\r) are disallowed and need to be replaced
115
- // see https://www.w3.org/TR/n-triples/#grammar-production-STRING_LITERAL_QUOTE
116
- str = str.replace(/\\/g, '\\\\');
117
- str = str.replace(/\"/g, '\\"');
118
- str = str.replace(/\n/g, '\\n');
119
- str = str.replace(/\r/g, '\\r');
120
- str = '"' + str + '"';
121
- if (literal.language) {
122
- str += '@' + literal.language;
123
- } else if (!literal.datatype.equals(XSD.string)) {
124
- // Only add datatype if it's not a string
125
- str += '^^' + literal.datatype.toCanonical();
126
- }
127
- return str;
128
- }
129
- }, {
130
- key: "fromBoolean",
131
- value: function fromBoolean(value) {
132
- var strValue = value ? '1' : '0';
133
- return new Literal(strValue, null, XSD.boolean);
110
+ /**
111
+ * Builds a literal node from a date value
112
+ * @param value The value
113
+ */
114
+ static fromDate(value) {
115
+ if (!(value instanceof Date)) {
116
+ throw new TypeError('Invalid argument to Literal.fromDate()');
134
117
  }
118
+ let d2 = function (x) {
119
+ return ('' + (100 + x)).slice(1, 3);
120
+ };
121
+ let date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
122
+ return new Literal(date, null, XSD.dateTime);
123
+ }
135
124
 
136
- /**
137
- * Builds a literal node from a date value
138
- * @param value The value
139
- */
140
- }, {
141
- key: "fromDate",
142
- value: function fromDate(value) {
143
- if (!(value instanceof Date)) {
144
- throw new TypeError('Invalid argument to Literal.fromDate()');
145
- }
146
- var d2 = function d2(x) {
147
- return ('' + (100 + x)).slice(1, 3);
148
- };
149
- var date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
150
- return new Literal(date, null, XSD.dateTime);
125
+ /**
126
+ * Builds a literal node from a number value
127
+ * @param value - The value
128
+ */
129
+ static fromNumber(value) {
130
+ if (typeof value !== 'number') {
131
+ throw new TypeError('Invalid argument to Literal.fromNumber()');
151
132
  }
152
-
153
- /**
154
- * Builds a literal node from a number value
155
- * @param value - The value
156
- */
157
- }, {
158
- key: "fromNumber",
159
- value: function fromNumber(value) {
160
- if (typeof value !== 'number') {
161
- throw new TypeError('Invalid argument to Literal.fromNumber()');
162
- }
163
- var datatype;
164
- var strValue = value.toString();
165
- if (strValue.indexOf('e') < 0 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
166
- datatype = Number.isInteger(value) ? XSD.integer : XSD.decimal;
167
- } else {
168
- datatype = XSD.double;
169
- }
170
- return new Literal(strValue, null, datatype);
133
+ let datatype;
134
+ const strValue = value.toString();
135
+ if (strValue.indexOf('e') < 0 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
136
+ datatype = Number.isInteger(value) ? XSD.integer : XSD.decimal;
137
+ } else {
138
+ datatype = XSD.double;
171
139
  }
140
+ return new Literal(strValue, null, datatype);
141
+ }
172
142
 
173
- /**
174
- * Builds a literal node from an input value
175
- * @param value - The input value
176
- */
177
- }, {
178
- key: "fromValue",
179
- value: function fromValue(value) {
180
- if (isLiteral(value)) {
181
- return value;
182
- }
183
- switch (_typeof(value)) {
184
- case 'object':
185
- if (value instanceof Date) {
186
- return Literal.fromDate(value);
187
- }
188
- case 'boolean':
189
- return Literal.fromBoolean(value);
190
- case 'number':
191
- return Literal.fromNumber(value);
192
- case 'string':
193
- return new Literal(value);
194
- }
195
- throw new Error("Can't make literal from " + value + ' of type ' + _typeof(value));
143
+ /**
144
+ * Builds a literal node from an input value
145
+ * @param value - The input value
146
+ */
147
+ static fromValue(value) {
148
+ if (isLiteral(value)) {
149
+ return value;
196
150
  }
197
- }]);
198
- }(Node);
199
- export { Literal as default };
151
+ switch (typeof value) {
152
+ case 'object':
153
+ if (value instanceof Date) {
154
+ return Literal.fromDate(value);
155
+ }
156
+ case 'boolean':
157
+ return Literal.fromBoolean(value);
158
+ case 'number':
159
+ return Literal.fromNumber(value);
160
+ case 'string':
161
+ return new Literal(value);
162
+ }
163
+ throw new Error("Can't make literal from " + value + ' of type ' + typeof value);
164
+ }
165
+ }
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;