n3 2.2.1 → 2.2.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/lib/N3Parser.js CHANGED
@@ -689,12 +689,17 @@ class N3Parser {
689
689
  break;
690
690
  // ~ is allowed in the annotation syntax
691
691
  case '~':
692
+ // Only invalidate the cache for a genuinely new triple - chained annotation blocks on the
693
+ // same triple (subject already null from a preceding annotation) must keep reusing it.
694
+ if (subject !== null) this._tripleTerm = null;
692
695
  next = this._readReifierInAnnotation;
693
696
  startingAnnotation = true;
694
697
  break;
695
698
  // {| means that the current triple is annotated with predicate-object pairs.
696
699
  case '{|':
697
700
  // Continue using the last triple as reified triple subject for the predicate-object pairs.
701
+ // Same staleness rule as ~ above.
702
+ if (subject !== null) this._tripleTerm = null;
698
703
  this._subject = this._readTripleTerm();
699
704
  this._validAnnotation = false;
700
705
  startingAnnotation = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
package/src/N3Parser.js CHANGED
@@ -746,12 +746,19 @@ export default class N3Parser {
746
746
  break;
747
747
  // ~ is allowed in the annotation syntax
748
748
  case '~':
749
+ // Only invalidate the cache for a genuinely new triple - chained annotation blocks on the
750
+ // same triple (subject already null from a preceding annotation) must keep reusing it.
751
+ if (subject !== null)
752
+ this._tripleTerm = null;
749
753
  next = this._readReifierInAnnotation;
750
754
  startingAnnotation = true;
751
755
  break;
752
756
  // {| means that the current triple is annotated with predicate-object pairs.
753
757
  case '{|':
754
758
  // Continue using the last triple as reified triple subject for the predicate-object pairs.
759
+ // Same staleness rule as ~ above.
760
+ if (subject !== null)
761
+ this._tripleTerm = null;
755
762
  this._subject = this._readTripleTerm();
756
763
  this._validAnnotation = false;
757
764
  startingAnnotation = true;