Comparing version 1.0.0 to 1.0.1
@@ -426,2 +426,3 @@ // **N3Lexer** tokenizes N3 documents. | ||
this._input = ''; | ||
this._pendingBuffer = null; | ||
if (typeof input.setEncoding === 'function') | ||
@@ -431,5 +432,17 @@ input.setEncoding('utf8'); | ||
input.on('data', function (data) { | ||
if (self._input !== null) { | ||
self._input += data; | ||
self._tokenizeToEnd(callback, false); | ||
if (self._input !== null && data.length !== 0) { | ||
// Prepend any previous pending writes | ||
if (self._pendingBuffer) { | ||
data = Buffer.concat([self._pendingBuffer, data]); | ||
self._pendingBuffer = null; | ||
} | ||
// Hold if the buffer ends in an incomplete unicode sequence | ||
if (data[data.length - 1] & 0x80) { | ||
self._pendingBuffer = data; | ||
} | ||
// Otherwise, tokenize as far as possible | ||
else { | ||
self._input += data; | ||
self._tokenizeToEnd(callback, false); | ||
} | ||
} | ||
@@ -436,0 +449,0 @@ }); |
{ | ||
"name": "n3", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.", | ||
@@ -5,0 +5,0 @@ "author": "Ruben Verborgh <ruben.verborgh@gmail.com>", |
126317
2699