n3 2.5.0 → 2.6.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/lib/N3Lexer.js CHANGED
@@ -131,12 +131,12 @@ class N3Lexer {
131
131
  // Try to find a comment
132
132
  if (this.comments && (comment = this._comment.exec(whiteSpaceMatch[0]))) emitToken('comment', comment[1], '', this._line, whiteSpaceMatch[0].length);
133
133
  // Advance the input
134
- input = input.substr(whiteSpaceMatch[0].length, input.length);
134
+ input = input.slice(whiteSpaceMatch[0].length);
135
135
  currentLineLength = input.length;
136
136
  this._line++;
137
137
  }
138
138
  // Skip whitespace on current line
139
- if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input))) input = input.substr(whiteSpaceMatch[0].length, input.length);
139
+ if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input))) input = input.slice(whiteSpaceMatch[0].length);
140
140
 
141
141
  // Stop for now if we're at the end
142
142
  if (this._endOfFile.test(input)) {
@@ -167,7 +167,7 @@ class N3Lexer {
167
167
  else if (input[1] === '^') {
168
168
  this._previousMarker = '^^';
169
169
  // Move to type IRI or prefixed name
170
- input = input.substr(2);
170
+ input = input.slice(2);
171
171
  if (input[0] !== '<') {
172
172
  inconclusive = true;
173
173
  break;
@@ -406,7 +406,7 @@ class N3Lexer {
406
406
  this._previousMarker = type;
407
407
 
408
408
  // Advance to next part to tokenize
409
- input = input.substr(length, input.length);
409
+ input = input.slice(length);
410
410
  }
411
411
 
412
412
  // Emits the token through the callback
@@ -516,7 +516,7 @@ class N3Lexer {
516
516
 
517
517
  // ### Strips off any starting UTF BOM mark.
518
518
  _readStartingBom(input) {
519
- return input.startsWith('\ufeff') ? input.substr(1) : input;
519
+ return input.startsWith('\ufeff') ? input.slice(1) : input;
520
520
  }
521
521
 
522
522
  // ## Public methods
package/lib/N3Parser.js CHANGED
@@ -36,6 +36,8 @@ class N3Parser {
36
36
  this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
37
37
  // Whether the log:isImpliedBy predicate is supported
38
38
  this._isImpliedBy = options.isImpliedBy;
39
+ // Whether an undeclared empty prefix resolves against the document IRI
40
+ this._implicitEmptyPrefix = !!options.implicitEmptyPrefix;
39
41
  // Whether an empty formula is read as the boolean literal true,
40
42
  // as in the N3 spec tests (opt-in until the next major version)
41
43
  this._emptyFormulaAsTrue = !!options.emptyFormulaAsTrue;
@@ -1406,6 +1408,8 @@ class N3Parser {
1406
1408
  this._sparqlStyle = false;
1407
1409
  this._prefixes = Object.create(null);
1408
1410
  this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2) : `b${blankNodePrefix++}_`;
1411
+ // Optionally bind the N3 empty prefix to the document's local namespace
1412
+ if (this._n3Mode && this._implicitEmptyPrefix && this._base) this._prefixes[''] = this._resolveIRI('#');
1409
1413
  this._prefixCallback = onPrefix || noop;
1410
1414
  this._versionCallback = onVersion || noop;
1411
1415
  this._inversePredicate = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.5.0",
3
+ "version": "2.6.1",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
@@ -34,7 +34,6 @@
34
34
  "@babel/register": "^8.0.1",
35
35
  "@rdfjs/data-model": "^1",
36
36
  "arrayify-stream": "^3.0.0",
37
- "browserify": "^17.0.0",
38
37
  "deep-taxonomy-benchmark": "^2.0.0",
39
38
  "docco": "^0.9.1",
40
39
  "esbuild": "^0.28.1",
@@ -43,18 +42,21 @@
43
42
  "eslint-plugin-jest": "^29.15.0",
44
43
  "globals": "^17.6.0",
45
44
  "jest": "^30.4.2",
45
+ "playwright": "^1.61.1",
46
46
  "pre-commit": "^2.0.0",
47
47
  "rdf-isomorphic": "^2.0.0",
48
48
  "rdf-test-suite": "^2.1.4",
49
- "streamify-string": "^1.0.1",
50
- "uglify-js": "^3.14.3"
49
+ "streamify-string": "^1.0.1"
50
+ },
51
+ "overrides": {
52
+ "js-yaml": "^4.2.0"
51
53
  },
52
54
  "scripts": {
53
55
  "build": "npm run build:node && npm run build:browser",
54
56
  "build:node": "babel src -d lib",
55
- "build:browser": "rm -rf browser && mkdir browser && npm run build:browser:umd && npm run build:browser:esm",
56
- "build:browser:umd": "browserify -s N3 lib/index.js | uglifyjs > browser/n3.min.js",
57
- "build:browser:esm": "node scripts/build-esm.js",
57
+ "build:browser": "rm -rf browser && mkdir browser && npm run build:browser:iife && npm run build:browser:esm",
58
+ "build:browser:iife": "node scripts/build-browser-bundle.js iife",
59
+ "build:browser:esm": "node scripts/build-browser-bundle.js esm",
58
60
  "test": "jest",
59
61
  "lint": "eslint src perf test spec",
60
62
  "prepare": "npm run build",
package/src/N3Lexer.js CHANGED
@@ -102,13 +102,13 @@ export default class N3Lexer {
102
102
  if (this.comments && (comment = this._comment.exec(whiteSpaceMatch[0])))
103
103
  emitToken('comment', comment[1], '', this._line, whiteSpaceMatch[0].length);
104
104
  // Advance the input
105
- input = input.substr(whiteSpaceMatch[0].length, input.length);
105
+ input = input.slice(whiteSpaceMatch[0].length);
106
106
  currentLineLength = input.length;
107
107
  this._line++;
108
108
  }
109
109
  // Skip whitespace on current line
110
110
  if (!whiteSpaceMatch && (whiteSpaceMatch = this._whitespace.exec(input)))
111
- input = input.substr(whiteSpaceMatch[0].length, input.length);
111
+ input = input.slice(whiteSpaceMatch[0].length);
112
112
 
113
113
  // Stop for now if we're at the end
114
114
  if (this._endOfFile.test(input)) {
@@ -136,7 +136,7 @@ export default class N3Lexer {
136
136
  else if (input[1] === '^') {
137
137
  this._previousMarker = '^^';
138
138
  // Move to type IRI or prefixed name
139
- input = input.substr(2);
139
+ input = input.slice(2);
140
140
  if (input[0] !== '<') {
141
141
  inconclusive = true;
142
142
  break;
@@ -425,7 +425,7 @@ export default class N3Lexer {
425
425
  this._previousMarker = type;
426
426
 
427
427
  // Advance to next part to tokenize
428
- input = input.substr(length, input.length);
428
+ input = input.slice(length);
429
429
  }
430
430
 
431
431
  // Emits the token through the callback
@@ -525,7 +525,7 @@ export default class N3Lexer {
525
525
 
526
526
  // ### Strips off any starting UTF BOM mark.
527
527
  _readStartingBom(input) {
528
- return input.startsWith('\ufeff') ? input.substr(1) : input;
528
+ return input.startsWith('\ufeff') ? input.slice(1) : input;
529
529
  }
530
530
 
531
531
  // ## Public methods
package/src/N3Parser.js CHANGED
@@ -29,6 +29,8 @@ export default class N3Parser {
29
29
  this._supportsQuads = !(isTurtle || isTriG || isNTriples || isN3);
30
30
  // Whether the log:isImpliedBy predicate is supported
31
31
  this._isImpliedBy = options.isImpliedBy;
32
+ // Whether an undeclared empty prefix resolves against the document IRI
33
+ this._implicitEmptyPrefix = !!options.implicitEmptyPrefix;
32
34
  // Whether an empty formula is read as the boolean literal true,
33
35
  // as in the N3 spec tests (opt-in until the next major version)
34
36
  this._emptyFormulaAsTrue = !!options.emptyFormulaAsTrue;
@@ -1522,6 +1524,9 @@ export default class N3Parser {
1522
1524
  this._prefixes = Object.create(null);
1523
1525
  this._prefixes._ = this._blankNodePrefix ? this._blankNodePrefix.substr(2)
1524
1526
  : `b${blankNodePrefix++}_`;
1527
+ // Optionally bind the N3 empty prefix to the document's local namespace
1528
+ if (this._n3Mode && this._implicitEmptyPrefix && this._base)
1529
+ this._prefixes[''] = this._resolveIRI('#');
1525
1530
  this._prefixCallback = onPrefix || noop;
1526
1531
  this._versionCallback = onVersion || noop;
1527
1532
  this._inversePredicate = false;