n3 2.10.0 → 2.10.1
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 +5 -5
- package/browser/n3.min.js +5 -5
- package/lib/N3DataFactory.js +10 -2
- package/package.json +7 -3
- package/src/N3DataFactory.js +10 -2
package/lib/N3DataFactory.js
CHANGED
|
@@ -23,6 +23,8 @@ const {
|
|
|
23
23
|
// eslint-disable-next-line prefer-const
|
|
24
24
|
let DEFAULTGRAPH;
|
|
25
25
|
let _blankNodeCounter = 0;
|
|
26
|
+
// The ID of the empty IRI, which cannot be '' as that is the ID of the default graph
|
|
27
|
+
const EMPTY_IRI_ID = '<>';
|
|
26
28
|
const escapedLiteral = /^"(.*".*)(?="[^"]*$)/;
|
|
27
29
|
|
|
28
30
|
// ## DataFactory singleton
|
|
@@ -82,7 +84,10 @@ class NamedNode extends Term {
|
|
|
82
84
|
* the constructor assumes an already-validated IRI.
|
|
83
85
|
*/
|
|
84
86
|
constructor(iri) {
|
|
85
|
-
super(iri);
|
|
87
|
+
super(iri === '' ? EMPTY_IRI_ID : iri);
|
|
88
|
+
if (iri === '') Object.defineProperty(this, 'value', {
|
|
89
|
+
value: ''
|
|
90
|
+
});
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
// ### The term type of this term
|
|
@@ -291,6 +296,9 @@ function termFromId(id, factory, nested) {
|
|
|
291
296
|
case '[':
|
|
292
297
|
id = JSON.parse(id);
|
|
293
298
|
break;
|
|
299
|
+
case '<':
|
|
300
|
+
if (id === EMPTY_IRI_ID) return factory.namedNode('');
|
|
301
|
+
// falls through
|
|
294
302
|
default:
|
|
295
303
|
if (!nested || !Array.isArray(id)) {
|
|
296
304
|
return factory.namedNode(id);
|
|
@@ -312,7 +320,7 @@ function termToId(term, nested) {
|
|
|
312
320
|
// Term instantiated with another library
|
|
313
321
|
switch (term.termType) {
|
|
314
322
|
case 'NamedNode':
|
|
315
|
-
return term.value;
|
|
323
|
+
return term.value || EMPTY_IRI_ID;
|
|
316
324
|
case 'BlankNode':
|
|
317
325
|
return `_:${term.value}`;
|
|
318
326
|
case 'Variable':
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n3",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.1",
|
|
4
4
|
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
|
|
5
5
|
"author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
|
|
6
6
|
"keywords": [
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"test": "jest",
|
|
61
61
|
"lint": "eslint src perf test spec",
|
|
62
62
|
"prepare": "npm run build",
|
|
63
|
-
"spec": "npm run spec-1-1 && npm run spec-1-2",
|
|
63
|
+
"spec": "npm run spec-1-1 && npm run spec-1-2 && npm run spec-n3",
|
|
64
64
|
"spec-1-1": "npm run spec-1-1-turtle && npm run spec-1-1-ntriples && npm run spec-1-1-nquads && npm run spec-1-1-trig",
|
|
65
65
|
"spec-1-1-earl": "npm run spec-1-1-earl-turtle && npm run spec-1-1-earl-ntriples && npm run spec-1-1-earl-nquads && npm run spec-1-1-earl-trig",
|
|
66
66
|
"spec-1-1-ntriples": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-tests/rdf/rdf11/rdf-n-triples/manifest.ttl -i '{ \"format\": \"n-triples\" }' -c .rdf-test-suite-cache/",
|
|
@@ -81,7 +81,11 @@
|
|
|
81
81
|
"spec-1-2-earl-nquads": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-tests/rdf/rdf12/rdf-n-quads/syntax/manifest.ttl -i '{ \"format\": \"n-quads\" }' -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-nquads.ttl",
|
|
82
82
|
"spec-1-2-earl-turtle": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-tests/rdf/rdf12/rdf-turtle/syntax/manifest.ttl -i '{ \"format\": \"turtle\" }' -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-turtle.ttl",
|
|
83
83
|
"spec-1-2-earl-trig": "rdf-test-suite spec/parser.js https://w3c.github.io/rdf-tests/rdf/rdf12/rdf-trig/syntax/manifest.ttl -i '{ \"format\": \"trig\" }' -c .rdf-test-suite-cache/ -o earl -p spec/earl-meta.json > spec/earl-trig.ttl",
|
|
84
|
-
"spec-
|
|
84
|
+
"spec-n3": "npm run spec-n3-parser && npm run spec-n3-extended",
|
|
85
|
+
"spec-n3-fetch": "sh scripts/fetch-n3-tests.sh",
|
|
86
|
+
"spec-n3-parser": "npm run spec-n3-fetch && rdf-test-suite spec/parser.js https://w3c-cg.github.io/N3/tests/N3Tests/manifest-parser.ttl -i '{ \"format\": \"text/n3\" }' -m 'https://w3c-cg.github.io/N3/tests/~.n3-tests/tests/'",
|
|
87
|
+
"spec-n3-extended": "npm run spec-n3-fetch && rdf-test-suite spec/parser.js https://w3c-cg.github.io/N3/tests/N3Tests/manifest-extended.ttl -i '{ \"format\": \"text/n3\" }' -m 'https://w3c-cg.github.io/N3/tests/~.n3-tests/tests/'",
|
|
88
|
+
"spec-clean": "rm -rf .rdf-test-suite-cache/ .n3-tests/",
|
|
85
89
|
"docs": "cd src && docco *.js -o ../docs && cd .."
|
|
86
90
|
},
|
|
87
91
|
"repository": {
|
package/src/N3DataFactory.js
CHANGED
|
@@ -8,6 +8,8 @@ const { rdf, xsd } = namespaces;
|
|
|
8
8
|
// eslint-disable-next-line prefer-const
|
|
9
9
|
let DEFAULTGRAPH;
|
|
10
10
|
let _blankNodeCounter = 0;
|
|
11
|
+
// The ID of the empty IRI, which cannot be '' as that is the ID of the default graph
|
|
12
|
+
const EMPTY_IRI_ID = '<>';
|
|
11
13
|
|
|
12
14
|
const escapedLiteral = /^"(.*".*)(?="[^"]*$)/;
|
|
13
15
|
|
|
@@ -72,7 +74,9 @@ export class NamedNode extends Term {
|
|
|
72
74
|
* the constructor assumes an already-validated IRI.
|
|
73
75
|
*/
|
|
74
76
|
constructor(iri) {
|
|
75
|
-
super(iri);
|
|
77
|
+
super(iri === '' ? EMPTY_IRI_ID : iri);
|
|
78
|
+
if (iri === '')
|
|
79
|
+
Object.defineProperty(this, 'value', { value: '' });
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
// ### The term type of this term
|
|
@@ -285,6 +289,10 @@ export function termFromId(id, factory, nested) {
|
|
|
285
289
|
case '[':
|
|
286
290
|
id = JSON.parse(id);
|
|
287
291
|
break;
|
|
292
|
+
case '<':
|
|
293
|
+
if (id === EMPTY_IRI_ID)
|
|
294
|
+
return factory.namedNode('');
|
|
295
|
+
// falls through
|
|
288
296
|
default:
|
|
289
297
|
if (!nested || !Array.isArray(id)) {
|
|
290
298
|
return factory.namedNode(id);
|
|
@@ -313,7 +321,7 @@ export function termToId(term, nested) {
|
|
|
313
321
|
|
|
314
322
|
// Term instantiated with another library
|
|
315
323
|
switch (term.termType) {
|
|
316
|
-
case 'NamedNode': return term.value;
|
|
324
|
+
case 'NamedNode': return term.value || EMPTY_IRI_ID;
|
|
317
325
|
case 'BlankNode': return `_:${term.value}`;
|
|
318
326
|
case 'Variable': return `?${term.value}`;
|
|
319
327
|
case 'DefaultGraph': return '';
|