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.
- package/dist/515.rdflib.min.js +3 -0
- package/dist/515.rdflib.min.js.map +1 -0
- package/dist/789.rdflib.min.js +1 -0
- 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 -85
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -106
- package/esm/default-graph.js +13 -33
- package/esm/empty.js +8 -26
- package/esm/factories/canonical-data-factory.js +33 -30
- package/esm/factories/extended-term-factory.js +18 -14
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1364 -1668
- package/esm/formula.js +631 -739
- package/esm/index.js +31 -51
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +41 -86
- package/esm/literal.js +120 -157
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1008 -1090
- package/esm/named-node.js +69 -99
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -97
- package/esm/node.js +1 -2
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -2
- package/esm/query.js +15 -30
- package/esm/rdfaparser.js +775 -846
- package/esm/rdfxmlparser.js +348 -365
- package/esm/serialize.js +2 -3
- package/esm/serializer.js +834 -889
- package/esm/sparql-to-query.js +0 -2
- package/esm/statement.js +52 -72
- package/esm/store.js +852 -963
- package/esm/types.js +26 -21
- package/esm/update-manager.js +964 -1104
- package/esm/updates-via.js +104 -134
- 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 -6
- package/esm/utils.js +7 -6
- package/esm/variable.js +32 -58
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +56 -83
- package/lib/class-order.js +2 -3
- package/lib/collection.js +69 -104
- package/lib/default-graph.js +13 -32
- package/lib/empty.js +8 -25
- package/lib/factories/canonical-data-factory.js +36 -34
- package/lib/factories/extended-term-factory.js +19 -16
- package/lib/factories/factory-types.js +2 -3
- package/lib/factories/rdflib-data-factory.js +10 -13
- package/lib/fetcher.js +1394 -1693
- package/lib/formula.js +631 -738
- package/lib/index.js +66 -89
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +3 -4
- package/lib/lists.js +47 -87
- package/lib/literal.js +120 -156
- package/lib/log.js +8 -9
- package/lib/n3parser.js +1011 -1096
- package/lib/named-node.js +69 -98
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +72 -95
- package/lib/node.js +2 -4
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -2
- package/lib/query.js +19 -32
- package/lib/rdfaparser.js +777 -849
- package/lib/rdfxmlparser.js +350 -366
- package/lib/serialize.js +2 -3
- package/lib/serializer.js +838 -892
- package/lib/sparql-to-query.js +0 -2
- package/lib/statement.js +54 -74
- package/lib/store.js +873 -978
- package/lib/types.js +22 -43
- package/lib/update-manager.js +973 -1111
- package/lib/updates-via.js +105 -134
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -4
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +11 -13
- package/lib/utils.js +6 -7
- package/lib/variable.js +34 -60
- package/lib/xsd-internal.js +2 -3
- package/lib/xsd.js +3 -4
- package/package.json +31 -31
- package/src/n3parser.js +1 -1
- package/src/rdfxmlparser.js +2 -1
- package/src/serializer.js +1 -1
- package/src/update-manager.ts +2 -1
- package/.babelrc +0 -20
- package/dist/670.rdflib.min.js +0 -1
- package/dist/730.rdflib.min.js +0 -3
- package/dist/730.rdflib.min.js.map +0 -1
- /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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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(
|
|
40
|
-
_defineProperty(
|
|
26
|
+
_defineProperty(this, "datatype", XSD.string);
|
|
27
|
+
_defineProperty(this, "isVar", 0);
|
|
41
28
|
/**
|
|
42
29
|
* The language for the literal
|
|
43
30
|
*/
|
|
44
|
-
_defineProperty(
|
|
31
|
+
_defineProperty(this, "language", '');
|
|
45
32
|
if (language) {
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
this.language = language;
|
|
34
|
+
this.datatype = XSD.langString;
|
|
48
35
|
} else if (datatype) {
|
|
49
|
-
|
|
36
|
+
this.datatype = RDFlibNamedNode.fromValue(datatype);
|
|
50
37
|
} else {
|
|
51
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
157
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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;
|