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.
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -2
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +57 -82
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -103
- package/esm/default-graph.js +13 -30
- package/esm/empty.js +8 -23
- package/esm/factories/canonical-data-factory.js +33 -29
- package/esm/factories/extended-term-factory.js +18 -13
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1366 -1651
- package/esm/formula.js +631 -736
- package/esm/index.js +31 -48
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +38 -86
- package/esm/literal.js +120 -154
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1009 -1086
- package/esm/named-node.js +69 -96
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -96
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +15 -16
- package/esm/rdfaparser.js +775 -841
- package/esm/rdfxmlparser.js +348 -364
- package/esm/serialize.js +2 -2
- package/esm/serializer.js +835 -877
- package/esm/statement.js +52 -71
- package/esm/store.js +853 -957
- package/esm/types.js +21 -21
- package/esm/update-manager.js +965 -1100
- package/esm/updates-via.js +104 -132
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +4 -5
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +32 -55
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +57 -80
- package/lib/class-order.js +1 -1
- package/lib/collection.js +70 -101
- package/lib/default-graph.js +14 -29
- package/lib/empty.js +9 -22
- package/lib/factories/canonical-data-factory.js +35 -31
- package/lib/factories/extended-term-factory.js +18 -13
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +9 -11
- package/lib/fetcher.js +1375 -1654
- package/lib/formula.js +632 -735
- package/lib/index.js +80 -84
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +47 -87
- package/lib/literal.js +121 -153
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1012 -1090
- package/lib/named-node.js +70 -95
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +73 -94
- package/lib/node.js +1 -1
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +20 -18
- package/lib/rdfaparser.js +778 -843
- package/lib/rdfxmlparser.js +351 -365
- package/lib/serialize.js +2 -2
- package/lib/serializer.js +840 -880
- package/lib/statement.js +55 -73
- package/lib/store.js +860 -958
- package/lib/types.js +21 -21
- package/lib/update-manager.js +970 -1102
- package/lib/updates-via.js +107 -132
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +8 -9
- package/lib/utils.js +6 -6
- package/lib/variable.js +35 -57
- package/lib/xsd.js +2 -2
- package/package.json +2 -2
- package/src/n3parser.js +1 -1
- package/src/serializer.js +1 -1
- package/src/update-manager.ts +2 -1
- 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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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(
|
|
37
|
-
_defineProperty(
|
|
26
|
+
_defineProperty(this, "datatype", XSD.string);
|
|
27
|
+
_defineProperty(this, "isVar", 0);
|
|
38
28
|
/**
|
|
39
29
|
* The language for the literal
|
|
40
30
|
*/
|
|
41
|
-
_defineProperty(
|
|
31
|
+
_defineProperty(this, "language", '');
|
|
42
32
|
if (language) {
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
this.language = language;
|
|
34
|
+
this.datatype = XSD.langString;
|
|
45
35
|
} else if (datatype) {
|
|
46
|
-
|
|
36
|
+
this.datatype = RDFlibNamedNode.fromValue(datatype);
|
|
47
37
|
} else {
|
|
48
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
155
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
199
|
-
|
|
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
|
-
|
|
6
|
-
debug
|
|
7
|
-
warn
|
|
8
|
-
info
|
|
9
|
-
error
|
|
10
|
-
success
|
|
11
|
-
msg
|
|
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;
|