From 4b9f5193effb84d7770ad1d416cfe010fc4b6591 Mon Sep 17 00:00:00 2001 From: Ilia Saulenko Date: Mon, 26 Jan 2015 22:17:13 +0600 Subject: [PATCH 1/2] Error name handling instead of hasNext() --- index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index a339a1f..809f64f 100644 --- a/index.js +++ b/index.js @@ -16,12 +16,12 @@ function CursorStream(cursor) { } CursorStream.prototype._read = function read() { - if (!(this._cursor && this._cursor.hasNext())) { - this.push(null); - return; - } this._cursor.next(function (err, item) { if (err) { + if (((err.name === "RqlDriverError") && err.message === "No more rows in the cursor.")) { + this.push(null); + return; + } this.emit('error', err); return; } @@ -29,4 +29,4 @@ CursorStream.prototype._read = function read() { read.bind(this); } }.bind(this)); -}; \ No newline at end of file +}; From 1255caded46bb74b648eada8155977cf0f244ac4 Mon Sep 17 00:00:00 2001 From: Ilia Saulenko Date: Mon, 26 Jan 2015 22:17:43 +0600 Subject: [PATCH 2/2] Fixed example in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3137f7..1b6c79f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ r.connect( //... // Make a query to get a cursor r.table('myTable').run(connection, function(err, cursor) { var stream = new CursorStream(cursor); - cursor.pipe(//... do whatever you want with your stream ! + stream.pipe(//... do whatever you want with your stream ! }); ```