Skip to content
This repository was archived by the owner on Feb 5, 2020. It is now read-only.

Commit f1b1444

Browse files
committed
Update packages.
1 parent 4ee0aac commit f1b1444

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

lib/triple-pattern-fragments/TurtleFragmentIterator.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function TurtleFragmentIterator(source, fragmentUrl) {
1111
if (!(this instanceof TurtleFragmentIterator))
1212
return new TurtleFragmentIterator(source, fragmentUrl);
1313
TransformIterator.call(this, source);
14+
this._fragmentUrl = fragmentUrl;
1415

1516
// Expose an additional metadata stream
1617
this.metadataStream = new BufferedIterator();
@@ -26,19 +27,24 @@ function TurtleFragmentIterator(source, fragmentUrl) {
2627

2728
// Convert Turtle into triples using the N3 parser
2829
this._parser = new N3.Parser({ documentURI: fragmentUrl });
29-
this._parser.parse(function (error, triple) {
30-
if (error)
31-
self.emit('error', error);
32-
else if (triple)
33-
self._processTriple(triple);
30+
this._parser.parse({
31+
// Use dummy stream to capture `data` and `end` callbacks
32+
on: function (event, callback) {
33+
if (event === 'data') self._parseData = callback;
34+
else if (event === 'end') self._parseEnd = callback;
35+
},
36+
},
37+
// Process each triple and emit possible errors
38+
function (error, triple) {
39+
if (error) self.emit('error', error);
40+
else if (triple) self._processTriple(triple);
3441
});
35-
this._fragmentUrl = fragmentUrl;
3642
}
3743
TransformIterator.subclass(TurtleFragmentIterator);
3844

3945
// Sends a chunk of Turtle to the N3 parser to convert it to triples
4046
TurtleFragmentIterator.prototype._transform = function (chunk, done) {
41-
this._parser.addChunk(chunk), done();
47+
this._parseData(chunk), done();
4248
};
4349

4450
// Sends the given parsed triple to the data or metadata stream
@@ -54,7 +60,7 @@ TurtleFragmentIterator.prototype._processTriple = function (triple) {
5460
// Closes the streams after the source has ended
5561
TurtleFragmentIterator.prototype._flush = function (done) {
5662
// Ensure the parser processes possible pending triples
57-
this._parser && this._parser.end();
63+
this._parseEnd && this._parseEnd();
5864
// Once all triples have been processed, close both streams
5965
this.metadataStream.close();
6066
done();

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"lodash": "~2.4.1",
3030
"lru-cache": "^4.0.1",
3131
"minimist": "^1.2.0",
32-
"n3": "^0.5.0",
32+
"n3": "^0.6.0",
3333
"negotiator": "^0.6.1",
3434
"parse-link-header": "~0.4.1",
3535
"setimmediate": "^1.0.4",
@@ -41,9 +41,9 @@
4141
},
4242
"devDependencies": {
4343
"chai": "^3.5.0",
44-
"eslint": "^3.0.1",
44+
"eslint": "^3.4.0",
4545
"jsdoc": "^3.4.0",
46-
"mocha": "^2.5.3",
46+
"mocha": "^3.0.2",
4747
"pre-commit": "^1.1.3",
4848
"sinon": "^1.17.4",
4949
"sinon-chai": "^2.8.0"

0 commit comments

Comments
 (0)