n3 2.6.1 → 2.6.3
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.esm.min.js +6 -6
- package/browser/n3.min.js +7 -7
- package/lib/N3Store.js +5 -6
- package/lib/N3Writer.js +9 -5
- package/package.json +1 -1
- package/src/N3Store.js +6 -6
- package/src/N3Writer.js +10 -6
package/lib/N3Store.js
CHANGED
|
@@ -1085,10 +1085,9 @@ class N3Store {
|
|
|
1085
1085
|
}
|
|
1086
1086
|
|
|
1087
1087
|
// ### Store is an iterable.
|
|
1088
|
-
//
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
yield* this.readQuads();
|
|
1088
|
+
// Returns the quad iterator directly; order is not guaranteed.
|
|
1089
|
+
[Symbol.iterator]() {
|
|
1090
|
+
return this.readQuads();
|
|
1092
1091
|
}
|
|
1093
1092
|
}
|
|
1094
1093
|
|
|
@@ -1267,7 +1266,7 @@ class DatasetCoreAndReadableStream extends _readableStream.Readable {
|
|
|
1267
1266
|
match(subject, predicate, object, graph) {
|
|
1268
1267
|
return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph, this.options);
|
|
1269
1268
|
}
|
|
1270
|
-
|
|
1271
|
-
|
|
1269
|
+
[Symbol.iterator]() {
|
|
1270
|
+
return this._filtered ? this._filtered[Symbol.iterator]() : this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);
|
|
1272
1271
|
}
|
|
1273
1272
|
}
|
package/lib/N3Writer.js
CHANGED
|
@@ -106,16 +106,16 @@ class N3Writer {
|
|
|
106
106
|
// Write the graph's label if it has changed
|
|
107
107
|
// (the id-based fast path of `equals` would conflate
|
|
108
108
|
// the empty named node `<>` with the default graph)
|
|
109
|
-
if (!graph.equals(this._graph) || graph.termType !== this._graph.termType) {
|
|
109
|
+
if (graph !== this._graph && (!graph.equals(this._graph) || graph.termType !== this._graph.termType)) {
|
|
110
110
|
// Close the previous graph and start the new one
|
|
111
111
|
this._write((this._subject === null ? '' : this._inDefaultGraph ? '.\n' : '\n}\n') + (DEFAULTGRAPH.equals(graph) ? '' : `${this._encodeIriOrBlank(graph)} {\n`));
|
|
112
112
|
this._graph = graph;
|
|
113
113
|
this._subject = null;
|
|
114
114
|
}
|
|
115
115
|
// Don't repeat the subject if it's the same
|
|
116
|
-
if (subject.equals(this._subject)) {
|
|
116
|
+
if (subject === this._subject || subject.equals(this._subject)) {
|
|
117
117
|
// Don't repeat the predicate if it's the same
|
|
118
|
-
if (predicate.equals(this._predicate)) this._write(`, ${this._encodeObject(object)}`, done);
|
|
118
|
+
if (predicate === this._predicate || predicate.equals(this._predicate)) this._write(`, ${this._encodeObject(object)}`, done);
|
|
119
119
|
// Same subject, different predicate
|
|
120
120
|
else this._write(`;\n ${this._encodePredicate(this._predicate = predicate)} ${this._encodeObject(object)}`, done);
|
|
121
121
|
}
|
|
@@ -177,8 +177,12 @@ class N3Writer {
|
|
|
177
177
|
if (escape.test(value)) value = value.replace(escapeAll, characterReplacer);
|
|
178
178
|
|
|
179
179
|
// Write a language-tagged literal
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
180
|
+
const language = literal.language;
|
|
181
|
+
if (language) {
|
|
182
|
+
const literalDirection = literal.direction;
|
|
183
|
+
const direction = literalDirection ? `--${literalDirection}` : '';
|
|
184
|
+
return `"${value}"@${language}${direction}`;
|
|
185
|
+
}
|
|
182
186
|
|
|
183
187
|
// Write dedicated literals per data type
|
|
184
188
|
if (this._lineMode) {
|
package/package.json
CHANGED
package/src/N3Store.js
CHANGED
|
@@ -1148,10 +1148,9 @@ export default class N3Store {
|
|
|
1148
1148
|
}
|
|
1149
1149
|
|
|
1150
1150
|
// ### Store is an iterable.
|
|
1151
|
-
//
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
yield* this.readQuads();
|
|
1151
|
+
// Returns the quad iterator directly; order is not guaranteed.
|
|
1152
|
+
[Symbol.iterator]() {
|
|
1153
|
+
return this.readQuads();
|
|
1155
1154
|
}
|
|
1156
1155
|
}
|
|
1157
1156
|
|
|
@@ -1345,7 +1344,8 @@ class DatasetCoreAndReadableStream extends Readable {
|
|
|
1345
1344
|
return new DatasetCoreAndReadableStream(this.filtered, subject, predicate, object, graph, this.options);
|
|
1346
1345
|
}
|
|
1347
1346
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1347
|
+
[Symbol.iterator]() {
|
|
1348
|
+
return this._filtered ? this._filtered[Symbol.iterator]() :
|
|
1349
|
+
this.n3Store.readQuads(this.subject, this.predicate, this.object, this.graph);
|
|
1350
1350
|
}
|
|
1351
1351
|
}
|
package/src/N3Writer.js
CHANGED
|
@@ -90,7 +90,8 @@ export default class N3Writer {
|
|
|
90
90
|
// Write the graph's label if it has changed
|
|
91
91
|
// (the id-based fast path of `equals` would conflate
|
|
92
92
|
// the empty named node `<>` with the default graph)
|
|
93
|
-
if (
|
|
93
|
+
if (graph !== this._graph &&
|
|
94
|
+
(!graph.equals(this._graph) || graph.termType !== this._graph.termType)) {
|
|
94
95
|
// Close the previous graph and start the new one
|
|
95
96
|
this._write((this._subject === null ? '' : (this._inDefaultGraph ? '.\n' : '\n}\n')) +
|
|
96
97
|
(DEFAULTGRAPH.equals(graph) ? '' : `${this._encodeIriOrBlank(graph)} {\n`));
|
|
@@ -98,9 +99,9 @@ export default class N3Writer {
|
|
|
98
99
|
this._subject = null;
|
|
99
100
|
}
|
|
100
101
|
// Don't repeat the subject if it's the same
|
|
101
|
-
if (subject.equals(this._subject)) {
|
|
102
|
+
if (subject === this._subject || subject.equals(this._subject)) {
|
|
102
103
|
// Don't repeat the predicate if it's the same
|
|
103
|
-
if (predicate.equals(this._predicate))
|
|
104
|
+
if (predicate === this._predicate || predicate.equals(this._predicate))
|
|
104
105
|
this._write(`, ${this._encodeObject(object)}`, done);
|
|
105
106
|
// Same subject, different predicate
|
|
106
107
|
else
|
|
@@ -179,9 +180,12 @@ export default class N3Writer {
|
|
|
179
180
|
value = value.replace(escapeAll, characterReplacer);
|
|
180
181
|
|
|
181
182
|
// Write a language-tagged literal
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
|
|
183
|
+
const language = literal.language;
|
|
184
|
+
if (language) {
|
|
185
|
+
const literalDirection = literal.direction;
|
|
186
|
+
const direction = literalDirection ? `--${literalDirection}` : '';
|
|
187
|
+
return `"${value}"@${language}${direction}`;
|
|
188
|
+
}
|
|
185
189
|
|
|
186
190
|
// Write dedicated literals per data type
|
|
187
191
|
if (this._lineMode) {
|