Comparing version 1.16.4 to 1.17.0
@@ -319,3 +319,2 @@ "use strict"; | ||
case ')': | ||
case '{': | ||
case '}': | ||
@@ -329,2 +328,17 @@ if (!this._lineMode) { | ||
case '{': | ||
// We need at least 2 tokens lookahead to distinguish "{|" and "{ " | ||
if (!this._lineMode && input.length >= 2) { | ||
// Try to find a quoted triple annotation start | ||
if (input[1] === '|') type = '{|', matchLength = 2;else type = firstChar, matchLength = 1; | ||
} | ||
break; | ||
case '|': | ||
// We need 2 tokens lookahead to parse "|}" | ||
// Try to find a quoted triple annotation end | ||
if (input.length >= 2 && input[1] === '}') type = '|}', matchLength = 2; | ||
break; | ||
default: | ||
@@ -331,0 +345,0 @@ inconclusive = true; |
@@ -648,3 +648,20 @@ "use strict"; | ||
break; | ||
// {| means that the current triple is annotated with predicate-object pairs. | ||
case '{|': | ||
if (!this._supportsRDFStar) return this._error('Unexpected RDF* syntax', token); // Continue using the last triple as quoted triple subject for the predicate-object pairs. | ||
const predicate = this._predicate, | ||
object = this._object; | ||
this._subject = this._quad(subject, predicate, object, this.DEFAULTGRAPH); | ||
next = this._readPredicate; | ||
break; | ||
// |} means that the current quoted triple in annotation syntax is finalized. | ||
case '|}': | ||
if (this._subject.termType !== 'Quad') return this._error('Unexpected asserted triple closing', token); | ||
this._subject = null; | ||
next = this._readPunctuation; | ||
break; | ||
default: | ||
@@ -651,0 +668,0 @@ // An entity means this is a quad (only allowed if not already inside a graph) |
{ | ||
"name": "n3", | ||
"version": "1.16.4", | ||
"version": "1.17.0", | ||
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.", | ||
@@ -5,0 +5,0 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>", |
@@ -64,6 +64,6 @@ # Lightning fast, asynchronous, streaming RDF for JavaScript | ||
const myQuad = quad( | ||
namedNode('https://ruben.verborgh.org/profile/#me'), | ||
namedNode('http://xmlns.com/foaf/0.1/givenName'), | ||
literal('Ruben', 'en'), | ||
defaultGraph(), | ||
namedNode('https://ruben.verborgh.org/profile/#me'), // Subject | ||
namedNode('http://xmlns.com/foaf/0.1/givenName'), // Predicate | ||
literal('Ruben', 'en'), // Object | ||
defaultGraph(), // Graph | ||
); | ||
@@ -181,12 +181,12 @@ console.log(myQuad.termType); // Quad | ||
```JavaScript | ||
const writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); | ||
const writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } }); // Create a writer which uses `c` as a prefix for the namespace `http://example.org/cartoons#` | ||
writer.addQuad( | ||
namedNode('http://example.org/cartoons#Tom'), | ||
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), | ||
namedNode('http://example.org/cartoons#Cat') | ||
namedNode('http://example.org/cartoons#Tom'), // Subject | ||
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), // Predicate | ||
namedNode('http://example.org/cartoons#Cat') // Object | ||
); | ||
writer.addQuad(quad( | ||
namedNode('http://example.org/cartoons#Tom'), | ||
namedNode('http://example.org/cartoons#name'), | ||
literal('Tom') | ||
namedNode('http://example.org/cartoons#Tom'), // Subject | ||
namedNode('http://example.org/cartoons#name'), // Predicate | ||
literal('Tom') // Object | ||
)); | ||
@@ -212,10 +212,10 @@ writer.end((error, result) => console.log(result)); | ||
writer.addQuad( | ||
namedNode('http://example.org/cartoons#Tom'), | ||
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), | ||
namedNode('http://example.org/cartoons#Cat') | ||
namedNode('http://example.org/cartoons#Tom'), // Subject | ||
namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), // Predicate | ||
namedNode('http://example.org/cartoons#Cat') // Object | ||
); | ||
writer.addQuad(quad( | ||
namedNode('http://example.org/cartoons#Tom'), | ||
namedNode('http://example.org/cartoons#name'), | ||
literal('Tom') | ||
namedNode('http://example.org/cartoons#Tom'), // Subject | ||
namedNode('http://example.org/cartoons#name'), // Predicate | ||
literal('Tom') // Object | ||
)); | ||
@@ -222,0 +222,0 @@ writer.end(); |
@@ -303,3 +303,2 @@ // **N3Lexer** tokenizes N3 documents. | ||
case ')': | ||
case '{': | ||
case '}': | ||
@@ -311,2 +310,18 @@ if (!this._lineMode) { | ||
break; | ||
case '{': | ||
// We need at least 2 tokens lookahead to distinguish "{|" and "{ " | ||
if (!this._lineMode && input.length >= 2) { | ||
// Try to find a quoted triple annotation start | ||
if (input[1] === '|') | ||
type = '{|', matchLength = 2; | ||
else | ||
type = firstChar, matchLength = 1; | ||
} | ||
break; | ||
case '|': | ||
// We need 2 tokens lookahead to parse "|}" | ||
// Try to find a quoted triple annotation end | ||
if (input.length >= 2 && input[1] === '}') | ||
type = '|}', matchLength = 2; | ||
break; | ||
@@ -313,0 +328,0 @@ default: |
@@ -617,2 +617,18 @@ // **N3Parser** parses N3 documents. | ||
break; | ||
// {| means that the current triple is annotated with predicate-object pairs. | ||
case '{|': | ||
if (!this._supportsRDFStar) | ||
return this._error('Unexpected RDF* syntax', token); | ||
// Continue using the last triple as quoted triple subject for the predicate-object pairs. | ||
const predicate = this._predicate, object = this._object; | ||
this._subject = this._quad(subject, predicate, object, this.DEFAULTGRAPH); | ||
next = this._readPredicate; | ||
break; | ||
// |} means that the current quoted triple in annotation syntax is finalized. | ||
case '|}': | ||
if (this._subject.termType !== 'Quad') | ||
return this._error('Unexpected asserted triple closing', token); | ||
this._subject = null; | ||
next = this._readPunctuation; | ||
break; | ||
default: | ||
@@ -619,0 +635,0 @@ // An entity means this is a quad (only allowed if not already inside a graph) |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
517522
6832
0