rdflib 2.2.22-2f49e8ef → 2.2.22-53d65d90
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.
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +4 -0
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +90 -61
- package/esm/class-order.js +1 -1
- package/esm/collection.js +106 -70
- package/esm/default-graph.js +33 -13
- package/esm/empty.js +26 -8
- package/esm/factories/canonical-data-factory.js +30 -33
- package/esm/factories/extended-term-factory.js +14 -18
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +11 -9
- package/esm/fetcher.js +1644 -1355
- package/esm/formula.js +740 -632
- package/esm/index.js +52 -33
- package/esm/jsonldparser.js +35 -19
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +86 -38
- package/esm/literal.js +157 -120
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1085 -1008
- package/esm/named-node.js +99 -69
- package/esm/namespace.js +4 -2
- package/esm/node-internal.js +98 -74
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +16 -15
- package/esm/rdfaparser.js +846 -781
- package/esm/rdfxmlparser.js +365 -348
- package/esm/serialize.js +4 -11
- package/esm/serializer.js +886 -821
- package/esm/statement.js +72 -52
- package/esm/store.js +924 -822
- package/esm/types.js +21 -21
- package/esm/update-manager.js +983 -882
- package/esm/updates-via.js +134 -104
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +5 -4
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +58 -32
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +88 -60
- package/lib/class-order.js +1 -1
- package/lib/collection.js +104 -69
- package/lib/default-graph.js +32 -13
- package/lib/empty.js +25 -8
- package/lib/factories/canonical-data-factory.js +32 -35
- package/lib/factories/extended-term-factory.js +14 -18
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +11 -9
- package/lib/fetcher.js +1646 -1385
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +739 -632
- package/lib/index.d.ts +1 -2
- package/lib/index.js +88 -70
- package/lib/jsonldparser.js +35 -19
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +86 -54
- package/lib/literal.js +156 -120
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1089 -1010
- package/lib/named-node.js +98 -69
- package/lib/namespace.js +4 -2
- package/lib/node-internal.js +96 -73
- package/lib/node.js +1 -1
- package/lib/parse.js +6 -5
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +18 -19
- package/lib/rdfaparser.js +848 -783
- package/lib/rdfxmlparser.js +366 -350
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +4 -13
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +890 -825
- package/lib/statement.js +74 -54
- package/lib/store.d.ts +1 -1
- package/lib/store.js +926 -844
- package/lib/types.js +21 -21
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +959 -865
- package/lib/updates-via.js +134 -105
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +6 -4
- package/lib/utils-js.js +9 -8
- package/lib/utils.js +6 -6
- package/lib/variable.js +60 -34
- package/lib/xsd.js +2 -2
- package/package.json +9 -8
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/serialize.ts +4 -11
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +8 -2
- package/esm/convert.js +0 -60
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -71
- 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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_defineProperty(
|
|
32
|
-
_defineProperty(
|
|
33
|
-
_defineProperty(
|
|
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
|
-
|
|
36
|
-
|
|
48
|
+
_this.language = language;
|
|
49
|
+
_this.datatype = XSD.langString;
|
|
37
50
|
} else if (datatype) {
|
|
38
|
-
|
|
51
|
+
_this.datatype = RDFlibNamedNode.fromValue(datatype);
|
|
39
52
|
} else {
|
|
40
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|