rdflib 2.2.34 → 2.2.35-0ebb696c

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