n3 1.23.0 → 1.23.2

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/src/N3Store.js CHANGED
@@ -1134,27 +1134,28 @@ class DatasetCoreAndReadableStream extends Readable {
1134
1134
 
1135
1135
  const graphs = n3Store._getGraphs(graph);
1136
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]);
1137
+ let subjects, predicates, objects, content;
1138
+ if (content = graphs[graphKey]) {
1139
+ if (!subjectId && predicateId) {
1140
+ if (predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId])) {
1141
+ subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);
1142
+ objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);
1143
+ }
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]);
1145
+ else if (objectId) {
1146
+ if (objects = indexMatch(content.objects, [objectId, subjectId, predicateId])) {
1147
+ subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId]);
1148
+ predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);
1149
+ }
1150
+ }
1151
+ else if (subjects = indexMatch(content.subjects, [subjectId, predicateId, objectId])) {
1152
+ predicates = indexMatch(content.predicates, [predicateId, objectId, subjectId]);
1153
+ objects = indexMatch(content.objects, [objectId, subjectId, predicateId]);
1149
1154
  }
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
1155
 
1156
- if (subjects)
1157
- newStore._graphs[graphKey] = { subjects, predicates, objects };
1156
+ if (subjects)
1157
+ newStore._graphs[graphKey] = { subjects, predicates, objects };
1158
+ }
1158
1159
  }
1159
1160
  newStore._size = null;
1160
1161
  }