Comparing version 1.11.0 to 1.11.1
@@ -473,2 +473,7 @@ "use strict"; | ||
return err; | ||
} // ### Strips off any starting UTF BOM mark. | ||
_readStartingBom(input) { | ||
return input.startsWith('\ufeff') ? input.substr(1) : input; | ||
} // ## Public methods | ||
@@ -483,3 +488,3 @@ // ### `tokenize` starts the transformation of an N3 document into an array of tokens. | ||
if (typeof input === 'string') { | ||
this._input = input; // If a callback was passed, asynchronously call it | ||
this._input = this._readStartingBom(input); // If a callback was passed, asynchronously call it | ||
@@ -498,3 +503,2 @@ if (typeof callback === 'function') (0, _queueMicrotask.default)(() => this._tokenizeToEnd(callback, true)); // If no callback was passed, tokenize synchronously and return | ||
else { | ||
this._input = ''; | ||
this._pendingBuffer = null; | ||
@@ -516,3 +520,4 @@ if (typeof input.setEncoding === 'function') input.setEncoding('utf8'); // Adds the data chunk to the buffer and parses as far as possible | ||
else { | ||
this._input += data; | ||
// Only read a BOM at the start | ||
if (typeof this._input === 'undefined') this._input = this._readStartingBom(typeof data === 'string' ? data : data.toString());else this._input += data; | ||
@@ -525,3 +530,3 @@ this._tokenizeToEnd(callback, false); | ||
input.on('end', () => { | ||
if (this._input !== null) this._tokenizeToEnd(callback, true); | ||
if (typeof this._input === 'string') this._tokenizeToEnd(callback, true); | ||
}); | ||
@@ -528,0 +533,0 @@ input.on('error', callback); |
{ | ||
"name": "n3", | ||
"version": "1.11.0", | ||
"version": "1.11.1", | ||
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.", | ||
@@ -5,0 +5,0 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>", |
@@ -432,2 +432,7 @@ // **N3Lexer** tokenizes N3 documents. | ||
// ### Strips off any starting UTF BOM mark. | ||
_readStartingBom(input) { | ||
return input.startsWith('\ufeff') ? input.substr(1) : input; | ||
} | ||
// ## Public methods | ||
@@ -442,3 +447,3 @@ | ||
if (typeof input === 'string') { | ||
this._input = input; | ||
this._input = this._readStartingBom(input); | ||
// If a callback was passed, asynchronously call it | ||
@@ -458,3 +463,2 @@ if (typeof callback === 'function') | ||
else { | ||
this._input = ''; | ||
this._pendingBuffer = null; | ||
@@ -477,3 +481,7 @@ if (typeof input.setEncoding === 'function') | ||
else { | ||
this._input += data; | ||
// Only read a BOM at the start | ||
if (typeof this._input === 'undefined') | ||
this._input = this._readStartingBom(typeof data === 'string' ? data : data.toString()); | ||
else | ||
this._input += data; | ||
this._tokenizeToEnd(callback, false); | ||
@@ -485,3 +493,3 @@ } | ||
input.on('end', () => { | ||
if (this._input !== null) | ||
if (typeof this._input === 'string') | ||
this._tokenizeToEnd(callback, true); | ||
@@ -488,0 +496,0 @@ }); |
271768
5840