n3 1.22.2 → 1.23.0
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/browser/n3.min.js +1 -1
- package/lib/N3Store.js +21 -9
- package/lib/N3Writer.js +1 -1
- package/package.json +2 -2
- package/src/N3Store.js +22 -9
- package/src/N3Writer.js +1 -1
package/lib/N3Store.js
CHANGED
|
@@ -1077,20 +1077,32 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
|
|
|
1077
1077
|
factory: n3Store._factory,
|
|
1078
1078
|
entityIndex: this.options.entityIndex
|
|
1079
1079
|
});
|
|
1080
|
-
const graphs = n3Store._getGraphs(graph);
|
|
1081
1080
|
let subjectId, predicateId, objectId;
|
|
1082
1081
|
|
|
1083
1082
|
// Translate IRIs to internal index keys.
|
|
1084
1083
|
if (subject && !(subjectId = newStore._termToNumericId(subject)) || predicate && !(predicateId = newStore._termToNumericId(predicate)) || object && !(objectId = newStore._termToNumericId(object))) return newStore;
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
objects
|
|
1092
|
-
}
|
|
1084
|
+
const graphs = n3Store._getGraphs(graph);
|
|
1085
|
+
for (const graphKey in graphs) {
|
|
1086
|
+
let subjects, predicates, objects;
|
|
1087
|
+
if (!subjectId && predicateId) {
|
|
1088
|
+
if (predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId])) {
|
|
1089
|
+
subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId]);
|
|
1090
|
+
objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId]);
|
|
1091
|
+
}
|
|
1092
|
+
} else if (objectId) {
|
|
1093
|
+
if (objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId])) {
|
|
1094
|
+
subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId]);
|
|
1095
|
+
predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId]);
|
|
1096
|
+
}
|
|
1097
|
+
} else if (subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId])) {
|
|
1098
|
+
predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId]);
|
|
1099
|
+
objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId]);
|
|
1093
1100
|
}
|
|
1101
|
+
if (subjects) newStore._graphs[graphKey] = {
|
|
1102
|
+
subjects,
|
|
1103
|
+
predicates,
|
|
1104
|
+
objects
|
|
1105
|
+
};
|
|
1094
1106
|
}
|
|
1095
1107
|
newStore._size = null;
|
|
1096
1108
|
}
|
package/lib/N3Writer.js
CHANGED
|
@@ -284,7 +284,7 @@ class N3Writer {
|
|
|
284
284
|
prefixList += (prefixList ? '|' : '') + this._prefixIRIs[prefixIRI];
|
|
285
285
|
}
|
|
286
286
|
IRIlist = escapeRegex(IRIlist, /[\]\/\(\)\*\+\?\.\\\$]/g, '\\$&');
|
|
287
|
-
this._prefixRegex = new RegExp(`^(?:${prefixList})[^\/]*$|` + `^(${IRIlist})([_a-zA-
|
|
287
|
+
this._prefixRegex = new RegExp(`^(?:${prefixList})[^\/]*$|` + `^(${IRIlist})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`);
|
|
288
288
|
}
|
|
289
289
|
// End a prefix block with a newline
|
|
290
290
|
this._write(hasPrefixes ? '\n' : '', done);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n3",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
|
|
5
5
|
"author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"browserify": "^17.0.0",
|
|
39
39
|
"deep-taxonomy-benchmark": "^2.0.0",
|
|
40
40
|
"docco": "^0.9.1",
|
|
41
|
-
"eslint": "^
|
|
41
|
+
"eslint": "^9.12.0",
|
|
42
42
|
"eslint-plugin-import": "^2.29.1",
|
|
43
43
|
"eslint-plugin-jest": "^28.8.3",
|
|
44
44
|
"jest": "^29.7.0",
|
package/src/N3Store.js
CHANGED
|
@@ -1123,7 +1123,6 @@ class DatasetCoreAndReadableStream extends Readable {
|
|
|
1123
1123
|
if (!this._filtered) {
|
|
1124
1124
|
const { n3Store, graph, object, predicate, subject } = this;
|
|
1125
1125
|
const newStore = this._filtered = new N3Store({ factory: n3Store._factory, entityIndex: this.options.entityIndex });
|
|
1126
|
-
const graphs = n3Store._getGraphs(graph);
|
|
1127
1126
|
|
|
1128
1127
|
let subjectId, predicateId, objectId;
|
|
1129
1128
|
|
|
@@ -1133,15 +1132,29 @@ class DatasetCoreAndReadableStream extends Readable {
|
|
|
1133
1132
|
object && !(objectId = newStore._termToNumericId(object)))
|
|
1134
1133
|
return newStore;
|
|
1135
1134
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1135
|
+
const graphs = n3Store._getGraphs(graph);
|
|
1136
|
+
for (const graphKey in graphs) {
|
|
1137
|
+
let subjects, predicates, objects;
|
|
1138
|
+
|
|
1139
|
+
if (!subjectId && predicateId) {
|
|
1140
|
+
if (predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId])) {
|
|
1141
|
+
subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId]);
|
|
1142
|
+
objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId]);
|
|
1143
|
+
}
|
|
1144
1144
|
}
|
|
1145
|
+
else if (objectId) {
|
|
1146
|
+
if (objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId])) {
|
|
1147
|
+
subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId]);
|
|
1148
|
+
predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId]);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
else if (subjects = indexMatch(graphs[graphKey].subjects, [subjectId, predicateId, objectId])) {
|
|
1152
|
+
predicates = indexMatch(graphs[graphKey].predicates, [predicateId, objectId, subjectId]);
|
|
1153
|
+
objects = indexMatch(graphs[graphKey].objects, [objectId, subjectId, predicateId]);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
if (subjects)
|
|
1157
|
+
newStore._graphs[graphKey] = { subjects, predicates, objects };
|
|
1145
1158
|
}
|
|
1146
1159
|
newStore._size = null;
|
|
1147
1160
|
}
|
package/src/N3Writer.js
CHANGED
|
@@ -297,7 +297,7 @@ export default class N3Writer {
|
|
|
297
297
|
}
|
|
298
298
|
IRIlist = escapeRegex(IRIlist, /[\]\/\(\)\*\+\?\.\\\$]/g, '\\$&');
|
|
299
299
|
this._prefixRegex = new RegExp(`^(?:${prefixList})[^\/]*$|` +
|
|
300
|
-
`^(${IRIlist})([_a-zA-
|
|
300
|
+
`^(${IRIlist})([_a-zA-Z0-9][\\-_a-zA-Z0-9]*)$`);
|
|
301
301
|
}
|
|
302
302
|
// End a prefix block with a newline
|
|
303
303
|
this._write(hasPrefixes ? '\n' : '', done);
|