rdflib 2.2.22 → 2.2.23-6384f9a2

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